use of org.springframework.test.web.reactive.server.WebTestClient in project spring-boot by spring-projects.
the class MvcEndpointRequestIntegrationTests method toAnyEndpointShouldMatchServletEndpoint.
@Test
void toAnyEndpointShouldMatchServletEndpoint() {
getContextRunner().withPropertyValues("spring.security.user.password=password", "management.endpoints.web.exposure.include=se1").run((context) -> {
WebTestClient webTestClient = getWebTestClient(context);
webTestClient.get().uri("/actuator/se1").exchange().expectStatus().isUnauthorized();
webTestClient.get().uri("/actuator/se1").header("Authorization", getBasicAuth()).exchange().expectStatus().isOk();
webTestClient.get().uri("/actuator/se1/list").exchange().expectStatus().isUnauthorized();
webTestClient.get().uri("/actuator/se1/list").header("Authorization", getBasicAuth()).exchange().expectStatus().isOk();
});
}
use of org.springframework.test.web.reactive.server.WebTestClient in project spring-boot by spring-projects.
the class DefaultErrorWebExceptionHandlerIntegrationTests method neverIncludeStackTrace.
@Test
void neverIncludeStackTrace() {
this.contextRunner.withPropertyValues("server.error.include-exception=true", "server.error.include-stacktrace=never").run((context) -> {
WebTestClient client = getWebClient(context);
client.get().uri("/?trace=true").exchange().expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR).expectBody().jsonPath("status").isEqualTo("500").jsonPath("error").isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()).jsonPath("exception").isEqualTo(IllegalStateException.class.getName()).jsonPath("trace").doesNotExist().jsonPath("requestId").isEqualTo(this.logIdFilter.getLogId());
});
}
use of org.springframework.test.web.reactive.server.WebTestClient in project spring-boot by spring-projects.
the class DefaultErrorWebExceptionHandlerIntegrationTests method defaultErrorAttributesSubclassUsingDelegation.
@Test
void defaultErrorAttributesSubclassUsingDelegation() {
this.contextRunner.withUserConfiguration(CustomErrorAttributesWithDelegation.class).run((context) -> {
WebTestClient client = getWebClient(context);
client.get().uri("/badRequest").exchange().expectStatus().isBadRequest().expectBody().jsonPath("status").isEqualTo("400").jsonPath("error").isEqualTo("custom error").jsonPath("newAttribute").isEqualTo("value").jsonPath("path").doesNotExist();
});
}
use of org.springframework.test.web.reactive.server.WebTestClient in project spring-boot by spring-projects.
the class DefaultErrorWebExceptionHandlerIntegrationTests method responseCommitted.
@Test
void responseCommitted() {
this.contextRunner.run((context) -> {
WebTestClient client = getWebClient(context);
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> client.get().uri("/commit").exchange().expectStatus()).withCauseInstanceOf(FailureAfterResponseCompletedException.class).withMessageContaining("Error occurred after response was completed");
});
}
use of org.springframework.test.web.reactive.server.WebTestClient in project spring-boot by spring-projects.
the class DefaultErrorWebExceptionHandlerIntegrationTests method seriesStatusTemplateErrorPage.
@Test
void seriesStatusTemplateErrorPage() {
this.contextRunner.withPropertyValues("server.error.whitelabel.enabled=false", "spring.mustache.prefix=" + getErrorTemplatesLocation()).run((context) -> {
WebTestClient client = getWebClient(context);
String body = client.get().uri("/badRequest").accept(MediaType.TEXT_HTML).exchange().expectStatus().isBadRequest().expectBody(String.class).returnResult().getResponseBody();
assertThat(body).contains("4xx page");
});
}
Aggregations