Allow actuator endpoints to be used with mvcMatchers
This commit changes AbstractWebMvcEndpointHandlerMapping to be a MatchableHandlerMapping. Additionally, EndpointRequest, now delegates to MvcRequestMatcher for Spring MVC applications. For all other applications, AntPathRequestMatcher is used as a delegate. Closes gh-13962
This commit is contained in:
@@ -141,6 +141,16 @@ public class SampleActuatorCustomSecurityApplicationTests {
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mvcMatchersCanBeUsedToSecureActuators() {
|
||||
ResponseEntity<Object> entity = beansRestTemplate()
|
||||
.getForEntity("/actuator/beans", Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
entity = beansRestTemplate()
|
||||
.getForEntity("/actuator/beans/", Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
|
||||
private TestRestTemplate restTemplate() {
|
||||
return configure(new TestRestTemplate());
|
||||
}
|
||||
@@ -153,6 +163,10 @@ public class SampleActuatorCustomSecurityApplicationTests {
|
||||
return configure(new TestRestTemplate("user", "password"));
|
||||
}
|
||||
|
||||
private TestRestTemplate beansRestTemplate() {
|
||||
return configure(new TestRestTemplate("beans", "beans"));
|
||||
}
|
||||
|
||||
private TestRestTemplate configure(TestRestTemplate restTemplate) {
|
||||
restTemplate
|
||||
.setUriTemplateHandler(new LocalHostUriTemplateHandler(this.environment));
|
||||
|
||||
Reference in New Issue
Block a user