Add ClientRequest.attribute(String)

This commit adds the attribute(String) convenience method to the
ClientRequest class. It also adapts the Basic Authentication filter to
use it.
This commit is contained in:
Arjen Poutsma
2017-07-11 15:41:24 +02:00
parent e11bb17aa6
commit 2ea693bd83
3 changed files with 84 additions and 35 deletions

View File

@@ -117,4 +117,20 @@ public class ExchangeFilterFunctionsTests {
assertEquals(response, result);
}
@Test
public void basicAuthenticationAbsentAttributes() throws Exception {
ClientRequest request = ClientRequest.method(GET, URI.create("http://example.com")).build();
ClientResponse response = mock(ClientResponse.class);
ExchangeFunction exchange = r -> {
assertFalse(r.headers().containsKey(HttpHeaders.AUTHORIZATION));
return Mono.just(response);
};
ExchangeFilterFunction auth = ExchangeFilterFunctions.basicAuthentication();
assertFalse(request.headers().containsKey(HttpHeaders.AUTHORIZATION));
ClientResponse result = auth.filter(request, exchange).block();
assertEquals(response, result);
}
}