Remove ExchangeFilterFunctions

Issue: gh-5612
This commit is contained in:
Rob Winch
2018-07-30 14:45:14 -05:00
parent 262c1a77c6
commit afa2d9cbc7
11 changed files with 55 additions and 103 deletions

View File

@@ -68,8 +68,6 @@ import java.security.Principal;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.security.test.web.reactive.server.SecurityMockServerConfigurers.csrf;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
/**
* @author Rob Winch
@@ -122,11 +120,10 @@ public class EnableWebFluxSecurityTests {
WebTestClient client = WebTestClientBuilder
.bindToWebFilters(this.springSecurityFilterChain)
.filter(basicAuthentication())
.build();
FluxExchangeResult<String> result = client.get()
.attributes(basicAuthenticationCredentials("user", "password"))
.headers(headers -> headers.setBasicAuth("user", "password"))
.exchange()
.expectStatus()
.isOk()
@@ -171,13 +168,12 @@ public class EnableWebFluxSecurityTests {
.flatMap( principal -> exchange.getResponse()
.writeWith(Mono.just(toDataBuffer(principal.getName()))))
)
.filter(basicAuthentication())
.build();
client
.get()
.uri("/")
.attributes(basicAuthenticationCredentials("user", "password"))
.headers(headers -> headers.setBasicAuth("user", "password"))
.exchange()
.expectStatus().isOk()
.expectBody(String.class).consumeWith( result -> assertThat(result.getResponseBody()).isEqualTo("user"));
@@ -208,13 +204,12 @@ public class EnableWebFluxSecurityTests {
.flatMap( principal -> exchange.getResponse()
.writeWith(Mono.just(toDataBuffer(principal.getName()))))
)
.filter(basicAuthentication())
.build();
client
.get()
.uri("/")
.attributes(basicAuthenticationCredentials("user", "password"))
.headers(headers -> headers.setBasicAuth("user", "password"))
.exchange()
.expectStatus().isOk()
.expectBody(String.class).consumeWith( result -> assertThat(result.getResponseBody()).isEqualTo("user"));

View File

@@ -25,8 +25,6 @@ import org.springframework.security.web.server.authentication.RedirectServerAuth
import org.springframework.security.web.server.authorization.HttpStatusServerAccessDeniedHandler;
import org.springframework.security.web.server.authorization.ServerAccessDeniedHandler;
import org.springframework.test.web.reactive.server.WebTestClient;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.Credentials.basicAuthenticationCredentials;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
/**
* @author Denys Ivano
@@ -96,13 +94,12 @@ public class ExceptionHandlingSpecTests {
WebTestClient client = WebTestClientBuilder
.bindToWebFilters(securityWebFilter)
.filter(basicAuthentication())
.build();
client
.get()
.uri("/admin")
.attributes(basicAuthenticationCredentials("user", "password"))
.headers(headers -> headers.setBasicAuth("user", "password"))
.exchange()
.expectStatus().isForbidden();
}
@@ -122,13 +119,12 @@ public class ExceptionHandlingSpecTests {
WebTestClient client = WebTestClientBuilder
.bindToWebFilters(securityWebFilter)
.filter(basicAuthentication())
.build();
client
.get()
.uri("/admin")
.attributes(basicAuthenticationCredentials("user", "password"))
.headers(headers -> headers.setBasicAuth("user", "password"))
.exchange()
.expectStatus().isBadRequest();
}

View File

@@ -40,7 +40,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import static org.springframework.web.reactive.function.client.ExchangeFilterFunctions.basicAuthentication;
/**
* @author Rob Winch
@@ -92,12 +91,9 @@ public class ServerHttpSecurityTests {
WebTestClient client = buildClient();
EntityExchangeResult<String> result = client
.mutate()
.filter(basicAuthentication("rob", "rob"))
.build()
.get()
EntityExchangeResult<String> result = client.get()
.uri("/")
.headers(headers -> headers.setBasicAuth("rob", "rob"))
.exchange()
.expectStatus().isOk()
.expectHeader().valueMatches(HttpHeaders.CACHE_CONTROL, ".+")