Skip to content

Commit bcd79dd

Browse files
committed
Move all actuators under /application
Context path can be configured via `management.context-path`. Closes gh-6886
1 parent 92468d4 commit bcd79dd

File tree

47 files changed

+242
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+242
-186
lines changed

spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static void clearLog() {
9797

9898
@Test
9999
public void logfile() throws Exception {
100-
this.mockMvc.perform(get("/logfile").accept(MediaType.TEXT_PLAIN))
100+
this.mockMvc.perform(get("/application/logfile").accept(MediaType.TEXT_PLAIN))
101101
.andExpect(status().isOk()).andDo(document("logfile"));
102102
}
103103

@@ -106,7 +106,7 @@ public void partialLogfile() throws Exception {
106106
FileCopyUtils.copy(getClass().getResourceAsStream("log.txt"),
107107
new FileOutputStream(LOG_FILE));
108108
this.mockMvc
109-
.perform(get("/logfile").accept(MediaType.TEXT_PLAIN)
109+
.perform(get("/application/logfile").accept(MediaType.TEXT_PLAIN)
110110
.header(HttpHeaders.RANGE, "bytes=0-1024"))
111111
.andExpect(status().isPartialContent())
112112
.andDo(document("partial-logfile"));
@@ -115,15 +115,15 @@ public void partialLogfile() throws Exception {
115115
@Test
116116
public void singleLogger() throws Exception {
117117
this.mockMvc
118-
.perform(get("/loggers/org.springframework.boot")
118+
.perform(get("/application/loggers/org.springframework.boot")
119119
.accept(MediaType.APPLICATION_JSON))
120120
.andExpect(status().isOk()).andDo(document("single-logger"));
121121
}
122122

123123
@Test
124124
public void setLogger() throws Exception {
125125
this.mockMvc
126-
.perform(post("/loggers/org.springframework.boot")
126+
.perform(post("/application/loggers/org.springframework.boot")
127127
.contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)
128128
.content("{\"configuredLevel\": \"DEBUG\"}"))
129129
.andExpect(status().isOk()).andDo(document("set-logger"));
@@ -132,15 +132,15 @@ public void setLogger() throws Exception {
132132
@Test
133133
public void auditEvents() throws Exception {
134134
this.mockMvc
135-
.perform(get("/auditevents").param("after", "2016-11-01T10:00:00+0000")
135+
.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")
136136
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
137137
.andExpect(status().isOk()).andDo(document("auditevents"));
138138
}
139139

140140
@Test
141141
public void auditEventsByPrincipal() throws Exception {
142142
this.mockMvc
143-
.perform(get("/auditevents").param("principal", "admin")
143+
.perform(get("/application/auditevents").param("principal", "admin")
144144
.param("after", "2016-11-01T10:00:00+0000")
145145
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
146146
.andExpect(status().isOk())
@@ -150,7 +150,7 @@ public void auditEventsByPrincipal() throws Exception {
150150
@Test
151151
public void auditEventsByPrincipalAndType() throws Exception {
152152
this.mockMvc
153-
.perform(get("/auditevents").param("principal", "admin")
153+
.perform(get("/application/auditevents").param("principal", "admin")
154154
.param("after", "2016-11-01T10:00:00+0000")
155155
.param("type", "AUTHENTICATION_SUCCESS")
156156
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
@@ -171,7 +171,7 @@ public void endpoints() throws Exception {
171171
String output = endpointPath.substring(1);
172172
output = output.length() > 0 ? output : "./";
173173
this.mockMvc
174-
.perform(get(endpointPath)
174+
.perform(get("/application" + endpointPath)
175175
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
176176
.andExpect(status().isOk()).andDo(document(output))
177177
.andDo(new ResultHandler() {

spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HealthEndpointDocumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class HealthEndpointDocumentation {
5151
@Test
5252
public void health() throws Exception {
5353
this.mockMvc
54-
.perform(get("/health")
54+
.perform(get("/application/health")
5555
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
5656
.andExpect(status().isOk()).andDo(document("health/insensitive"));
5757
}

spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HypermediaEndpointDocumentation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,26 @@ public class HypermediaEndpointDocumentation {
5252
@Test
5353
public void beans() throws Exception {
5454
this.mockMvc
55-
.perform(get("/beans")
55+
.perform(get("/application/beans")
5656
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
5757
.andExpect(status().isOk()).andDo(document("beans/hypermedia"));
5858
}
5959

6060
@Test
6161
public void metrics() throws Exception {
6262
this.mockMvc
63-
.perform(get("/metrics")
63+
.perform(get("/application/metrics")
6464
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
6565
.andExpect(status().isOk())
6666
.andExpect(jsonPath("$._links.self.href")
67-
.value("http://localhost:8080/metrics"))
67+
.value("http://localhost:8080/application/metrics"))
6868
.andDo(document("metrics/hypermedia"));
6969
}
7070

7171
@Test
7272
public void home() throws Exception {
7373
this.mockMvc
74-
.perform(get("/actuator")
74+
.perform(get("/application")
7575
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
7676
.andExpect(status().isOk()).andDo(document("admin"));
7777
}

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
7979
/**
8080
* Management endpoint context-path.
8181
*/
82-
private String contextPath = "";
82+
private String contextPath = "/application";
8383

8484
/**
8585
* Add the "X-Application-Context" HTTP header in each response.

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private static String getDefaultPath(
4444
if (StringUtils.hasText(managementServletContext.getContextPath())) {
4545
return "";
4646
}
47-
return "/actuator";
47+
return "/application";
4848
}
4949

5050
@ActuatorGetMapping

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/BootCuriesHrefIntegrationTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,35 @@ public void closeContext() {
4949
@Test
5050
public void basicCuriesHref() {
5151
int port = load("endpoints.docs.curies.enabled:true", "server.port:0");
52-
assertThat(getCurieHref("http://localhost:" + port + "/actuator")).isEqualTo(
53-
"http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}");
52+
assertThat(getCurieHref("http://localhost:" + port + "/application")).isEqualTo(
53+
"http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}");
5454
}
5555

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

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

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

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

102102
@Test

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ public class EndpointMvcIntegrationTests {
8585
@Test
8686
public void envEndpointNotHidden() throws InterruptedException {
8787
String body = new TestRestTemplate().getForObject(
88-
"http://localhost:" + this.port + "/env/foo.bar", String.class);
88+
"http://localhost:" + this.port + "/application/env/foo.bar", String.class);
8989
assertThat(body).isNotNull().contains("\"baz\"");
9090
assertThat(this.interceptor.invoked()).isTrue();
9191
}
9292

9393
@Test
9494
public void healthEndpointNotHidden() throws InterruptedException {
9595
String body = new TestRestTemplate()
96-
.getForObject("http://localhost:" + this.port + "/health", String.class);
96+
.getForObject("http://localhost:" + this.port + "/application/health", String.class);
9797
assertThat(body).isNotNull().contains("status");
9898
assertThat(this.interceptor.invoked()).isTrue();
9999
}

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfigurationTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,36 @@ public void basicConfiguration() {
8080
public void curiesEnabledWithDefaultPorts() {
8181
load("endpoints.docs.curies.enabled:true");
8282
assertThat(getCurieHref())
83-
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
83+
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
8484
}
8585

8686
@Test
8787
public void curiesEnabledWithRandomPorts() {
8888
load("endpoints.docs.curies.enabled:true", "server.port:0", "management.port:0");
8989
assertThat(getCurieHref())
90-
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
90+
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
9191
}
9292

9393
@Test
9494
public void curiesEnabledWithSpecificServerPort() {
9595
load("endpoints.docs.curies.enabled:true", "server.port:8080");
9696
assertThat(getCurieHref())
97-
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
97+
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
9898
}
9999

100100
@Test
101101
public void curiesEnabledWithSpecificManagementPort() {
102102
load("endpoints.docs.curies.enabled:true", "management.port:8081");
103103
assertThat(getCurieHref())
104-
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
104+
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
105105
}
106106

107107
@Test
108108
public void curiesEnabledWithSpecificManagementAndServerPorts() {
109109
load("endpoints.docs.curies.enabled:true", "server.port:8080",
110110
"management.port:8081");
111111
assertThat(getCurieHref())
112-
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
112+
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
113113
}
114114

115115
private void load(String... properties) {

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void endpointHandlerMapping() throws Exception {
7474
this.context.refresh();
7575
EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping",
7676
EndpointHandlerMapping.class);
77-
assertThat(mapping.getPrefix()).isEmpty();
77+
assertThat(mapping.getPrefix()).isEqualTo("/application");
7878
MvcEndpointSecurityInterceptor securityInterceptor = (MvcEndpointSecurityInterceptor) ReflectionTestUtils
7979
.getField(mapping, "securityInterceptor");
8080
Object secure = ReflectionTestUtils.getField(securityInterceptor, "secure");

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void close() {
4646
public void defaultManagementServerProperties() {
4747
ManagementServerProperties properties = new ManagementServerProperties();
4848
assertThat(properties.getPort()).isNull();
49-
assertThat(properties.getContextPath()).isEqualTo("");
49+
assertThat(properties.getContextPath()).isEqualTo("/application");
5050
assertThat(properties.getAddApplicationContextHeader()).isEqualTo(false);
5151
}
5252

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementWebSecurityAutoConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ public void testWebConfiguration() throws Exception {
9797
FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
9898
// 1 for static resources, one for management endpoints and one for the rest
9999
assertThat(filterChainProxy.getFilterChains()).hasSize(3);
100-
assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty();
101-
assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty();
102-
assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty();
103-
assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty();
100+
assertThat(filterChainProxy.getFilters("/application/beans")).isNotEmpty();
101+
assertThat(filterChainProxy.getFilters("/application/beans/")).isNotEmpty();
102+
assertThat(filterChainProxy.getFilters("/application/beans.foo")).isNotEmpty();
103+
assertThat(filterChainProxy.getFilters("/application/beans/foo/bar")).isNotEmpty();
104104
}
105105

106106
@Test

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AuditEventsMvcEndpointTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ public void setUp() {
7474

7575
@Test
7676
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
77-
this.mvc.perform(get("/auditevents")).andExpect(status().isOk())
77+
this.mvc.perform(get("/application/auditevents")).andExpect(status().isOk())
7878
.andExpect(header().string("Content-Type",
7979
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
8080
}
8181

8282
@Test
8383
public void contentTypeCanBeApplicationJson() throws Exception {
84-
this.mvc.perform(get("/auditevents").header(HttpHeaders.ACCEPT,
84+
this.mvc.perform(get("/application/auditevents").header(HttpHeaders.ACCEPT,
8585
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
8686
.andExpect(header().string("Content-Type",
8787
MediaType.APPLICATION_JSON_UTF8_VALUE));
@@ -90,20 +90,20 @@ public void contentTypeCanBeApplicationJson() throws Exception {
9090
@Test
9191
public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception {
9292
this.context.getBean(AuditEventsMvcEndpoint.class).setEnabled(false);
93-
this.mvc.perform(get("/auditevents").param("after", "2016-11-01T10:00:00+0000"))
93+
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000"))
9494
.andExpect(status().isNotFound());
9595
}
9696

9797
@Test
9898
public void invokeFilterByDateAfter() throws Exception {
99-
this.mvc.perform(get("/auditevents").param("after", "2016-11-01T13:00:00+0000"))
99+
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T13:00:00+0000"))
100100
.andExpect(status().isOk())
101101
.andExpect(content().string("{\"events\":[]}"));
102102
}
103103

104104
@Test
105105
public void invokeFilterByPrincipalAndDateAfter() throws Exception {
106-
this.mvc.perform(get("/auditevents").param("principal", "user").param("after",
106+
this.mvc.perform(get("/application/auditevents").param("principal", "user").param("after",
107107
"2016-11-01T10:00:00+0000"))
108108
.andExpect(status().isOk())
109109
.andExpect(content().string(
@@ -113,7 +113,7 @@ public void invokeFilterByPrincipalAndDateAfter() throws Exception {
113113

114114
@Test
115115
public void invokeFilterByPrincipalAndDateAfterAndType() throws Exception {
116-
this.mvc.perform(get("/auditevents").param("principal", "admin")
116+
this.mvc.perform(get("/application/auditevents").param("principal", "admin")
117117
.param("after", "2016-11-01T10:00:00+0000").param("type", "logout"))
118118
.andExpect(status().isOk())
119119
.andExpect(content().string(

0 commit comments

Comments
 (0)