use of org.springframework.web.server.handler.FilteringWebHandler in project spring-security by spring-projects.
the class OAuth2AuthorizationRequestRedirectWebFilterTests method filterWhenExceptionThenSaveRequestSessionAttribute.
@Test
public void filterWhenExceptionThenSaveRequestSessionAttribute() {
given(this.clientRepository.findByRegistrationId(this.registration.getRegistrationId())).willReturn(Mono.just(this.registration));
given(this.authzRequestRepository.saveAuthorizationRequest(any(), any())).willReturn(Mono.empty());
this.filter.setRequestCache(this.requestCache);
given(this.requestCache.saveRequest(any())).willReturn(Mono.empty());
FilteringWebHandler webHandler = new FilteringWebHandler((e) -> Mono.error(new ClientAuthorizationRequiredException(this.registration.getRegistrationId())), Arrays.asList(this.filter));
// @formatter:off
this.client = WebTestClient.bindToWebHandler(webHandler).build();
this.client.get().uri("https://example.com/foo").exchange().expectStatus().is3xxRedirection().returnResult(String.class);
// @formatter:on
verify(this.requestCache).saveRequest(any());
}
use of org.springframework.web.server.handler.FilteringWebHandler in project spring-security by spring-projects.
the class ExchangeMatcherRedirectWebFilterTests method filterWhenRequestMatchThenRedirectToSpecifiedUrl.
@Test
public void filterWhenRequestMatchThenRedirectToSpecifiedUrl() {
ExchangeMatcherRedirectWebFilter filter = new ExchangeMatcherRedirectWebFilter(new PathPatternParserServerWebExchangeMatcher("/context"), "/test");
FilteringWebHandler handler = new FilteringWebHandler((e) -> e.getResponse().setComplete(), Collections.singletonList(filter));
WebTestClient client = WebTestClient.bindToWebHandler(handler).build();
client.get().uri("/context").exchange().expectStatus().isFound().expectHeader().valueEquals(HttpHeaders.LOCATION, "/test");
}
use of org.springframework.web.server.handler.FilteringWebHandler in project spring-security by spring-projects.
the class ExchangeMatcherRedirectWebFilterTests method filterWhenRequestNotMatchThenNextFilter.
@Test
public void filterWhenRequestNotMatchThenNextFilter() {
ExchangeMatcherRedirectWebFilter filter = new ExchangeMatcherRedirectWebFilter(new PathPatternParserServerWebExchangeMatcher("/context"), "/test");
FilteringWebHandler handler = new FilteringWebHandler((e) -> e.getResponse().setComplete(), Collections.singletonList(filter));
WebTestClient client = WebTestClient.bindToWebHandler(handler).build();
client.get().uri("/test").exchange().expectStatus().isOk();
}
Aggregations