use of org.springframework.mock.web.server.MockServerWebExchange in project spring-security by spring-projects.
the class WebSessionServerRequestCacheTests method saveRequestGetRequestWhenFaviconThenNotFound.
@Test
public void saveRequestGetRequestWhenFaviconThenNotFound() {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/favicon.png").accept(MediaType.TEXT_HTML));
this.cache.saveRequest(exchange).block();
URI saved = this.cache.getRedirectUri(exchange).block();
assertThat(saved).isNull();
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-security by spring-projects.
the class WebSessionServerRequestCacheTests method saveRequestGetRequestWithQueryParamsWhenGetThenFound.
@Test
public void saveRequestGetRequestWithQueryParamsWhenGetThenFound() {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/secured/").queryParam("key", "value").accept(MediaType.TEXT_HTML));
this.cache.saveRequest(exchange).block();
URI saved = this.cache.getRedirectUri(exchange).block();
assertThat(saved).isEqualTo(exchange.getRequest().getURI());
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-security by spring-projects.
the class WebSessionServerRequestCacheTests method saveRequestRemoveRequestWhenThenFound.
@Test
public void saveRequestRemoveRequestWhenThenFound() {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/secured/").accept(MediaType.TEXT_HTML));
this.cache.saveRequest(exchange).block();
ServerHttpRequest saved = this.cache.removeMatchingRequest(exchange).block();
assertThat(saved.getURI()).isEqualTo(exchange.getRequest().getURI());
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-security by spring-projects.
the class WebSessionServerRequestCacheTests method removeRequestGetRequestWhenDefaultThenNotFound.
@Test
public void removeRequestGetRequestWhenDefaultThenNotFound() {
MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/secured/"));
this.cache.saveRequest(exchange).block();
this.cache.removeMatchingRequest(exchange).block();
assertThat(this.cache.getRedirectUri(exchange).block()).isNull();
}
use of org.springframework.mock.web.server.MockServerWebExchange in project spring-boot by spring-projects.
the class ReactiveCloudFoundrySecurityInterceptorTests method preHandleWhenAccessIsNotAllowedShouldReturnAccessDenied.
@Test
void preHandleWhenAccessIsNotAllowedShouldReturnAccessDenied() {
given(this.securityService.getAccessLevel(mockAccessToken(), "my-app-id")).willReturn(Mono.just(AccessLevel.RESTRICTED));
given(this.tokenValidator.validate(any())).willReturn(Mono.empty());
MockServerWebExchange request = MockServerWebExchange.from(MockServerHttpRequest.get("/a").header(HttpHeaders.AUTHORIZATION, "bearer " + mockAccessToken()).build());
StepVerifier.create(this.interceptor.preHandle(request, "/a")).consumeNextWith((response) -> assertThat(response.getStatus()).isEqualTo(Reason.ACCESS_DENIED.getStatus())).verifyComplete();
}
Aggregations