Move /application to /actuator
Change the endpoint default path from `/application` to `/actuator`. Fixes gh-10970
This commit is contained in:
@@ -65,15 +65,14 @@ public class CorsSampleActuatorApplicationTests {
|
||||
|
||||
@Test
|
||||
public void endpointShouldReturnUnauthorized() throws Exception {
|
||||
ResponseEntity<?> entity = this.testRestTemplate.getForEntity("/application/env",
|
||||
ResponseEntity<?> entity = this.testRestTemplate.getForEntity("/actuator/env",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preflightRequestToEndpointShouldReturnOk() throws Exception {
|
||||
RequestEntity<?> healthRequest = RequestEntity
|
||||
.options(new URI("/application/env"))
|
||||
RequestEntity<?> healthRequest = RequestEntity.options(new URI("/actuator/env"))
|
||||
.header("Origin", "http://localhost:8080")
|
||||
.header("Access-Control-Request-Method", "GET").build();
|
||||
ResponseEntity<?> exchange = this.testRestTemplate.exchange(healthRequest,
|
||||
@@ -84,7 +83,7 @@ public class CorsSampleActuatorApplicationTests {
|
||||
@Test
|
||||
public void preflightRequestWhenCorsConfigInvalidShouldReturnForbidden()
|
||||
throws Exception {
|
||||
RequestEntity<?> entity = RequestEntity.options(new URI("/application/env"))
|
||||
RequestEntity<?> entity = RequestEntity.options(new URI("/actuator/env"))
|
||||
.header("Origin", "http://localhost:9095")
|
||||
.header("Access-Control-Request-Method", "GET").build();
|
||||
ResponseEntity<byte[]> exchange = this.testRestTemplate.exchange(entity,
|
||||
|
||||
@@ -58,16 +58,16 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
@Test
|
||||
public void testSecureActuator() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/management/application/env",
|
||||
"http://localhost:" + this.managementPort + "/management/actuator/env",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsecureActuator() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.getForEntity("http://localhost:" + this.managementPort
|
||||
+ "/management/application/health", String.class);
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/management/actuator/health",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
}
|
||||
@@ -76,7 +76,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
public void testMissing() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate("admin", "admin")
|
||||
.getForEntity("http://localhost:" + this.managementPort
|
||||
+ "/management/application/missing", String.class);
|
||||
+ "/management/actuator/missing", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
assertThat(entity.getBody()).contains("\"status\":404");
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ public class SampleActuatorCustomSecurityApplicationTests {
|
||||
|
||||
@Test
|
||||
public void insecureActuator() throws Exception {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.getForEntity("/application/health", String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/health",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class SampleActuatorCustomSecurityApplicationTests {
|
||||
@Test
|
||||
public void secureActuator() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/application/env",
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/actuator/env",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SampleActuatorLog4J2ApplicationTests {
|
||||
@Test
|
||||
public void validateLoggersEndpoint() throws Exception {
|
||||
this.mvc.perform(
|
||||
get("/application/loggers/org.apache.coyote.http11.Http11NioProtocol")
|
||||
get("/actuator/loggers/org.apache.coyote.http11.Http11NioProtocol")
|
||||
.header("Authorization", "Basic " + getBasicAuth()))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().string(equalTo("{\"configuredLevel\":\"WARN\","
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SampleActuatorUiApplicationPortTests {
|
||||
public void testMetrics() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/application/metrics",
|
||||
"http://localhost:" + this.managementPort + "/actuator/metrics",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class SampleActuatorUiApplicationPortTests {
|
||||
public void testHealth() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/application/health",
|
||||
"http://localhost:" + this.managementPort + "/actuator/health",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
|
||||
@@ -70,8 +70,8 @@ public class SampleActuatorUiApplicationTests {
|
||||
@Test
|
||||
public void testMetrics() throws Exception {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.getForEntity("/application/metrics", Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/actuator/metrics",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,7 @@ public class ManagementAddressActuatorApplicationTests {
|
||||
public void testHealth() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity("http://localhost:"
|
||||
+ this.managementPort + "/admin/application/health",
|
||||
String.class);
|
||||
+ this.managementPort + "/admin/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/application/metrics",
|
||||
"http://localhost:" + this.managementPort + "/actuator/metrics",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||
public void testHealth() throws Exception {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/application/health",
|
||||
"http://localhost:" + this.managementPort + "/actuator/health",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
|
||||
@@ -94,7 +94,7 @@ public class SampleActuatorApplicationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/metrics", Map.class);
|
||||
.getForEntity("/actuator/metrics", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, Object> body = entity.getBody();
|
||||
assertThat(body).containsKey("names");
|
||||
@@ -107,7 +107,7 @@ public class SampleActuatorApplicationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/env", Map.class);
|
||||
.getForEntity("/actuator/env", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
@@ -118,7 +118,7 @@ public class SampleActuatorApplicationTests {
|
||||
public void testHealth() throws Exception {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/health", String.class);
|
||||
.getForEntity("/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
assertThat(entity.getBody()).doesNotContain("\"hello\":\"1\"");
|
||||
@@ -128,7 +128,7 @@ public class SampleActuatorApplicationTests {
|
||||
public void testInfo() throws Exception {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/info", String.class);
|
||||
.getForEntity("/actuator/info", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody())
|
||||
.contains("\"artifact\":\"spring-boot-sample-actuator\"");
|
||||
@@ -169,7 +169,7 @@ public class SampleActuatorApplicationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/trace", Map.class);
|
||||
.getForEntity("/actuator/trace", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, Object> body = entity.getBody();
|
||||
Map<String, Object> trace = ((List<Map<String, Object>>) body.get("traces"))
|
||||
@@ -183,11 +183,11 @@ public class SampleActuatorApplicationTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void traceWithParameterMap() throws Exception {
|
||||
this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/health?param1=value1", String.class);
|
||||
.getForEntity("/actuator/health?param1=value1", String.class);
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/trace", Map.class);
|
||||
.getForEntity("/actuator/trace", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, Object> body = entity.getBody();
|
||||
Map<String, Object> trace = ((List<Map<String, Object>>) body.get("traces"))
|
||||
@@ -215,7 +215,7 @@ public class SampleActuatorApplicationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/beans", Map.class);
|
||||
.getForEntity("/actuator/beans", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).containsOnlyKeys("beans", "parent", "contextId");
|
||||
assertThat(((String) entity.getBody().get("contextId")))
|
||||
@@ -228,7 +228,7 @@ public class SampleActuatorApplicationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/application/configprops", Map.class);
|
||||
.getForEntity("/actuator/configprops", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, Object> body = entity.getBody();
|
||||
assertThat((Map<String, Object>) body.get("beans"))
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ServletPathSampleActuatorApplicationTests {
|
||||
public void testHealth() throws Exception {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/spring/application/health", String.class);
|
||||
.getForEntity("/spring/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class ShutdownSampleActuatorApplicationTests {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.postForEntity("/application/shutdown", null, Map.class);
|
||||
.postForEntity("/actuator/shutdown", null, Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This sample demonstrates the flyway auto-configuration support.
|
||||
|
||||
You can look at `http://localhost:8080/application/flyway` to review the list of scripts.
|
||||
You can look at `http://localhost:8080/actuator/flyway` to review the list of scripts.
|
||||
|
||||
This sample also enables the H2 console (at `http://localhost:8080/h2-console`)
|
||||
so that you can review the state of the database (the default jdbc url is
|
||||
|
||||
@@ -60,8 +60,8 @@ public class SampleJerseyApplicationTests {
|
||||
|
||||
@Test
|
||||
public void actuatorStatus() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.getForEntity("/application/health", String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/health",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
This sample demonstrates the liquibase auto-configuration support.
|
||||
|
||||
You can look at `http://localhost:8080/application/liquibase` to review the list of
|
||||
You can look at `http://localhost:8080/actuator/liquibase` to review the list of
|
||||
scripts.
|
||||
|
||||
This sample also enables the H2 console (at `http://localhost:8080/h2-console`)
|
||||
|
||||
@@ -48,7 +48,7 @@ public class SampleSecureWebFluxApplicationTests {
|
||||
|
||||
@Test
|
||||
public void actuatorsSecureByDefault() {
|
||||
this.webClient.get().uri("/application/health").accept(MediaType.APPLICATION_JSON)
|
||||
this.webClient.get().uri("/actuator/health").accept(MediaType.APPLICATION_JSON)
|
||||
.exchange().expectStatus().isUnauthorized();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SampleSecureWebFluxApplicationTests {
|
||||
|
||||
@Test
|
||||
public void actuatorsAccessibleOnLogin() {
|
||||
this.webClient.get().uri("/application/health").accept(MediaType.APPLICATION_JSON)
|
||||
this.webClient.get().uri("/actuator/health").accept(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "basic " + getBasicAuth()).exchange()
|
||||
.expectBody(String.class).isEqualTo("{\"status\":\"UP\"}");
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class SampleMethodSecurityApplicationTests {
|
||||
public void testManagementProtected() throws Exception {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
||||
ResponseEntity<String> entity = this.restTemplate.exchange("/application/beans",
|
||||
ResponseEntity<String> entity = this.restTemplate.exchange("/actuator/beans",
|
||||
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class SampleMethodSecurityApplicationTests {
|
||||
this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor);
|
||||
try {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.getForEntity("/application/beans", String.class);
|
||||
.getForEntity("/actuator/beans", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SampleWebFluxApplicationTests {
|
||||
|
||||
@Test
|
||||
public void testActuatorStatus() {
|
||||
this.webClient.get().uri("/application/health").accept(MediaType.APPLICATION_JSON)
|
||||
this.webClient.get().uri("/actuator/health").accept(MediaType.APPLICATION_JSON)
|
||||
.exchange().expectStatus().isOk().expectBody()
|
||||
.json("{\"status\":\"UP\"}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user