List of usage examples for org.springframework.security.web.server.context WebSessionServerSecurityContextRepository WebSessionServerSecurityContextRepository
WebSessionServerSecurityContextRepository
From source file:org.springframework.security.config.web.server.ServerHttpSecurityTests.java
@Test public void basic() { given(this.authenticationManager.authenticate(any())) .willReturn(Mono.just(new TestingAuthenticationToken("rob", "rob", "ROLE_USER", "ROLE_ADMIN"))); this.http.securityContextRepository(new WebSessionServerSecurityContextRepository()); this.http.httpBasic(); this.http.authenticationManager(this.authenticationManager); ServerHttpSecurity.AuthorizeExchangeBuilder authorize = this.http.authorizeExchange(); authorize.anyExchange().authenticated(); WebTestClient client = buildClient(); EntityExchangeResult<String> result = client.mutate().filter(basicAuthentication("rob", "rob")).build() .get().uri("/").exchange().expectStatus().isOk().expectHeader() .valueMatches(HttpHeaders.CACHE_CONTROL, ".+").expectBody(String.class) .consumeWith(b -> assertThat(b.getResponseBody()).isEqualTo("ok")).returnResult(); assertThat(result.getResponseCookies().getFirst("SESSION")).isNotNull(); }