Polish
This commit is contained in:
@@ -86,8 +86,7 @@ public class SampleActuatorCustomSecurityApplicationTests {
|
||||
ResponseEntity<Object> entity = restTemplate().getForEntity("/actuator",
|
||||
Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
entity = adminRestTemplate().getForEntity("/actuator",
|
||||
Object.class);
|
||||
entity = adminRestTemplate().getForEntity("/actuator", Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -137,8 +136,8 @@ public class SampleActuatorCustomSecurityApplicationTests {
|
||||
|
||||
@Test
|
||||
public void actuatorExcludedFromEndpointRequestMatcher() {
|
||||
ResponseEntity<Object> entity = userRestTemplate().getForEntity("/actuator/mappings",
|
||||
Object.class);
|
||||
ResponseEntity<Object> entity = userRestTemplate()
|
||||
.getForEntity("/actuator/mappings", Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,7 @@ public class SampleSecureWebFluxCustomSecurityTests {
|
||||
@Test
|
||||
public void actuatorLinksIsSecure() {
|
||||
this.webClient.get().uri("/actuator").accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus().isUnauthorized();
|
||||
.exchange().expectStatus().isUnauthorized();
|
||||
this.webClient.get().uri("/actuator").accept(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "basic " + getBasicAuthForAdmin()).exchange()
|
||||
.expectStatus().isOk();
|
||||
@@ -118,7 +117,9 @@ public class SampleSecureWebFluxCustomSecurityTests {
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
http.authorizeExchange().matchers(EndpointRequest.to("health", "info"))
|
||||
.permitAll().matchers(EndpointRequest.toAnyEndpoint().excluding(MappingsEndpoint.class))
|
||||
.permitAll()
|
||||
.matchers(EndpointRequest.toAnyEndpoint()
|
||||
.excluding(MappingsEndpoint.class))
|
||||
.hasRole("ACTUATOR")
|
||||
.matchers(PathRequest.toStaticResources().atCommonLocations())
|
||||
.permitAll().pathMatchers("/login").permitAll().anyExchange()
|
||||
|
||||
Reference in New Issue
Block a user