Move all actuators under `/application`
Context path can be configured via `management.context-path`. Closes gh-6886
This commit is contained in:
parent
92468d4ffc
commit
bcd79dd992
|
@ -97,7 +97,7 @@ public class EndpointDocumentation {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void logfile() throws Exception {
|
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"));
|
.andExpect(status().isOk()).andDo(document("logfile"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ public class EndpointDocumentation {
|
||||||
FileCopyUtils.copy(getClass().getResourceAsStream("log.txt"),
|
FileCopyUtils.copy(getClass().getResourceAsStream("log.txt"),
|
||||||
new FileOutputStream(LOG_FILE));
|
new FileOutputStream(LOG_FILE));
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/logfile").accept(MediaType.TEXT_PLAIN)
|
.perform(get("/application/logfile").accept(MediaType.TEXT_PLAIN)
|
||||||
.header(HttpHeaders.RANGE, "bytes=0-1024"))
|
.header(HttpHeaders.RANGE, "bytes=0-1024"))
|
||||||
.andExpect(status().isPartialContent())
|
.andExpect(status().isPartialContent())
|
||||||
.andDo(document("partial-logfile"));
|
.andDo(document("partial-logfile"));
|
||||||
|
@ -115,7 +115,7 @@ public class EndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void singleLogger() throws Exception {
|
public void singleLogger() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/loggers/org.springframework.boot")
|
.perform(get("/application/loggers/org.springframework.boot")
|
||||||
.accept(MediaType.APPLICATION_JSON))
|
.accept(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().isOk()).andDo(document("single-logger"));
|
.andExpect(status().isOk()).andDo(document("single-logger"));
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ public class EndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void setLogger() throws Exception {
|
public void setLogger() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(post("/loggers/org.springframework.boot")
|
.perform(post("/application/loggers/org.springframework.boot")
|
||||||
.contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)
|
.contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)
|
||||||
.content("{\"configuredLevel\": \"DEBUG\"}"))
|
.content("{\"configuredLevel\": \"DEBUG\"}"))
|
||||||
.andExpect(status().isOk()).andDo(document("set-logger"));
|
.andExpect(status().isOk()).andDo(document("set-logger"));
|
||||||
|
@ -132,7 +132,7 @@ public class EndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void auditEvents() throws Exception {
|
public void auditEvents() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/auditevents").param("after", "2016-11-01T10:00:00+0000")
|
.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
.andExpect(status().isOk()).andDo(document("auditevents"));
|
.andExpect(status().isOk()).andDo(document("auditevents"));
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class EndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void auditEventsByPrincipal() throws Exception {
|
public void auditEventsByPrincipal() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/auditevents").param("principal", "admin")
|
.perform(get("/application/auditevents").param("principal", "admin")
|
||||||
.param("after", "2016-11-01T10:00:00+0000")
|
.param("after", "2016-11-01T10:00:00+0000")
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
|
@ -150,7 +150,7 @@ public class EndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void auditEventsByPrincipalAndType() throws Exception {
|
public void auditEventsByPrincipalAndType() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/auditevents").param("principal", "admin")
|
.perform(get("/application/auditevents").param("principal", "admin")
|
||||||
.param("after", "2016-11-01T10:00:00+0000")
|
.param("after", "2016-11-01T10:00:00+0000")
|
||||||
.param("type", "AUTHENTICATION_SUCCESS")
|
.param("type", "AUTHENTICATION_SUCCESS")
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
|
@ -171,7 +171,7 @@ public class EndpointDocumentation {
|
||||||
String output = endpointPath.substring(1);
|
String output = endpointPath.substring(1);
|
||||||
output = output.length() > 0 ? output : "./";
|
output = output.length() > 0 ? output : "./";
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get(endpointPath)
|
.perform(get("/application" + endpointPath)
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
.andExpect(status().isOk()).andDo(document(output))
|
.andExpect(status().isOk()).andDo(document(output))
|
||||||
.andDo(new ResultHandler() {
|
.andDo(new ResultHandler() {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class HealthEndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void health() throws Exception {
|
public void health() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/health")
|
.perform(get("/application/health")
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
.andExpect(status().isOk()).andDo(document("health/insensitive"));
|
.andExpect(status().isOk()).andDo(document("health/insensitive"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class HypermediaEndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void beans() throws Exception {
|
public void beans() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/beans")
|
.perform(get("/application/beans")
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
.andExpect(status().isOk()).andDo(document("beans/hypermedia"));
|
.andExpect(status().isOk()).andDo(document("beans/hypermedia"));
|
||||||
}
|
}
|
||||||
|
@ -60,18 +60,18 @@ public class HypermediaEndpointDocumentation {
|
||||||
@Test
|
@Test
|
||||||
public void metrics() throws Exception {
|
public void metrics() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/metrics")
|
.perform(get("/application/metrics")
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$._links.self.href")
|
.andExpect(jsonPath("$._links.self.href")
|
||||||
.value("http://localhost:8080/metrics"))
|
.value("http://localhost:8080/application/metrics"))
|
||||||
.andDo(document("metrics/hypermedia"));
|
.andDo(document("metrics/hypermedia"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void home() throws Exception {
|
public void home() throws Exception {
|
||||||
this.mockMvc
|
this.mockMvc
|
||||||
.perform(get("/actuator")
|
.perform(get("/application")
|
||||||
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
.accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON))
|
||||||
.andExpect(status().isOk()).andDo(document("admin"));
|
.andExpect(status().isOk()).andDo(document("admin"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
|
||||||
/**
|
/**
|
||||||
* Management endpoint context-path.
|
* Management endpoint context-path.
|
||||||
*/
|
*/
|
||||||
private String contextPath = "";
|
private String contextPath = "/application";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the "X-Application-Context" HTTP header in each response.
|
* Add the "X-Application-Context" HTTP header in each response.
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class HalJsonMvcEndpoint extends AbstractNamedMvcEndpoint {
|
||||||
if (StringUtils.hasText(managementServletContext.getContextPath())) {
|
if (StringUtils.hasText(managementServletContext.getContextPath())) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return "/actuator";
|
return "/application";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ActuatorGetMapping
|
@ActuatorGetMapping
|
||||||
|
|
|
@ -49,35 +49,35 @@ public class BootCuriesHrefIntegrationTests {
|
||||||
@Test
|
@Test
|
||||||
public void basicCuriesHref() {
|
public void basicCuriesHref() {
|
||||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0");
|
int port = load("endpoints.docs.curies.enabled:true", "server.port:0");
|
||||||
assertThat(getCurieHref("http://localhost:" + port + "/actuator")).isEqualTo(
|
assertThat(getCurieHref("http://localhost:" + port + "/application")).isEqualTo(
|
||||||
"http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}");
|
"http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void curiesHrefWithCustomContextPath() {
|
public void curiesHrefWithCustomContextPath() {
|
||||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||||
"server.servlet.context-path:/context");
|
"server.servlet.context-path:/context");
|
||||||
assertThat(getCurieHref("http://localhost:" + port + "/context/actuator"))
|
assertThat(getCurieHref("http://localhost:" + port + "/context/application"))
|
||||||
.isEqualTo("http://localhost:" + port
|
.isEqualTo("http://localhost:" + port
|
||||||
+ "/context/docs/#spring_boot_actuator__{rel}");
|
+ "/context/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void curiesHrefWithCustomServletPath() {
|
public void curiesHrefWithCustomServletPath() {
|
||||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||||
"server.servlet.path:/servlet");
|
"server.servlet.path:/servlet");
|
||||||
assertThat(getCurieHref("http://localhost:" + port + "/servlet/actuator"))
|
assertThat(getCurieHref("http://localhost:" + port + "/servlet/application"))
|
||||||
.isEqualTo("http://localhost:" + port
|
.isEqualTo("http://localhost:" + port
|
||||||
+ "/servlet/docs/#spring_boot_actuator__{rel}");
|
+ "/servlet/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void curiesHrefWithCustomServletAndContextPaths() {
|
public void curiesHrefWithCustomServletAndContextPaths() {
|
||||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||||
"server.servlet.context-path:/context", "server.servlet.path:/servlet");
|
"server.servlet.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
|
.isEqualTo("http://localhost:" + port
|
||||||
+ "/context/servlet/docs/#spring_boot_actuator__{rel}");
|
+ "/context/servlet/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -95,8 +95,8 @@ public class BootCuriesHrefIntegrationTests {
|
||||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||||
"server.servlet.context-path:/context", "server.servlet.path:/servlet",
|
"server.servlet.context-path:/context", "server.servlet.path:/servlet",
|
||||||
"management.port:0");
|
"management.port:0");
|
||||||
assertThat(getCurieHref("http://localhost:" + port + "/actuator/")).isEqualTo(
|
assertThat(getCurieHref("http://localhost:" + port + "/application/")).isEqualTo(
|
||||||
"http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}");
|
"http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class EndpointMvcIntegrationTests {
|
||||||
@Test
|
@Test
|
||||||
public void envEndpointNotHidden() throws InterruptedException {
|
public void envEndpointNotHidden() throws InterruptedException {
|
||||||
String body = new TestRestTemplate().getForObject(
|
String body = new TestRestTemplate().getForObject(
|
||||||
"http://localhost:" + this.port + "/env/foo.bar", String.class);
|
"http://localhost:" + this.port + "/application/env/foo.bar", String.class);
|
||||||
assertThat(body).isNotNull().contains("\"baz\"");
|
assertThat(body).isNotNull().contains("\"baz\"");
|
||||||
assertThat(this.interceptor.invoked()).isTrue();
|
assertThat(this.interceptor.invoked()).isTrue();
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class EndpointMvcIntegrationTests {
|
||||||
@Test
|
@Test
|
||||||
public void healthEndpointNotHidden() throws InterruptedException {
|
public void healthEndpointNotHidden() throws InterruptedException {
|
||||||
String body = new TestRestTemplate()
|
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(body).isNotNull().contains("status");
|
||||||
assertThat(this.interceptor.invoked()).isTrue();
|
assertThat(this.interceptor.invoked()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,28 +80,28 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests {
|
||||||
public void curiesEnabledWithDefaultPorts() {
|
public void curiesEnabledWithDefaultPorts() {
|
||||||
load("endpoints.docs.curies.enabled:true");
|
load("endpoints.docs.curies.enabled:true");
|
||||||
assertThat(getCurieHref())
|
assertThat(getCurieHref())
|
||||||
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
|
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void curiesEnabledWithRandomPorts() {
|
public void curiesEnabledWithRandomPorts() {
|
||||||
load("endpoints.docs.curies.enabled:true", "server.port:0", "management.port:0");
|
load("endpoints.docs.curies.enabled:true", "server.port:0", "management.port:0");
|
||||||
assertThat(getCurieHref())
|
assertThat(getCurieHref())
|
||||||
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
|
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void curiesEnabledWithSpecificServerPort() {
|
public void curiesEnabledWithSpecificServerPort() {
|
||||||
load("endpoints.docs.curies.enabled:true", "server.port:8080");
|
load("endpoints.docs.curies.enabled:true", "server.port:8080");
|
||||||
assertThat(getCurieHref())
|
assertThat(getCurieHref())
|
||||||
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
|
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void curiesEnabledWithSpecificManagementPort() {
|
public void curiesEnabledWithSpecificManagementPort() {
|
||||||
load("endpoints.docs.curies.enabled:true", "management.port:8081");
|
load("endpoints.docs.curies.enabled:true", "management.port:8081");
|
||||||
assertThat(getCurieHref())
|
assertThat(getCurieHref())
|
||||||
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
|
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -109,7 +109,7 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests {
|
||||||
load("endpoints.docs.curies.enabled:true", "server.port:8080",
|
load("endpoints.docs.curies.enabled:true", "server.port:8080",
|
||||||
"management.port:8081");
|
"management.port:8081");
|
||||||
assertThat(getCurieHref())
|
assertThat(getCurieHref())
|
||||||
.isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}");
|
.isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(String... properties) {
|
private void load(String... properties) {
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class EndpointWebMvcManagementContextConfigurationTests {
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping",
|
EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping",
|
||||||
EndpointHandlerMapping.class);
|
EndpointHandlerMapping.class);
|
||||||
assertThat(mapping.getPrefix()).isEmpty();
|
assertThat(mapping.getPrefix()).isEqualTo("/application");
|
||||||
MvcEndpointSecurityInterceptor securityInterceptor = (MvcEndpointSecurityInterceptor) ReflectionTestUtils
|
MvcEndpointSecurityInterceptor securityInterceptor = (MvcEndpointSecurityInterceptor) ReflectionTestUtils
|
||||||
.getField(mapping, "securityInterceptor");
|
.getField(mapping, "securityInterceptor");
|
||||||
Object secure = ReflectionTestUtils.getField(securityInterceptor, "secure");
|
Object secure = ReflectionTestUtils.getField(securityInterceptor, "secure");
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ManagementServerPropertiesTests {
|
||||||
public void defaultManagementServerProperties() {
|
public void defaultManagementServerProperties() {
|
||||||
ManagementServerProperties properties = new ManagementServerProperties();
|
ManagementServerProperties properties = new ManagementServerProperties();
|
||||||
assertThat(properties.getPort()).isNull();
|
assertThat(properties.getPort()).isNull();
|
||||||
assertThat(properties.getContextPath()).isEqualTo("");
|
assertThat(properties.getContextPath()).isEqualTo("/application");
|
||||||
assertThat(properties.getAddApplicationContextHeader()).isEqualTo(false);
|
assertThat(properties.getAddApplicationContextHeader()).isEqualTo(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,10 +97,10 @@ public class ManagementWebSecurityAutoConfigurationTests {
|
||||||
FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
|
FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class);
|
||||||
// 1 for static resources, one for management endpoints and one for the rest
|
// 1 for static resources, one for management endpoints and one for the rest
|
||||||
assertThat(filterChainProxy.getFilterChains()).hasSize(3);
|
assertThat(filterChainProxy.getFilterChains()).hasSize(3);
|
||||||
assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty();
|
assertThat(filterChainProxy.getFilters("/application/beans")).isNotEmpty();
|
||||||
assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty();
|
assertThat(filterChainProxy.getFilters("/application/beans/")).isNotEmpty();
|
||||||
assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty();
|
assertThat(filterChainProxy.getFilters("/application/beans.foo")).isNotEmpty();
|
||||||
assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty();
|
assertThat(filterChainProxy.getFilters("/application/beans/foo/bar")).isNotEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -74,14 +74,14 @@ public class AuditEventsMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
|
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(get("/auditevents")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/auditevents")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeCanBeApplicationJson() throws Exception {
|
public void contentTypeCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(get("/auditevents").header(HttpHeaders.ACCEPT,
|
this.mvc.perform(get("/application/auditevents").header(HttpHeaders.ACCEPT,
|
||||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
@ -90,20 +90,20 @@ public class AuditEventsMvcEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception {
|
public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception {
|
||||||
this.context.getBean(AuditEventsMvcEndpoint.class).setEnabled(false);
|
this.context.getBean(AuditEventsMvcEndpoint.class).setEnabled(false);
|
||||||
this.mvc.perform(get("/auditevents").param("after", "2016-11-01T10:00:00+0000"))
|
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000"))
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeFilterByDateAfter() throws Exception {
|
public void invokeFilterByDateAfter() throws Exception {
|
||||||
this.mvc.perform(get("/auditevents").param("after", "2016-11-01T13:00:00+0000"))
|
this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T13:00:00+0000"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string("{\"events\":[]}"));
|
.andExpect(content().string("{\"events\":[]}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeFilterByPrincipalAndDateAfter() throws Exception {
|
public void invokeFilterByPrincipalAndDateAfter() throws Exception {
|
||||||
this.mvc.perform(get("/auditevents").param("principal", "user").param("after",
|
this.mvc.perform(get("/application/auditevents").param("principal", "user").param("after",
|
||||||
"2016-11-01T10:00:00+0000"))
|
"2016-11-01T10:00:00+0000"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string(
|
.andExpect(content().string(
|
||||||
|
@ -113,7 +113,7 @@ public class AuditEventsMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeFilterByPrincipalAndDateAfterAndType() throws Exception {
|
public void invokeFilterByPrincipalAndDateAfterAndType() throws Exception {
|
||||||
this.mvc.perform(get("/auditevents").param("principal", "admin")
|
this.mvc.perform(get("/application/auditevents").param("principal", "admin")
|
||||||
.param("after", "2016-11-01T10:00:00+0000").param("type", "logout"))
|
.param("after", "2016-11-01T10:00:00+0000").param("type", "logout"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string(
|
.andExpect(content().string(
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class EnvironmentMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void homeContentTypeDefaultsToActuatorV2Json() throws Exception {
|
public void homeContentTypeDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(get("/env")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/env")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
}
|
}
|
||||||
|
@ -88,21 +88,21 @@ public class EnvironmentMvcEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
public void homeContentTypeCanBeApplicationJson() throws Exception {
|
public void homeContentTypeCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(
|
this.mvc.perform(
|
||||||
get("/env").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
|
get("/application/env").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
|
||||||
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
|
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subContentTypeDefaultsToActuatorV2Json() throws Exception {
|
public void subContentTypeDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(get("/env/foo")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/env/foo")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subContentTypeCanBeApplicationJson() throws Exception {
|
public void subContentTypeCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(get("/env/foo").header(HttpHeaders.ACCEPT,
|
this.mvc.perform(get("/application/env/foo").header(HttpHeaders.ACCEPT,
|
||||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
@ -110,20 +110,20 @@ public class EnvironmentMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void home() throws Exception {
|
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")));
|
.andExpect(content().string(containsString("systemProperties")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sub() throws Exception {
|
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\"}"));
|
.andExpect(content().string("{\"foo\":\"bar\"}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subWhenDisabled() throws Exception {
|
public void subWhenDisabled() throws Exception {
|
||||||
this.context.getBean(EnvironmentEndpoint.class).setEnabled(false);
|
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
|
@Test
|
||||||
|
@ -132,7 +132,7 @@ public class EnvironmentMvcEndpointTests {
|
||||||
map.put("food", null);
|
map.put("food", null);
|
||||||
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
|
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
|
||||||
.addFirst(new MapPropertySource("null-value", map));
|
.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("\"foo\":\"bar\"")))
|
||||||
.andExpect(content().string(containsString("\"fool\":\"baz\"")));
|
.andExpect(content().string(containsString("\"fool\":\"baz\"")));
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class EnvironmentMvcEndpointTests {
|
||||||
map.put("my.foo", "${my.bar}");
|
map.put("my.foo", "${my.bar}");
|
||||||
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
|
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
|
||||||
.addFirst(new MapPropertySource("unresolved-placeholder", map));
|
.addFirst(new MapPropertySource("unresolved-placeholder", map));
|
||||||
this.mvc.perform(get("/env/my.*")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/env/my.*")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("\"my.foo\":\"${my.bar}\"")));
|
.andExpect(content().string(containsString("\"my.foo\":\"${my.bar}\"")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public class EnvironmentMvcEndpointTests {
|
||||||
map.put("my.password", "hello");
|
map.put("my.password", "hello");
|
||||||
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
|
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
|
||||||
.addFirst(new MapPropertySource("placeholder", map));
|
.addFirst(new MapPropertySource("placeholder", map));
|
||||||
this.mvc.perform(get("/env/my.*")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/env/my.*")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("\"my.foo\":\"******\"")));
|
.andExpect(content().string(containsString("\"my.foo\":\"******\"")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,16 +61,16 @@ public class HalBrowserMvcEndpointBrowserPathIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requestWithTrailingSlashIsRedirectedToBrowserHtml() throws Exception {
|
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(
|
.andExpect(status().isFound()).andExpect(header().string(
|
||||||
HttpHeaders.LOCATION, "http://localhost/actuator/browser.html"));
|
HttpHeaders.LOCATION, "http://localhost/application/actuator/browser.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void requestWithoutTrailingSlashIsRedirectedToBrowserHtml() throws Exception {
|
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",
|
.andExpect(status().isFound()).andExpect(header().string("location",
|
||||||
"http://localhost/actuator/browser.html"));
|
"http://localhost/application/actuator/browser.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@MinimalActuatorHypermediaApplication
|
@MinimalActuatorHypermediaApplication
|
||||||
|
|
|
@ -67,26 +67,26 @@ public class HalBrowserMvcEndpointDisabledIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void linksOnActuator() throws Exception {
|
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(status().isOk()).andExpect(jsonPath("$._links").exists())
|
||||||
.andExpect(header().doesNotExist("cache-control"));
|
.andExpect(header().doesNotExist("cache-control"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void browserRedirect() throws Exception {
|
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(
|
.andExpect(status().isFound()).andExpect(header().string(
|
||||||
HttpHeaders.LOCATION, "http://localhost/actuator/browser.html"));
|
HttpHeaders.LOCATION, "http://localhost/application/browser.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void endpointsDoNotHaveLinks() throws Exception {
|
public void endpointsDoNotHaveLinks() throws Exception {
|
||||||
for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
|
for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
|
||||||
String path = endpoint.getPath();
|
String path = endpoint.getPath();
|
||||||
if ("/actuator".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) {
|
if ("".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
path = path.length() > 0 ? path : "/";
|
path = "/application" + (path.length() > 0 ? path : "/");
|
||||||
MockHttpServletRequestBuilder requestBuilder = get(path);
|
MockHttpServletRequestBuilder requestBuilder = get(path);
|
||||||
if (endpoint instanceof AuditEventsMvcEndpoint) {
|
if (endpoint instanceof AuditEventsMvcEndpoint) {
|
||||||
requestBuilder.param("after", "2016-01-01T12:00:00+00:00");
|
requestBuilder.param("after", "2016-01-01T12:00:00+00:00");
|
||||||
|
|
|
@ -74,11 +74,11 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
||||||
assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create(
|
assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create(
|
||||||
"http://localhost:" + this.port + "/spring/actuator/browser.html"));
|
"http://localhost:" + this.port + "/spring/application/browser.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -86,10 +86,10 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("entryPoint: '/spring/actuator'");
|
assertThat(entity.getBody()).contains("entryPoint: '/spring/application'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -97,7 +97,7 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"_links\":");
|
assertThat(entity.getBody()).contains("\"_links\":");
|
||||||
|
@ -108,7 +108,7 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"_links\":");
|
assertThat(entity.getBody()).contains("\"_links\":");
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class HalBrowserMvcEndpointServerPortIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
||||||
"http://localhost:" + this.port + "/actuator", HttpMethod.GET,
|
"http://localhost:" + this.port + "/application", HttpMethod.GET,
|
||||||
new HttpEntity<Void>(null, headers), String.class);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"_links\":");
|
assertThat(entity.getBody()).contains("\"_links\":");
|
||||||
|
@ -75,7 +75,7 @@ public class HalBrowserMvcEndpointServerPortIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
||||||
"http://localhost:" + this.port + "/actuator/", HttpMethod.GET,
|
"http://localhost:" + this.port + "/application/", HttpMethod.GET,
|
||||||
new HttpEntity<Void>(null, headers), String.class);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"_links\":");
|
assertThat(entity.getBody()).contains("\"_links\":");
|
||||||
|
@ -87,11 +87,11 @@ public class HalBrowserMvcEndpointServerPortIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
||||||
"http://localhost:" + this.port + "/actuator/", HttpMethod.GET,
|
"http://localhost:" + this.port + "/application/", HttpMethod.GET,
|
||||||
new HttpEntity<Void>(null, headers), String.class);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
||||||
assertThat(entity.getHeaders().getLocation()).isEqualTo(
|
assertThat(entity.getHeaders().getLocation()).isEqualTo(
|
||||||
URI.create("http://localhost:" + this.port + "/actuator/browser.html"));
|
URI.create("http://localhost:" + this.port + "/application/browser.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@MinimalActuatorHypermediaApplication
|
@MinimalActuatorHypermediaApplication
|
||||||
|
|
|
@ -74,11 +74,11 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND);
|
||||||
assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create(
|
assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create(
|
||||||
"http://localhost:" + this.port + "/spring/actuator/browser.html"));
|
"http://localhost:" + this.port + "/spring/application/browser.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -86,10 +86,10 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
HttpMethod.GET, new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("entryPoint: '/spring/actuator'");
|
assertThat(entity.getBody()).contains("entryPoint: '/spring/application'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -97,7 +97,7 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"_links\":");
|
assertThat(entity.getBody()).contains("\"_links\":");
|
||||||
|
@ -108,7 +108,7 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().exchange(
|
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);
|
new HttpEntity<Void>(null, headers), String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"_links\":");
|
assertThat(entity.getBody()).contains("\"_links\":");
|
||||||
|
|
|
@ -70,35 +70,35 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void links() throws Exception {
|
public void links() 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(status().isOk()).andExpect(jsonPath("$._links").exists())
|
||||||
.andExpect(header().doesNotExist("cache-control"));
|
.andExpect(header().doesNotExist("cache-control"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void linksWithTrailingSlash() throws Exception {
|
public void linksWithTrailingSlash() 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(status().isOk()).andExpect(jsonPath("$._links").exists())
|
||||||
.andExpect(header().doesNotExist("cache-control"));
|
.andExpect(header().doesNotExist("cache-control"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void browser() throws Exception {
|
public void browser() 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(
|
.andExpect(status().isFound()).andExpect(header().string(
|
||||||
HttpHeaders.LOCATION, "http://localhost/actuator/browser.html"));
|
HttpHeaders.LOCATION, "http://localhost/application/browser.html"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void trace() throws Exception {
|
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(status().isOk()).andExpect(jsonPath("$._links").doesNotExist())
|
||||||
.andExpect(jsonPath("$").isArray());
|
.andExpect(jsonPath("$").isArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void envValue() throws Exception {
|
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(status().isOk())
|
||||||
.andExpect(jsonPath("$._links").doesNotExist());
|
.andExpect(jsonPath("$._links").doesNotExist());
|
||||||
}
|
}
|
||||||
|
@ -107,11 +107,11 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests {
|
||||||
public void endpointsAllListed() throws Exception {
|
public void endpointsAllListed() throws Exception {
|
||||||
for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
|
for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
|
||||||
String path = endpoint.getPath();
|
String path = endpoint.getPath();
|
||||||
if ("/actuator".equals(path)) {
|
if ("/application".equals(path)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
path = path.startsWith("/") ? path.substring(1) : path;
|
path = path.startsWith("/") ? path.substring(1) : path;
|
||||||
this.mockMvc.perform(get("/actuator").accept(MediaType.APPLICATION_JSON))
|
this.mockMvc.perform(get("/application").accept(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$._links.%s.href", path).exists());
|
.andExpect(jsonPath("$._links.%s.href", path).exists());
|
||||||
}
|
}
|
||||||
|
@ -126,10 +126,10 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests {
|
||||||
if (collections.contains(path)) {
|
if (collections.contains(path)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
path = path.length() > 0 ? path : "/";
|
path = "/application" + (path.length() > 0 ? path : "/");
|
||||||
this.mockMvc.perform(get(path).accept(MediaType.APPLICATION_JSON))
|
this.mockMvc.perform(get(path).accept(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().isOk()).andExpect(jsonPath("$._links.self.href")
|
.andExpect(status().isOk()).andExpect(jsonPath("$._links.self.href")
|
||||||
.value("http://localhost" + endpoint.getPath()));
|
.value("http://localhost/application" + endpoint.getPath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2012-2016 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.mvc;
|
||||||
|
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link HalJsonMvcEndpoint}.
|
||||||
|
*
|
||||||
|
* @author Madhura Bhave
|
||||||
|
*/
|
||||||
|
public class HalJsonMvcEndpointTests {
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
ManagementServletContext managementServletContext;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void halJsonEndpointPathWhenManagementContextPathPresent() throws Exception {
|
||||||
|
Mockito.when(this.managementServletContext.getContextPath()).thenReturn("my-app");
|
||||||
|
HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(this.managementServletContext);
|
||||||
|
assertThat(endpoint.getPath()).isEqualTo("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void halJsonEndpointPathWhenManagementContextPathNotPresent() throws Exception {
|
||||||
|
Mockito.when(this.managementServletContext.getContextPath()).thenReturn("");
|
||||||
|
HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(this.managementServletContext);
|
||||||
|
assertThat(endpoint.getPath()).isEqualTo("/application");
|
||||||
|
}
|
||||||
|
}
|
|
@ -73,7 +73,7 @@ public class HeapdumpMvcEndpointSecureOptionsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeOptionsShouldReturnSize() throws Exception {
|
public void invokeOptionsShouldReturnSize() throws Exception {
|
||||||
this.mvc.perform(options("/heapdump")).andExpect(status().isOk());
|
this.mvc.perform(options("/application/heapdump")).andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Import({ JacksonAutoConfiguration.class,
|
@Import({ JacksonAutoConfiguration.class,
|
||||||
|
|
|
@ -82,26 +82,26 @@ public class HeapdumpMvcEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception {
|
public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception {
|
||||||
this.endpoint.setEnabled(false);
|
this.endpoint.setEnabled(false);
|
||||||
this.mvc.perform(get("/heapdump")).andExpect(status().isNotFound());
|
this.mvc.perform(get("/application/heapdump")).andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeWhenNotAvailableShouldReturnServiceUnavailableStatus()
|
public void invokeWhenNotAvailableShouldReturnServiceUnavailableStatus()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
this.endpoint.setAvailable(false);
|
this.endpoint.setAvailable(false);
|
||||||
this.mvc.perform(get("/heapdump")).andExpect(status().isServiceUnavailable());
|
this.mvc.perform(get("/application/heapdump")).andExpect(status().isServiceUnavailable());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeWhenLockedShouldReturnTooManyRequestsStatus() throws Exception {
|
public void invokeWhenLockedShouldReturnTooManyRequestsStatus() throws Exception {
|
||||||
this.endpoint.setLocked(true);
|
this.endpoint.setLocked(true);
|
||||||
this.mvc.perform(get("/heapdump")).andExpect(status().isTooManyRequests());
|
this.mvc.perform(get("/application/heapdump")).andExpect(status().isTooManyRequests());
|
||||||
assertThat(Thread.interrupted()).isTrue();
|
assertThat(Thread.interrupted()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeShouldReturnGzipContent() throws Exception {
|
public void invokeShouldReturnGzipContent() throws Exception {
|
||||||
MvcResult result = this.mvc.perform(get("/heapdump")).andExpect(status().isOk())
|
MvcResult result = this.mvc.perform(get("/application/heapdump")).andExpect(status().isOk())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
byte[] bytes = result.getResponse().getContentAsByteArray();
|
byte[] bytes = result.getResponse().getContentAsByteArray();
|
||||||
GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(bytes));
|
GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(bytes));
|
||||||
|
@ -111,7 +111,7 @@ public class HeapdumpMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void invokeOptionsShouldReturnSize() throws Exception {
|
public void invokeOptionsShouldReturnSize() throws Exception {
|
||||||
this.mvc.perform(options("/heapdump")).andExpect(status().isOk());
|
this.mvc.perform(options("/application/heapdump")).andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Import({ JacksonAutoConfiguration.class, AuditAutoConfiguration.class,
|
@Import({ JacksonAutoConfiguration.class, AuditAutoConfiguration.class,
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class InfoMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void home() throws Exception {
|
public void home() throws Exception {
|
||||||
this.mvc.perform(get("/info")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/info")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString(
|
.andExpect(content().string(containsString(
|
||||||
"\"beanName1\":{\"key11\":\"value11\",\"key12\":\"value12\"}")))
|
"\"beanName1\":{\"key11\":\"value11\",\"key12\":\"value12\"}")))
|
||||||
.andExpect(content().string(containsString(
|
.andExpect(content().string(containsString(
|
||||||
|
@ -84,7 +84,7 @@ public class InfoMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
|
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(get("/info")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/info")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ public class InfoMvcEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeCanBeApplicationJson() throws Exception {
|
public void contentTypeCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(
|
this.mvc.perform(
|
||||||
get("/info").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
|
get("/application/info").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
|
||||||
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
|
.andExpect(status().isOk()).andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class InfoMvcEndpointWithNoInfoContributorsTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void home() throws Exception {
|
public void home() throws Exception {
|
||||||
this.mvc.perform(get("/info")).andExpect(status().isOk());
|
this.mvc.perform(get("/application/info")).andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Import({ JacksonAutoConfiguration.class, AuditAutoConfiguration.class,
|
@Import({ JacksonAutoConfiguration.class, AuditAutoConfiguration.class,
|
||||||
|
|
|
@ -79,20 +79,20 @@ public class JolokiaMvcEndpointIntegrationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void search() throws Exception {
|
public void search() throws Exception {
|
||||||
this.mvc.perform(get("/jolokia/search/java.lang:*")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/jolokia/search/java.lang:*")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("GarbageCollector")));
|
.andExpect(content().string(containsString("GarbageCollector")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void read() throws Exception {
|
public void read() throws Exception {
|
||||||
this.mvc.perform(get("/jolokia/read/java.lang:type=Memory"))
|
this.mvc.perform(get("/application/jolokia/read/java.lang:type=Memory"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("NonHeapMemoryUsage")));
|
.andExpect(content().string(containsString("NonHeapMemoryUsage")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void list() throws Exception {
|
public void list() throws Exception {
|
||||||
this.mvc.perform(get("/jolokia/list/java.lang/type=Memory/attr"))
|
this.mvc.perform(get("/application/jolokia/list/java.lang/type=Memory/attr"))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("NonHeapMemoryUsage")));
|
.andExpect(content().string(containsString("NonHeapMemoryUsage")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,21 +99,21 @@ public class LoggersMvcEndpointTests {
|
||||||
.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
|
.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
|
||||||
String expected = "{\"levels\":[\"OFF\",\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],"
|
String expected = "{\"levels\":[\"OFF\",\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"],"
|
||||||
+ "\"loggers\":{\"ROOT\":{\"configuredLevel\":null,\"effectiveLevel\":\"DEBUG\"}}}";
|
+ "\"loggers\":{\"ROOT\":{\"configuredLevel\":null,\"effectiveLevel\":\"DEBUG\"}}}";
|
||||||
this.mvc.perform(get("/loggers")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/loggers")).andExpect(status().isOk())
|
||||||
.andExpect(content().json(expected));
|
.andExpect(content().json(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getLoggersWhenDisabledShouldReturnNotFound() throws Exception {
|
public void getLoggersWhenDisabledShouldReturnNotFound() throws Exception {
|
||||||
this.context.getBean(LoggersEndpoint.class).setEnabled(false);
|
this.context.getBean(LoggersEndpoint.class).setEnabled(false);
|
||||||
this.mvc.perform(get("/loggers")).andExpect(status().isNotFound());
|
this.mvc.perform(get("/application/loggers")).andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getLoggerShouldReturnLogLevels() throws Exception {
|
public void getLoggerShouldReturnLogLevels() throws Exception {
|
||||||
given(this.loggingSystem.getLoggerConfiguration("ROOT"))
|
given(this.loggingSystem.getLoggerConfiguration("ROOT"))
|
||||||
.willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG));
|
.willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG));
|
||||||
this.mvc.perform(get("/loggers/ROOT")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/loggers/ROOT")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(equalTo(
|
.andExpect(content().string(equalTo(
|
||||||
"{\"configuredLevel\":null," + "\"effectiveLevel\":\"DEBUG\"}")));
|
"{\"configuredLevel\":null," + "\"effectiveLevel\":\"DEBUG\"}")));
|
||||||
}
|
}
|
||||||
|
@ -121,25 +121,25 @@ public class LoggersMvcEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
public void getLoggersRootWhenDisabledShouldReturnNotFound() throws Exception {
|
public void getLoggersRootWhenDisabledShouldReturnNotFound() throws Exception {
|
||||||
this.context.getBean(LoggersEndpoint.class).setEnabled(false);
|
this.context.getBean(LoggersEndpoint.class).setEnabled(false);
|
||||||
this.mvc.perform(get("/loggers/ROOT")).andExpect(status().isNotFound());
|
this.mvc.perform(get("/application/loggers/ROOT")).andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getLoggersWhenLoggerNotFoundShouldReturnNotFound() throws Exception {
|
public void getLoggersWhenLoggerNotFoundShouldReturnNotFound() throws Exception {
|
||||||
this.mvc.perform(get("/loggers/com.does.not.exist"))
|
this.mvc.perform(get("/application/loggers/com.does.not.exist"))
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeForGetDefaultsToActuatorV2Json() throws Exception {
|
public void contentTypeForGetDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(get("/loggers")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/loggers")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeForGetCanBeApplicationJson() throws Exception {
|
public void contentTypeForGetCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(get("/loggers").header(HttpHeaders.ACCEPT,
|
this.mvc.perform(get("/application/loggers").header(HttpHeaders.ACCEPT,
|
||||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
@ -147,14 +147,14 @@ public class LoggersMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setLoggerUsingApplicationJsonShouldSetLogLevel() throws Exception {
|
public void setLoggerUsingApplicationJsonShouldSetLogLevel() throws Exception {
|
||||||
this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
this.mvc.perform(post("/application/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
||||||
.content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk());
|
.content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk());
|
||||||
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception {
|
public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception {
|
||||||
this.mvc.perform(post("/loggers/ROOT")
|
this.mvc.perform(post("/application/loggers/ROOT")
|
||||||
.contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)
|
.contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)
|
||||||
.content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk());
|
.content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk());
|
||||||
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
||||||
|
@ -163,7 +163,7 @@ public class LoggersMvcEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
public void setLoggerWhenDisabledShouldReturnNotFound() throws Exception {
|
public void setLoggerWhenDisabledShouldReturnNotFound() throws Exception {
|
||||||
this.context.getBean(LoggersEndpoint.class).setEnabled(false);
|
this.context.getBean(LoggersEndpoint.class).setEnabled(false);
|
||||||
this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
this.mvc.perform(post("/application/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
||||||
.content("{\"configuredLevel\":\"DEBUG\"}"))
|
.content("{\"configuredLevel\":\"DEBUG\"}"))
|
||||||
.andExpect(status().isNotFound());
|
.andExpect(status().isNotFound());
|
||||||
verifyZeroInteractions(this.loggingSystem);
|
verifyZeroInteractions(this.loggingSystem);
|
||||||
|
@ -171,7 +171,7 @@ public class LoggersMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void setLoggerWithWrongLogLevel() throws Exception {
|
public void setLoggerWithWrongLogLevel() throws Exception {
|
||||||
this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
this.mvc.perform(post("/application/loggers/ROOT").contentType(MediaType.APPLICATION_JSON)
|
||||||
.content("{\"configuredLevel\":\"other\"}"))
|
.content("{\"configuredLevel\":\"other\"}"))
|
||||||
.andExpect(status().is4xxClientError());
|
.andExpect(status().is4xxClientError());
|
||||||
verifyZeroInteractions(this.loggingSystem);
|
verifyZeroInteractions(this.loggingSystem);
|
||||||
|
|
|
@ -78,20 +78,20 @@ public class MetricsMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void home() throws Exception {
|
public void home() throws Exception {
|
||||||
this.mvc.perform(get("/metrics")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("\"foo\":1")));
|
.andExpect(content().string(containsString("\"foo\":1")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void homeContentTypeDefaultsToActuatorV2Json() throws Exception {
|
public void homeContentTypeDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(get("/metrics")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void homeContentTypeCanBeApplicationJson() throws Exception {
|
public void homeContentTypeCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(get("/metrics").header(HttpHeaders.ACCEPT,
|
this.mvc.perform(get("/application/metrics").header(HttpHeaders.ACCEPT,
|
||||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
@ -99,14 +99,14 @@ public class MetricsMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificMetricContentTypeDefaultsToActuatorV2Json() throws Exception {
|
public void specificMetricContentTypeDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(get("/metrics/foo")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics/foo")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificMetricContentTypeCanBeApplicationJson() throws Exception {
|
public void specificMetricContentTypeCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(get("/metrics/foo").header(HttpHeaders.ACCEPT,
|
this.mvc.perform(get("/application/metrics/foo").header(HttpHeaders.ACCEPT,
|
||||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
@ -115,50 +115,50 @@ public class MetricsMvcEndpointTests {
|
||||||
@Test
|
@Test
|
||||||
public void homeWhenDisabled() throws Exception {
|
public void homeWhenDisabled() throws Exception {
|
||||||
this.context.getBean(MetricsEndpoint.class).setEnabled(false);
|
this.context.getBean(MetricsEndpoint.class).setEnabled(false);
|
||||||
this.mvc.perform(get("/metrics")).andExpect(status().isNotFound());
|
this.mvc.perform(get("/application/metrics")).andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificMetric() throws Exception {
|
public void specificMetric() throws Exception {
|
||||||
this.mvc.perform(get("/metrics/foo")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics/foo")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(equalTo("{\"foo\":1}")));
|
.andExpect(content().string(equalTo("{\"foo\":1}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificMetricWhenDisabled() throws Exception {
|
public void specificMetricWhenDisabled() throws Exception {
|
||||||
this.context.getBean(MetricsEndpoint.class).setEnabled(false);
|
this.context.getBean(MetricsEndpoint.class).setEnabled(false);
|
||||||
this.mvc.perform(get("/metrics/foo")).andExpect(status().isNotFound());
|
this.mvc.perform(get("/application/metrics/foo")).andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificMetricThatDoesNotExist() throws Exception {
|
public void specificMetricThatDoesNotExist() throws Exception {
|
||||||
this.mvc.perform(get("/metrics/bar")).andExpect(status().isNotFound());
|
this.mvc.perform(get("/application/metrics/bar")).andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void regexAll() throws Exception {
|
public void regexAll() throws Exception {
|
||||||
String expected = "\"foo\":1,\"group1.a\":1,\"group1.b\":1,\"group2.a\":1,\"group2_a\":1";
|
String expected = "\"foo\":1,\"group1.a\":1,\"group1.b\":1,\"group2.a\":1,\"group2_a\":1";
|
||||||
this.mvc.perform(get("/metrics/.*")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics/.*")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString(expected)));
|
.andExpect(content().string(containsString(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void regexGroupDot() throws Exception {
|
public void regexGroupDot() throws Exception {
|
||||||
String expected = "\"group1.a\":1,\"group1.b\":1,\"group2.a\":1";
|
String expected = "\"group1.a\":1,\"group1.b\":1,\"group2.a\":1";
|
||||||
this.mvc.perform(get("/metrics/group[0-9]+\\..*")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics/group[0-9]+\\..*")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString(expected)));
|
.andExpect(content().string(containsString(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void regexGroup1() throws Exception {
|
public void regexGroup1() throws Exception {
|
||||||
String expected = "\"group1.a\":1,\"group1.b\":1";
|
String expected = "\"group1.a\":1,\"group1.b\":1";
|
||||||
this.mvc.perform(get("/metrics/group1\\..*")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics/group1\\..*")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString(expected)));
|
.andExpect(content().string(containsString(expected)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void specificMetricWithDot() throws Exception {
|
public void specificMetricWithDot() throws Exception {
|
||||||
this.mvc.perform(get("/metrics/group2.a")).andExpect(status().isOk())
|
this.mvc.perform(get("/application/metrics/group2.a")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("1")));
|
.andExpect(content().string(containsString("1")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
@Test
|
@Test
|
||||||
public void corsIsDisabledByDefault() throws Exception {
|
public void corsIsDisabledByDefault() throws Exception {
|
||||||
createMockMvc()
|
createMockMvc()
|
||||||
.perform(options("/beans").header("Origin", "foo.example.com")
|
.perform(options("/application/beans").header("Origin", "foo.example.com")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
||||||
.andExpect(
|
.andExpect(
|
||||||
header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
|
header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
|
||||||
|
@ -73,7 +73,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"endpoints.cors.allowed-origins:foo.example.com");
|
"endpoints.cors.allowed-origins:foo.example.com");
|
||||||
createMockMvc()
|
createMockMvc()
|
||||||
.perform(options("/beans").header("Origin", "bar.example.com")
|
.perform(options("/application/beans").header("Origin", "bar.example.com")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
performAcceptedCorsRequest();
|
performAcceptedCorsRequest();
|
||||||
|
@ -101,7 +101,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"endpoints.cors.allowed-origins:foo.example.com");
|
"endpoints.cors.allowed-origins:foo.example.com");
|
||||||
createMockMvc()
|
createMockMvc()
|
||||||
.perform(options("/beans").header("Origin", "foo.example.com")
|
.perform(options("/application/beans").header("Origin", "foo.example.com")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Alpha"))
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Alpha"))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
|
@ -113,7 +113,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
"endpoints.cors.allowed-origins:foo.example.com",
|
"endpoints.cors.allowed-origins:foo.example.com",
|
||||||
"endpoints.cors.allowed-headers:Alpha,Bravo");
|
"endpoints.cors.allowed-headers:Alpha,Bravo");
|
||||||
createMockMvc()
|
createMockMvc()
|
||||||
.perform(options("/beans").header("Origin", "foo.example.com")
|
.perform(options("/application/beans").header("Origin", "foo.example.com")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Alpha"))
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Alpha"))
|
||||||
.andExpect(status().isOk()).andExpect(header()
|
.andExpect(status().isOk()).andExpect(header()
|
||||||
|
@ -125,7 +125,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"endpoints.cors.allowed-origins:foo.example.com");
|
"endpoints.cors.allowed-origins:foo.example.com");
|
||||||
createMockMvc()
|
createMockMvc()
|
||||||
.perform(options("/health").header(HttpHeaders.ORIGIN, "foo.example.com")
|
.perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PATCH"))
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PATCH"))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
"endpoints.cors.allowed-origins:foo.example.com",
|
"endpoints.cors.allowed-origins:foo.example.com",
|
||||||
"endpoints.cors.allowed-methods:GET,HEAD");
|
"endpoints.cors.allowed-methods:GET,HEAD");
|
||||||
createMockMvc()
|
createMockMvc()
|
||||||
.perform(options("/health").header(HttpHeaders.ORIGIN, "foo.example.com")
|
.perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "HEAD"))
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "HEAD"))
|
||||||
.andExpect(status().isOk()).andExpect(header()
|
.andExpect(status().isOk()).andExpect(header()
|
||||||
.string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET,HEAD"));
|
.string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET,HEAD"));
|
||||||
|
@ -165,10 +165,10 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"endpoints.cors.allowed-origins:foo.example.com");
|
"endpoints.cors.allowed-origins:foo.example.com");
|
||||||
createMockMvc()
|
createMockMvc()
|
||||||
.perform(options("/jolokia").header("Origin", "bar.example.com")
|
.perform(options("/application/jolokia").header("Origin", "bar.example.com")
|
||||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"))
|
||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
performAcceptedCorsRequest("/jolokia");
|
performAcceptedCorsRequest("/application/jolokia");
|
||||||
}
|
}
|
||||||
|
|
||||||
private MockMvc createMockMvc() {
|
private MockMvc createMockMvc() {
|
||||||
|
@ -177,7 +177,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultActions performAcceptedCorsRequest() throws Exception {
|
private ResultActions performAcceptedCorsRequest() throws Exception {
|
||||||
return performAcceptedCorsRequest("/beans");
|
return performAcceptedCorsRequest("/application/beans");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultActions performAcceptedCorsRequest(String url) throws Exception {
|
private ResultActions performAcceptedCorsRequest(String url) throws Exception {
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class MvcEndpointIntegrationTests {
|
||||||
this.context = new AnnotationConfigWebApplicationContext();
|
this.context = new AnnotationConfigWebApplicationContext();
|
||||||
this.context.register(SecureConfiguration.class);
|
this.context.register(SecureConfiguration.class);
|
||||||
MockMvc mockMvc = createSecureMockMvc();
|
MockMvc mockMvc = createSecureMockMvc();
|
||||||
mockMvc.perform(get("/mappings")).andExpect(content().string(startsWith("{\"")));
|
mockMvc.perform(get("/application/mappings")).andExpect(content().string(startsWith("{\"")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -97,7 +97,7 @@ public class MvcEndpointIntegrationTests {
|
||||||
this.context = new AnnotationConfigWebApplicationContext();
|
this.context = new AnnotationConfigWebApplicationContext();
|
||||||
this.context.register(DefaultConfiguration.class);
|
this.context.register(DefaultConfiguration.class);
|
||||||
MockMvc mockMvc = createMockMvc();
|
MockMvc mockMvc = createMockMvc();
|
||||||
mockMvc.perform(get("/beans.cmd")).andExpect(status().isNotFound());
|
mockMvc.perform(get("/application/beans.cmd")).andExpect(status().isNotFound());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -107,7 +107,7 @@ public class MvcEndpointIntegrationTests {
|
||||||
this.context = new AnnotationConfigWebApplicationContext();
|
this.context = new AnnotationConfigWebApplicationContext();
|
||||||
this.context.register(SecureConfiguration.class);
|
this.context.register(SecureConfiguration.class);
|
||||||
MockMvc mockMvc = createSecureMockMvc();
|
MockMvc mockMvc = createSecureMockMvc();
|
||||||
mockMvc.perform(get("/beans.json")).andExpect(status().isOk());
|
mockMvc.perform(get("/application/beans.json")).andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -115,8 +115,8 @@ public class MvcEndpointIntegrationTests {
|
||||||
this.context = new AnnotationConfigWebApplicationContext();
|
this.context = new AnnotationConfigWebApplicationContext();
|
||||||
this.context.register(SecureConfiguration.class);
|
this.context.register(SecureConfiguration.class);
|
||||||
MockMvc mockMvc = createSecureMockMvc();
|
MockMvc mockMvc = createSecureMockMvc();
|
||||||
mockMvc.perform(get("/info")).andExpect(status().isOk());
|
mockMvc.perform(get("/application/info")).andExpect(status().isOk());
|
||||||
mockMvc.perform(get("/actuator")).andExpect(status().isOk());
|
mockMvc.perform(get("/application")).andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -136,7 +136,7 @@ public class MvcEndpointIntegrationTests {
|
||||||
this.context = new AnnotationConfigWebApplicationContext();
|
this.context = new AnnotationConfigWebApplicationContext();
|
||||||
this.context.register(SecureConfiguration.class);
|
this.context.register(SecureConfiguration.class);
|
||||||
MockMvc mockMvc = createSecureMockMvc();
|
MockMvc mockMvc = createSecureMockMvc();
|
||||||
mockMvc.perform(get("/beans")).andExpect(status().isUnauthorized());
|
mockMvc.perform(get("/application/beans")).andExpect(status().isUnauthorized());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -194,7 +194,7 @@ public class MvcEndpointIntegrationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"management.security.enabled:false");
|
"management.security.enabled:false");
|
||||||
MockMvc mockMvc = createSecureMockMvc();
|
MockMvc mockMvc = createSecureMockMvc();
|
||||||
mockMvc.perform(get("/beans")).andExpect(status().isOk());
|
mockMvc.perform(get("/application/beans")).andExpect(status().isOk());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertIndentedJsonResponse(Class<?> configuration) throws Exception {
|
private void assertIndentedJsonResponse(Class<?> configuration) throws Exception {
|
||||||
|
@ -205,7 +205,7 @@ public class MvcEndpointIntegrationTests {
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.jackson.serialization.indent-output:true");
|
"spring.jackson.serialization.indent-output:true");
|
||||||
MockMvc mockMvc = createSecureMockMvc();
|
MockMvc mockMvc = createSecureMockMvc();
|
||||||
mockMvc.perform(get("/mappings"))
|
mockMvc.perform(get("/application/mappings"))
|
||||||
.andExpect(content().string(startsWith("{" + LINE_SEPARATOR)));
|
.andExpect(content().string(startsWith("{" + LINE_SEPARATOR)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
|
||||||
this.context.register(TestConfiguration.class);
|
this.context.register(TestConfiguration.class);
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||||
mockMvc.perform(get("/health").with(getRequestPostProcessor()))
|
mockMvc.perform(get("/application/health").with(getRequestPostProcessor()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string("{\"status\":\"UP\"}"));
|
.andExpect(content().string("{\"status\":\"UP\"}"));
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
|
||||||
"management.security.enabled:false");
|
"management.security.enabled:false");
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
|
||||||
mockMvc.perform(get("/health")).andExpect(status().isOk())
|
mockMvc.perform(get("/application/health")).andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString(
|
.andExpect(content().string(containsString(
|
||||||
"\"status\":\"UP\",\"test\":{\"status\":\"UP\",\"hello\":\"world\"}")));
|
"\"status\":\"UP\",\"test\":{\"status\":\"UP\",\"hello\":\"world\"}")));
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class ShutdownMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
|
public void contentTypeDefaultsToActuatorV2Json() throws Exception {
|
||||||
this.mvc.perform(post("/shutdown")).andExpect(status().isOk())
|
this.mvc.perform(post("/application/shutdown")).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
"application/vnd.spring-boot.actuator.v2+json;charset=UTF-8"));
|
||||||
assertThat(this.context.getBean(CountDownLatch.class).await(30, TimeUnit.SECONDS))
|
assertThat(this.context.getBean(CountDownLatch.class).await(30, TimeUnit.SECONDS))
|
||||||
|
@ -84,7 +84,7 @@ public class ShutdownMvcEndpointTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contentTypeCanBeApplicationJson() throws Exception {
|
public void contentTypeCanBeApplicationJson() throws Exception {
|
||||||
this.mvc.perform(post("/shutdown").header(HttpHeaders.ACCEPT,
|
this.mvc.perform(post("/application/shutdown").header(HttpHeaders.ACCEPT,
|
||||||
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk())
|
||||||
.andExpect(header().string("Content-Type",
|
.andExpect(header().string("Content-Type",
|
||||||
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
MediaType.APPLICATION_JSON_UTF8_VALUE));
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class SampleActuatorLog4J2ApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void validateLoggersEndpoint() throws Exception {
|
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(status().isOk())
|
||||||
.andExpect(content().string(equalTo("{\"configuredLevel\":\"WARN\","
|
.andExpect(content().string(equalTo("{\"configuredLevel\":\"WARN\","
|
||||||
+ "\"effectiveLevel\":\"WARN\"}")));
|
+ "\"effectiveLevel\":\"WARN\"}")));
|
||||||
|
|
|
@ -61,14 +61,14 @@ public class SampleActuatorUiApplicationPortTests {
|
||||||
public void testMetrics() throws Exception {
|
public void testMetrics() throws Exception {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
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);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHealth() throws Exception {
|
public void testHealth() throws Exception {
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
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.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
|
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class SampleActuatorUiApplicationTests {
|
||||||
@Test
|
@Test
|
||||||
public void testMetrics() throws Exception {
|
public void testMetrics() throws Exception {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics",
|
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/application/metrics",
|
||||||
Map.class);
|
Map.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class InsecureManagementSampleActuatorApplicationTests {
|
||||||
// ignore;
|
// ignore;
|
||||||
}
|
}
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/metrics",
|
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/application/metrics",
|
||||||
Map.class);
|
Map.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
|
@ -71,14 +71,14 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||||
testHome(); // makes sure some requests have been made
|
testHome(); // makes sure some requests have been made
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
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);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHealth() throws Exception {
|
public void testHealth() throws Exception {
|
||||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
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.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class NonSensitiveHealthTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSecureHealth() throws Exception {
|
public void testSecureHealth() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/health",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).doesNotContain("\"hello\":1");
|
assertThat(entity.getBody()).doesNotContain("\"hello\":1");
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class SampleActuatorApplicationTests {
|
||||||
testHome(); // makes sure some requests have been made
|
testHome(); // makes sure some requests have been made
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = this.restTemplate
|
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);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Object> body = entity.getBody();
|
Map<String, Object> body = entity.getBody();
|
||||||
|
@ -109,7 +109,7 @@ public class SampleActuatorApplicationTests {
|
||||||
public void testEnv() throws Exception {
|
public void testEnv() throws Exception {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = this.restTemplate
|
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);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Object> body = entity.getBody();
|
Map<String, Object> body = entity.getBody();
|
||||||
|
@ -118,7 +118,7 @@ public class SampleActuatorApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHealth() throws Exception {
|
public void testHealth() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/health",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/health",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||||
|
@ -129,14 +129,14 @@ public class SampleActuatorApplicationTests {
|
||||||
public void testSecureHealth() throws Exception {
|
public void testSecureHealth() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate
|
ResponseEntity<String> entity = this.restTemplate
|
||||||
.withBasicAuth("user", getPassword())
|
.withBasicAuth("user", getPassword())
|
||||||
.getForEntity("/health", String.class);
|
.getForEntity("/application/health", String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"hello\":1");
|
assertThat(entity.getBody()).contains("\"hello\":1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInfo() throws Exception {
|
public void testInfo() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/info",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/info",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody())
|
assertThat(entity.getBody())
|
||||||
|
@ -176,7 +176,7 @@ public class SampleActuatorApplicationTests {
|
||||||
this.restTemplate.getForEntity("/health", String.class);
|
this.restTemplate.getForEntity("/health", String.class);
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<List> entity = this.restTemplate
|
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);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Map<String, Object>> list = entity.getBody();
|
List<Map<String, Object>> list = entity.getBody();
|
||||||
|
@ -189,10 +189,10 @@ public class SampleActuatorApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void traceWithParameterMap() throws Exception {
|
public void traceWithParameterMap() throws Exception {
|
||||||
this.restTemplate.getForEntity("/health?param1=value1", String.class);
|
this.restTemplate.getForEntity("/application/health?param1=value1", String.class);
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<List> entity = this.restTemplate
|
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);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Map<String, Object>> list = entity.getBody();
|
List<Map<String, Object>> list = entity.getBody();
|
||||||
|
@ -219,7 +219,7 @@ public class SampleActuatorApplicationTests {
|
||||||
public void testBeans() throws Exception {
|
public void testBeans() throws Exception {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<List> entity = this.restTemplate
|
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.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).hasSize(1);
|
assertThat(entity.getBody()).hasSize(1);
|
||||||
Map<String, Object> body = (Map<String, Object>) entity.getBody().get(0);
|
Map<String, Object> body = (Map<String, Object>) entity.getBody().get(0);
|
||||||
|
@ -231,7 +231,7 @@ public class SampleActuatorApplicationTests {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = this.restTemplate
|
ResponseEntity<Map> entity = this.restTemplate
|
||||||
.withBasicAuth("user", getPassword())
|
.withBasicAuth("user", getPassword())
|
||||||
.getForEntity("/configprops", Map.class);
|
.getForEntity("/application/configprops", Map.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Object> body = entity.getBody();
|
Map<String, Object> body = entity.getBody();
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ServletPathInsecureSampleActuatorApplicationTests {
|
||||||
@Test
|
@Test
|
||||||
public void testMetricsIsSecure() throws Exception {
|
public void testMetricsIsSecure() throws Exception {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/metrics",
|
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring//application/metrics",
|
||||||
Map.class);
|
Map.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ServletPathSampleActuatorApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHealth() throws Exception {
|
public void testHealth() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/spring/health",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/spring//application/health",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ShutdownSampleActuatorApplicationTests {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ResponseEntity<Map> entity = this.restTemplate
|
ResponseEntity<Map> entity = this.restTemplate
|
||||||
.withBasicAuth("user", getPassword())
|
.withBasicAuth("user", getPassword())
|
||||||
.postForEntity("/shutdown", null, Map.class);
|
.postForEntity("/application/shutdown", null, Map.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Map<String, Object> body = entity.getBody();
|
Map<String, Object> body = entity.getBody();
|
||||||
|
|
|
@ -50,22 +50,22 @@ public class SampleHypermediaGsonApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void health() throws Exception {
|
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(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());
|
.andExpect(jsonPath("$.content.status").exists());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void trace() throws Exception {
|
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(status().isOk()).andExpect(jsonPath("$.links").doesNotExist())
|
||||||
.andExpect(jsonPath("$").isArray());
|
.andExpect(jsonPath("$").isArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void envValue() throws Exception {
|
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(status().isOk())
|
||||||
.andExpect(jsonPath("$._links").doesNotExist());
|
.andExpect(jsonPath("$._links").doesNotExist());
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,16 +38,16 @@ public class SampleHypermediaUiSecureApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void links() {
|
public void links() {
|
||||||
String response = this.restTemplate.getForObject("/actuator", String.class);
|
String response = this.restTemplate.getForObject("/application", String.class);
|
||||||
assertThat(response).contains("\"_links\":");
|
assertThat(response).contains("\"_links\":");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsecureNestedPath() throws Exception {
|
public void testInsecureNestedPath() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/env",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/env",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
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);
|
String.class);
|
||||||
assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
assertThat(user.getBody()).contains("{\"foo\":");
|
assertThat(user.getBody()).contains("{\"foo\":");
|
||||||
|
@ -55,7 +55,7 @@ public class SampleHypermediaUiSecureApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSecurePath() throws Exception {
|
public void testSecurePath() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/metrics",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/metrics",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class SampleHypermediaUiApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void links() {
|
public void links() {
|
||||||
String response = this.restTemplate.getForObject("/actuator", String.class);
|
String response = this.restTemplate.getForObject("/application", String.class);
|
||||||
assertThat(response).contains("\"_links\":");
|
assertThat(response).contains("\"_links\":");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class SampleHypermediaUiApplicationTests {
|
||||||
public void linksWithJson() throws Exception {
|
public void linksWithJson() throws Exception {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
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);
|
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
|
||||||
assertThat(response.getBody()).contains("\"_links\":");
|
assertThat(response.getBody()).contains("\"_links\":");
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class SampleHypermediaApplicationHomePageTests {
|
||||||
public void linksWithJson() throws Exception {
|
public void linksWithJson() throws Exception {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
|
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);
|
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
|
||||||
assertThat(response.getBody()).contains("\"_links\":");
|
assertThat(response.getBody()).contains("\"_links\":");
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class SampleHypermediaApplicationHomePageTests {
|
||||||
public void halWithHtml() throws Exception {
|
public void halWithHtml() throws Exception {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
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);
|
HttpMethod.GET, new HttpEntity<Void>(headers), String.class);
|
||||||
assertThat(response.getBody()).contains("HAL Browser");
|
assertThat(response.getBody()).contains("HAL Browser");
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,19 +70,19 @@ public class SampleSecureOAuth2ActuatorApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void healthAvailable() throws Exception {
|
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
|
@Test
|
||||||
public void envSecuredWithBasic() throws Exception {
|
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")))
|
.andExpect(header().string("WWW-Authenticate", containsString("Basic")))
|
||||||
.andDo(print());
|
.andDo(print());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void envWithPassword() throws Exception {
|
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())))
|
"Basic " + Base64Utils.encodeToString("user:password".getBytes())))
|
||||||
.andExpect(status().isOk()).andDo(print());
|
.andExpect(status().isOk()).andDo(print());
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class SampleMethodSecurityApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testManagementProtected() throws Exception {
|
public void testManagementProtected() throws Exception {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/beans",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/beans",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class SampleMethodSecurityApplicationTests {
|
||||||
"admin", "admin");
|
"admin", "admin");
|
||||||
this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor);
|
this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor);
|
||||||
try {
|
try {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/beans",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/beans",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class SampleMethodSecurityApplicationTests {
|
||||||
"user", "user");
|
"user", "user");
|
||||||
this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor);
|
this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor);
|
||||||
try {
|
try {
|
||||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/beans",
|
ResponseEntity<String> entity = this.restTemplate.getForEntity("/application/beans",
|
||||||
String.class);
|
String.class);
|
||||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue