Skip to content

Move all actuator endpoints under /application #7603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void clearLog() {

@Test
public void logfile() throws Exception {
this.mockMvc.perform(get("/logfile").accept(MediaType.TEXT_PLAIN))
this.mockMvc.perform(get("/application/logfile").accept(MediaType.TEXT_PLAIN))
.andExpect(status().isOk()).andDo(document("logfile"));
}

Expand All @@ -104,7 +104,7 @@ public void partialLogfile() throws Exception {
FileCopyUtils.copy(getClass().getResourceAsStream("log.txt"),
new FileOutputStream(LOG_FILE));
this.mockMvc
.perform(get("/logfile").accept(MediaType.TEXT_PLAIN)
.perform(get("/application/logfile").accept(MediaType.TEXT_PLAIN)
.header(HttpHeaders.RANGE, "bytes=0-1024"))
.andExpect(status().isPartialContent())
.andDo(document("partial-logfile"));
Expand Down Expand Up @@ -139,7 +139,7 @@ public void endpoints() throws Exception {
if (!SKIPPED.contains(endpointPath)) {
String output = endpointPath.substring(1);
output = output.length() > 0 ? output : "./";
this.mockMvc.perform(get(endpointPath).accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application" + endpointPath).accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andDo(document(output))
.andDo(new ResultHandler() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class HealthEndpointDocumentation {

@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()).andDo(document("health/insensitive"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ public class HypermediaEndpointDocumentation {

@Test
public void beans() throws Exception {
this.mockMvc.perform(get("/beans").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application/beans").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andDo(document("beans/hypermedia"));
}

@Test
public void metrics() throws Exception {
this.mockMvc.perform(get("/metrics").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application/metrics").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$._links.self.href")
.value("http://localhost:8080/metrics"))
.value("http://localhost:8080/application/metrics"))
.andDo(document("metrics/hypermedia"));
}

@Test
public void home() throws Exception {
this.mockMvc.perform(get("/actuator").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andDo(document("admin"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
* Management endpoint context-path.
*/
@NotNull
private String contextPath = "";
private String contextPath = "/application";

/**
* Add the "X-Application-Context" HTTP header in each response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private static String getDefaultPath(
if (StringUtils.hasText(managementServletContext.getContextPath())) {
return "";
}
return "/actuator";
return "/application";
}

@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,35 @@ public void closeContext() {
@Test
public void basicCuriesHref() {
int port = load("endpoints.docs.curies.enabled:true", "server.port:0");
assertThat(getCurieHref("http://localhost:" + port + "/actuator")).isEqualTo(
"http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}");
assertThat(getCurieHref("http://localhost:" + port + "/application")).isEqualTo(
"http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}");
}

@Test
public void curiesHrefWithCustomContextPath() {
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
"server.context-path:/context");
assertThat(getCurieHref("http://localhost:" + port + "/context/actuator"))
assertThat(getCurieHref("http://localhost:" + port + "/context/application"))
.isEqualTo("http://localhost:" + port
+ "/context/docs/#spring_boot_actuator__{rel}");
+ "/context/application/docs/#spring_boot_actuator__{rel}");
}

@Test
public void curiesHrefWithCustomServletPath() {
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
"server.servlet-path:/servlet");
assertThat(getCurieHref("http://localhost:" + port + "/servlet/actuator"))
assertThat(getCurieHref("http://localhost:" + port + "/servlet/application"))
.isEqualTo("http://localhost:" + port
+ "/servlet/docs/#spring_boot_actuator__{rel}");
+ "/servlet/application/docs/#spring_boot_actuator__{rel}");
}

@Test
public void curiesHrefWithCustomServletAndContextPaths() {
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
"server.context-path:/context", "server.servlet-path:/servlet");
assertThat(getCurieHref("http://localhost:" + port + "/context/servlet/actuator"))
assertThat(getCurieHref("http://localhost:" + port + "/context/servlet/application"))
.isEqualTo("http://localhost:" + port
+ "/context/servlet/docs/#spring_boot_actuator__{rel}");
+ "/context/servlet/application/docs/#spring_boot_actuator__{rel}");
}

@Test
Expand All @@ -95,8 +95,8 @@ public void serverPathsAreIgnoredWithSeparateManagementPort() {
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
"server.context-path:/context", "server.servlet-path:/servlet",
"management.port:0");
assertThat(getCurieHref("http://localhost:" + port + "/actuator/")).isEqualTo(
"http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}");
assertThat(getCurieHref("http://localhost:" + port + "/application/")).isEqualTo(
"http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ public class EndpointMvcIntegrationTests {
@Test
public void envEndpointNotHidden() throws InterruptedException {
String body = new TestRestTemplate().getForObject(
"http://localhost:" + this.port + "/env/user.dir", String.class);
"http://localhost:" + this.port + "/application/env/user.dir", String.class);
assertThat(body).isNotNull().contains("spring-boot-actuator");
assertThat(this.interceptor.invoked()).isTrue();
}

@Test
public void healthEndpointNotHidden() throws InterruptedException {
String body = new TestRestTemplate()
.getForObject("http://localhost:" + this.port + "/health", String.class);
.getForObject("http://localhost:" + this.port + "/application/health", String.class);
assertThat(body).isNotNull().contains("status");
assertThat(this.interceptor.invoked()).isTrue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ public void onSamePort() throws Exception {
EndpointWebMvcAutoConfiguration.class);
this.applicationContext.refresh();
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, "endpointoutput");
assertContent("/application/endpoint", ports.get().server, "endpointoutput");
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, null);
assertThat(hasHeader("/endpoint", ports.get().server, "X-Application-Context"))
assertContent("/application/endpoint", ports.get().management, null);
assertThat(hasHeader("/application/endpoint", ports.get().server, "X-Application-Context"))
.isTrue();
assertThat(this.applicationContext.containsBean("applicationContextIdFilter"))
.isTrue();
Expand Down Expand Up @@ -287,7 +287,7 @@ public void onRandomPort() throws Exception {
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", managementPort, null);
assertContent("/endpoint", managementPort, "endpointoutput");
assertContent("/application/endpoint", managementPort, "endpointoutput");
}

@Test
Expand Down Expand Up @@ -330,7 +330,7 @@ public void specificPortsViaProperties() throws Exception {
assertContent("/controller", ports.get().server, "controlleroutput");
assertContent("/endpoint", ports.get().server, null);
assertContent("/controller", ports.get().management, null);
assertContent("/endpoint", ports.get().management, "endpointoutput");
assertContent("/application/endpoint", ports.get().management, "endpointoutput");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,36 @@ public void basicConfiguration() {
public void curiesEnabledWithDefaultPorts() {
load("endpoints.docs.curies.enabled:true");
assertThat(getCurieHref())
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
}

@Test
public void curiesEnabledWithRandomPorts() {
load("endpoints.docs.curies.enabled:true", "server.port:0", "management.port:0");
assertThat(getCurieHref())
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
}

@Test
public void curiesEnabledWithSpecificServerPort() {
load("endpoints.docs.curies.enabled:true", "server.port:8080");
assertThat(getCurieHref())
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
}

@Test
public void curiesEnabledWithSpecificManagementPort() {
load("endpoints.docs.curies.enabled:true", "management.port:8081");
assertThat(getCurieHref())
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
}

@Test
public void curiesEnabledWithSpecificManagementAndServerPorts() {
load("endpoints.docs.curies.enabled:true", "server.port:8080",
"management.port:8081");
assertThat(getCurieHref())
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
}

private void load(String... properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void close() {
public void defaultManagementServerProperties() {
ManagementServerProperties properties = new ManagementServerProperties();
assertThat(properties.getPort()).isNull();
assertThat(properties.getContextPath()).isEqualTo("");
assertThat(properties.getContextPath()).isEqualTo("/application");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ public void testWebConfiguration() throws Exception {
FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
// 1 for static resources, one for management endpoints and one for the rest
assertThat(filterChainProxy.getFilterChains()).hasSize(3);
assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/application/beans")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/application/beans/")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/application/beans.foo")).isNotEmpty();
assertThat(filterChainProxy.getFilters("/application/beans/foo/bar")).isNotEmpty();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ public void setUp() {

@Test
public void home() throws Exception {
this.mvc.perform(get("/env")).andExpect(status().isOk())
this.mvc.perform(get("/application/env")).andExpect(status().isOk())
.andExpect(content().string(containsString("systemProperties")));
}

@Test
public void sub() throws Exception {
this.mvc.perform(get("/env/foo")).andExpect(status().isOk())
this.mvc.perform(get("/application/env/foo")).andExpect(status().isOk())
.andExpect(content().string("{\"foo\":\"bar\"}"));
}

@Test
public void subWhenDisabled() throws Exception {
this.context.getBean(EnvironmentEndpoint.class).setEnabled(false);
this.mvc.perform(get("/env/foo")).andExpect(status().isNotFound());
this.mvc.perform(get("/application/env/foo")).andExpect(status().isNotFound());
}

@Test
Expand All @@ -99,7 +99,7 @@ public void regex() throws Exception {
map.put("food", null);
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
.addFirst(new MapPropertySource("null-value", map));
this.mvc.perform(get("/env/foo.*")).andExpect(status().isOk())
this.mvc.perform(get("/application/env/foo.*")).andExpect(status().isOk())
.andExpect(content().string(containsString("\"foo\":\"bar\"")))
.andExpect(content().string(containsString("\"fool\":\"baz\"")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ public void setUp() {

@Test
public void requestWithTrailingSlashIsRedirectedToBrowserHtml() throws Exception {
this.mockMvc.perform(get("/actuator/").accept(MediaType.TEXT_HTML))
this.mockMvc.perform(get("/application/actuator/").accept(MediaType.TEXT_HTML))
.andExpect(status().isFound()).andExpect(header().string(
HttpHeaders.LOCATION, "http://localhost/actuator/browser.html"));
HttpHeaders.LOCATION, "http://localhost/application/actuator/browser.html"));
}

@Test
public void requestWithoutTrailingSlashIsRedirectedToBrowserHtml() throws Exception {
this.mockMvc.perform(get("/actuator").accept(MediaType.TEXT_HTML))
this.mockMvc.perform(get("/application/actuator").accept(MediaType.TEXT_HTML))
.andExpect(status().isFound()).andExpect(header().string("location",
"http://localhost/actuator/browser.html"));
"http://localhost/application/actuator/browser.html"));
}

@MinimalActuatorHypermediaApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,26 @@ public void setUp() {

@Test
public void linksOnActuator() throws Exception {
this.mockMvc.perform(get("/actuator").accept(MediaType.APPLICATION_JSON))
this.mockMvc.perform(get("/application").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$._links").exists())
.andExpect(header().doesNotExist("cache-control"));
}

@Test
public void browserRedirect() throws Exception {
this.mockMvc.perform(get("/actuator/").accept(MediaType.TEXT_HTML))
this.mockMvc.perform(get("/application/").accept(MediaType.TEXT_HTML))
.andExpect(status().isFound()).andExpect(header().string(
HttpHeaders.LOCATION, "http://localhost/actuator/browser.html"));
HttpHeaders.LOCATION, "http://localhost/application/browser.html"));
}

@Test
public void endpointsDoNotHaveLinks() throws Exception {
for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
String path = endpoint.getPath();
if ("/actuator".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) {
if ("".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) {
continue;
}
path = path.length() > 0 ? path : "/";
path = "/application" + (path.length() > 0 ? path : "/");
this.mockMvc.perform(get(path).accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$._links").doesNotExist());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@ public void actuatorBrowserRedirect() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/spring/actuator/", HttpMethod.GET,
"http://localhost:" + this.port + "/spring/application/", HttpMethod.GET,
new HttpEntity<Void>(null, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create(
"http://localhost:" + this.port + "/spring/actuator/browser.html"));
"http://localhost:" + this.port + "/spring/application/browser.html"));
}

@Test
public void actuatorBrowserEntryPoint() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/spring/actuator/browser.html",
"http://localhost:" + this.port + "/spring/application/browser.html",
HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("entryPoint: '/spring/actuator'");
assertThat(entity.getBody()).contains("entryPoint: '/spring/application'");
}

@Test
public void actuatorLinks() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/spring/actuator", HttpMethod.GET,
"http://localhost:" + this.port + "/spring/application", HttpMethod.GET,
new HttpEntity<Void>(null, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"_links\":");
Expand All @@ -108,7 +108,7 @@ public void actuatorLinksWithTrailingSlash() throws Exception {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
ResponseEntity<String> entity = new TestRestTemplate().exchange(
"http://localhost:" + this.port + "/spring/actuator/", HttpMethod.GET,
"http://localhost:" + this.port + "/spring/application/", HttpMethod.GET,
new HttpEntity<Void>(null, headers), String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"_links\":");
Expand Down
Loading