use of org.springframework.security.web.server.csrf.ServerCsrfTokenRepository in project spring-security by spring-projects.
the class ServerHttpSecurityTests method postWhenCustomCsrfTokenRepositoryThenUsed.
@Test
public void postWhenCustomCsrfTokenRepositoryThenUsed() {
ServerCsrfTokenRepository customServerCsrfTokenRepository = mock(ServerCsrfTokenRepository.class);
given(customServerCsrfTokenRepository.loadToken(any(ServerWebExchange.class))).willReturn(Mono.empty());
SecurityWebFilterChain securityFilterChain = this.http.csrf((csrf) -> csrf.csrfTokenRepository(customServerCsrfTokenRepository)).build();
WebFilterChainProxy springSecurityFilterChain = new WebFilterChainProxy(securityFilterChain);
WebTestClient client = WebTestClientBuilder.bindToWebFilters(springSecurityFilterChain).build();
client.post().uri("/").exchange().expectStatus().isForbidden();
verify(customServerCsrfTokenRepository).loadToken(any());
}
Aggregations