use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-security by spring-projects.
the class OidcClientInitiatedServerLogoutSuccessHandlerTests method logoutWhenUsingPostLogoutRedirectUriTemplateThenBuildsItForRedirect.
@Test
public void logoutWhenUsingPostLogoutRedirectUriTemplateThenBuildsItForRedirect() throws IOException, ServletException {
OAuth2AuthenticationToken token = new OAuth2AuthenticationToken(TestOidcUsers.create(), AuthorityUtils.NO_AUTHORITIES, this.registration.getRegistrationId());
given(this.exchange.getPrincipal()).willReturn(Mono.just(token));
MockServerHttpRequest request = MockServerHttpRequest.get("https://rp.example.org/").build();
given(this.exchange.getRequest()).willReturn(request);
WebFilterExchange f = new WebFilterExchange(this.exchange, this.chain);
this.handler.setPostLogoutRedirectUri("{baseUrl}");
this.handler.onLogoutSuccess(f, token).block();
assertThat(redirectedUrl(this.exchange)).isEqualTo("https://endpoint?" + "id_token_hint=id-token&" + "post_logout_redirect_uri=https://rp.example.org");
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-boot by spring-projects.
the class DefaultErrorAttributesTests method getError.
@Test
void getError() {
Error error = new OutOfMemoryError("Test error");
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
ServerRequest serverRequest = buildServerRequest(request, error);
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(serverRequest, ErrorAttributeOptions.of(Include.MESSAGE));
assertThat(this.errorAttributes.getError(serverRequest)).isSameAs(error);
assertThat(attributes.get("exception")).isNull();
assertThat(attributes.get("message")).isEqualTo("Test error");
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-boot by spring-projects.
the class DefaultErrorAttributesTests method includeTrace.
@Test
void includeTrace() {
RuntimeException ex = new RuntimeException("Test");
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(buildServerRequest(request, ex), ErrorAttributeOptions.of(Include.STACK_TRACE));
assertThat(attributes.get("trace").toString()).startsWith("java.lang");
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-boot by spring-projects.
the class DefaultErrorAttributesTests method includeLogPrefix.
@Test
void includeLogPrefix() {
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
ServerRequest serverRequest = buildServerRequest(request, NOT_FOUND);
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(serverRequest, ErrorAttributeOptions.defaults());
assertThat(attributes.get("requestId")).isEqualTo(serverRequest.exchange().getRequest().getId());
}
use of org.springframework.mock.http.server.reactive.MockServerHttpRequest in project spring-boot by spring-projects.
the class DefaultErrorAttributesTests method includePath.
@Test
void includePath() {
MockServerHttpRequest request = MockServerHttpRequest.get("/test").build();
Map<String, Object> attributes = this.errorAttributes.getErrorAttributes(buildServerRequest(request, NOT_FOUND), ErrorAttributeOptions.defaults());
assertThat(attributes.get("path")).isEqualTo("/test");
}
Aggregations