Move all actuators under /application

Context path can be configured via `management.context-path`.

Closes gh-6886
This commit is contained in:
Madhura Bhave
2016-10-13 10:32:38 -07:00
parent 92468d4ffc
commit bcd79dd992
47 changed files with 242 additions and 186 deletions

View File

@@ -63,7 +63,7 @@ public class SampleActuatorLog4J2ApplicationTests {
@Test
public void validateLoggersEndpoint() throws Exception {
this.mvc.perform(get("/loggers/org.apache.coyote.http11.Http11NioProtocol"))
this.mvc.perform(get("/application/loggers/org.apache.coyote.http11.Http11NioProtocol"))
.andExpect(status().isOk())
.andExpect(content().string(equalTo("{\"configuredLevel\":\"WARN\","
+ "\"effectiveLevel\":\"WARN\"}")));

View File

@@ -61,14 +61,14 @@ public class SampleActuatorUiApplicationPortTests {
public void testMetrics() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/metrics", Map.class);
"http://localhost:" + this.managementPort + "/application//metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/health", String.class);
"http://localhost:" + this.managementPort + "/application//health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
}

View File

@@ -71,7 +71,7 @@ public class SampleActuatorUiApplicationTests {
@Test
public void testMetrics() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics",
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/application/metrics",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}

View File

@@ -69,7 +69,7 @@ public class InsecureManagementSampleActuatorApplicationTests {
// ignore;
}
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics",
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/application/metrics",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")

View File

@@ -71,14 +71,14 @@ public class ManagementPortSampleActuatorApplicationTests {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/metrics", Map.class);
"http://localhost:" + this.managementPort + "/application/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/health", String.class);
"http://localhost:" + this.managementPort + "/application/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}

View File

@@ -46,7 +46,7 @@ public class NonSensitiveHealthTests {
@Test
public void testSecureHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/health",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).doesNotContain("\"hello\":1");

View File

@@ -98,7 +98,7 @@ public class SampleActuatorApplicationTests {
testHome(); // makes sure some requests have been made
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/metrics", Map.class);
.withBasicAuth("user", getPassword()).getForEntity("/application/metrics", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -109,7 +109,7 @@ public class SampleActuatorApplicationTests {
public void testEnv() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/env", Map.class);
.withBasicAuth("user", getPassword()).getForEntity("/application/env", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();
@@ -118,7 +118,7 @@ public class SampleActuatorApplicationTests {
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/health",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
@@ -129,14 +129,14 @@ public class SampleActuatorApplicationTests {
public void testSecureHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate
.withBasicAuth("user", getPassword())
.getForEntity("/health", String.class);
.getForEntity("/application/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"hello\":1");
}
@Test
public void testInfo() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/info",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/info",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody())
@@ -176,7 +176,7 @@ public class SampleActuatorApplicationTests {
this.restTemplate.getForEntity("/health", String.class);
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/trace", List.class);
.withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
List<Map<String, Object>> list = entity.getBody();
@@ -189,10 +189,10 @@ public class SampleActuatorApplicationTests {
@Test
public void traceWithParameterMap() throws Exception {
this.restTemplate.getForEntity("/health?param1=value1", String.class);
this.restTemplate.getForEntity("/application/health?param1=value1", String.class);
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/trace", List.class);
.withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
List<Map<String, Object>> list = entity.getBody();
@@ -219,7 +219,7 @@ public class SampleActuatorApplicationTests {
public void testBeans() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<List> entity = this.restTemplate
.withBasicAuth("user", getPassword()).getForEntity("/beans", List.class);
.withBasicAuth("user", getPassword()).getForEntity("/application/beans", List.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).hasSize(1);
Map<String, Object> body = (Map<String, Object>) entity.getBody().get(0);
@@ -231,7 +231,7 @@ public class SampleActuatorApplicationTests {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword())
.getForEntity("/configprops", Map.class);
.getForEntity("/application/configprops", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -62,7 +62,7 @@ public class ServletPathInsecureSampleActuatorApplicationTests {
@Test
public void testMetricsIsSecure() throws Exception {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/metrics",
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring//application/metrics",
Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}

View File

@@ -60,7 +60,7 @@ public class ServletPathSampleActuatorApplicationTests {
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/spring/health",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/spring//application/health",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");

View File

@@ -65,7 +65,7 @@ public class ShutdownSampleActuatorApplicationTests {
@SuppressWarnings("rawtypes")
ResponseEntity<Map> entity = this.restTemplate
.withBasicAuth("user", getPassword())
.postForEntity("/shutdown", null, Map.class);
.postForEntity("/application/shutdown", null, Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked")
Map<String, Object> body = entity.getBody();

View File

@@ -50,22 +50,22 @@ public class SampleHypermediaGsonApplicationTests {
@Test
public void health() throws Exception {
this.mockMvc.perform(get("/health").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application/health").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$.links[0].href").value("http://localhost/health"))
.andExpect(jsonPath("$.links[0].href").value("http://localhost/application/health"))
.andExpect(jsonPath("$.content.status").exists());
}
@Test
public void trace() throws Exception {
this.mockMvc.perform(get("/trace").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application/trace").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.links").doesNotExist())
.andExpect(jsonPath("$").isArray());
}
@Test
public void envValue() throws Exception {
this.mockMvc.perform(get("/env/user.home").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application/env/user.home").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$._links").doesNotExist());
}

View File

@@ -38,16 +38,16 @@ public class SampleHypermediaUiSecureApplicationTests {
@Test
public void links() {
String response = this.restTemplate.getForObject("/actuator", String.class);
String response = this.restTemplate.getForObject("/application", String.class);
assertThat(response).contains("\"_links\":");
}
@Test
public void testInsecureNestedPath() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/env",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/env",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
ResponseEntity<String> user = this.restTemplate.getForEntity("/env/foo",
ResponseEntity<String> user = this.restTemplate.getForEntity("/application/env/foo",
String.class);
assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(user.getBody()).contains("{\"foo\":");
@@ -55,7 +55,7 @@ public class SampleHypermediaUiSecureApplicationTests {
@Test
public void testSecurePath() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/metrics",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/metrics",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}

View File

@@ -50,7 +50,7 @@ public class SampleHypermediaUiApplicationTests {
@Test
public void links() {
String response = this.restTemplate.getForObject("/actuator", String.class);
String response = this.restTemplate.getForObject("/application", String.class);
assertThat(response).contains("\"_links\":");
}
@@ -58,7 +58,7 @@ public class SampleHypermediaUiApplicationTests {
public void linksWithJson() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> response = this.restTemplate.exchange("/actuator",
ResponseEntity<String> response = this.restTemplate.exchange("/application",
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
assertThat(response.getBody()).contains("\"_links\":");
}

View File

@@ -51,7 +51,7 @@ public class SampleHypermediaApplicationHomePageTests {
public void linksWithJson() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> response = this.restTemplate.exchange("/actuator",
ResponseEntity<String> response = this.restTemplate.exchange("/application",
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
assertThat(response.getBody()).contains("\"_links\":");
}
@@ -60,7 +60,7 @@ public class SampleHypermediaApplicationHomePageTests {
public void halWithHtml() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> response = this.restTemplate.exchange("/actuator/",
ResponseEntity<String> response = this.restTemplate.exchange("/application/",
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
assertThat(response.getBody()).contains("HAL Browser");
}

View File

@@ -70,19 +70,19 @@ public class SampleSecureOAuth2ActuatorApplicationTests {
@Test
public void healthAvailable() throws Exception {
this.mvc.perform(get("/health")).andExpect(status().isOk()).andDo(print());
this.mvc.perform(get("/application/health")).andExpect(status().isOk()).andDo(print());
}
@Test
public void envSecuredWithBasic() throws Exception {
this.mvc.perform(get("/env")).andExpect(status().isUnauthorized())
this.mvc.perform(get("/application/env")).andExpect(status().isUnauthorized())
.andExpect(header().string("WWW-Authenticate", containsString("Basic")))
.andDo(print());
}
@Test
public void envWithPassword() throws Exception {
this.mvc.perform(get("/env").header("Authorization",
this.mvc.perform(get("/application/env").header("Authorization",
"Basic " + Base64Utils.encodeToString("user:password".getBytes())))
.andExpect(status().isOk()).andDo(print());
}

View File

@@ -105,7 +105,7 @@ public class SampleMethodSecurityApplicationTests {
@Test
public void testManagementProtected() throws Exception {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/beans",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/beans",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@@ -116,7 +116,7 @@ public class SampleMethodSecurityApplicationTests {
"admin", "admin");
this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor);
try {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/beans",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/beans",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
}
@@ -132,7 +132,7 @@ public class SampleMethodSecurityApplicationTests {
"user", "user");
this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor);
try {
ResponseEntity<String> entity = this.restTemplate.getForEntity("/beans",
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/beans",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
}