@@ -154,11 +154,30 @@ public void filter_allowExpression_onlyAllowsRelevantExpressions()
154154 HeaderMutations filtered = filter .filter (mutations );
155155
156156
157- assertThat (filtered .headersToRemove ()).containsExactly ("x-allowed-remove" );
157+ assertThat (filtered .headersToRemove ()).containsExactly ("x-allowed-remove" ,
158+ "not-allowed-remove" );
158159 assertThat (filtered .headers ()).containsExactly (header ("x-allowed-key" , "value" ),
159- header ("x-allowed-resp-key" , "value" ));
160+ header ("not-allowed-key" , "value" ), header ("x-allowed-resp-key" , "value" ),
161+ header ("not-allowed-resp-key" , "value" ));
162+ }
163+
164+ @ Test
165+ public void filter_allowExpression_fallsThroughToDisallowAll ()
166+ throws HeaderMutationDisallowedException {
167+ HeaderMutationRulesConfig rules = HeaderMutationRulesConfig .builder ().disallowAll (true )
168+ .allowExpression (Pattern .compile ("^x-allowed-.*" )).build ();
169+ HeaderMutationFilter filter = new HeaderMutationFilter (Optional .of (rules ));
170+ HeaderMutations mutations = HeaderMutations .create (
171+ ImmutableList .of (header ("x-allowed-key" , "value" ), header ("not-allowed-key" , "value" )),
172+ ImmutableList .of ("x-allowed-remove" , "not-allowed-remove" ));
173+
174+ HeaderMutations filtered = filter .filter (mutations );
175+
176+ assertThat (filtered .headersToRemove ()).containsExactly ("x-allowed-remove" );
177+ assertThat (filtered .headers ()).containsExactly (header ("x-allowed-key" , "value" ));
160178 }
161179
180+
162181 @ Test
163182 public void filter_allowExpression_overridesDisallowAll ()
164183 throws HeaderMutationDisallowedException {
0 commit comments