use of org.springframework.security.web.server.WebFilterExchange in project spring-security by spring-projects.
the class HttpStatusReturningServerLogoutSuccessHandlerTests method customHttpStatusBeingReturned.
@Test
public void customHttpStatusBeingReturned() {
WebFilterExchange filterExchange = buildFilterExchange();
new HttpStatusReturningServerLogoutSuccessHandler(HttpStatus.NO_CONTENT).onLogoutSuccess(filterExchange, mock(Authentication.class)).block();
assertThat(filterExchange.getExchange().getResponse().getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
}
use of org.springframework.security.web.server.WebFilterExchange in project spring-security by spring-projects.
the class HeaderWriterServerLogoutHandlerTests method logoutWhenInvokedThenWritesResponseHeaders.
@Test
public void logoutWhenInvokedThenWritesResponseHeaders() {
ServerHttpHeadersWriter headersWriter = mock(ServerHttpHeadersWriter.class);
HeaderWriterServerLogoutHandler handler = new HeaderWriterServerLogoutHandler(headersWriter);
ServerWebExchange serverWebExchange = mock(ServerWebExchange.class);
WebFilterExchange filterExchange = mock(WebFilterExchange.class);
given(filterExchange.getExchange()).willReturn(serverWebExchange);
Authentication authentication = mock(Authentication.class);
handler.logout(filterExchange, authentication);
verify(headersWriter).writeHttpHeaders(serverWebExchange);
}
use of org.springframework.security.web.server.WebFilterExchange in project spring-security by spring-projects.
the class CsrfServerLogoutHandlerTests method setup.
@BeforeEach
public void setup() {
this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/").build());
this.filterExchange = new WebFilterExchange(this.exchange, this.filterChain);
this.handler = new CsrfServerLogoutHandler(this.csrfTokenRepository);
}
use of org.springframework.security.web.server.WebFilterExchange in project spring-security by spring-projects.
the class HttpStatusReturningServerLogoutSuccessHandlerTests method buildFilterExchange.
private static WebFilterExchange buildFilterExchange() {
MockServerHttpRequest request = MockServerHttpRequest.get("/").build();
MockServerWebExchange exchange = MockServerWebExchange.from(request);
return new WebFilterExchange(exchange, mock(WebFilterChain.class));
}
use of org.springframework.security.web.server.WebFilterExchange in project spring-security by spring-projects.
the class OidcClientInitiatedServerLogoutSuccessHandlerTests method logoutWhenNotOidcUserThenDefaults.
@Test
public void logoutWhenNotOidcUserThenDefaults() {
OAuth2AuthenticationToken token = new OAuth2AuthenticationToken(TestOAuth2Users.create(), AuthorityUtils.NO_AUTHORITIES, this.registration.getRegistrationId());
given(this.exchange.getPrincipal()).willReturn(Mono.just(token));
WebFilterExchange f = new WebFilterExchange(this.exchange, this.chain);
this.handler.setLogoutSuccessUrl(URI.create("https://default"));
this.handler.onLogoutSuccess(f, token).block();
assertThat(redirectedUrl(this.exchange)).isEqualTo("https://default");
}
Aggregations