Merge branch '2.1.x'
Closes gh-17079
This commit is contained in:
@@ -45,8 +45,8 @@ class EndpointsPropertiesSampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testCustomErrorPath() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/oops", Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/oops",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
@@ -56,8 +56,7 @@ class EndpointsPropertiesSampleActuatorApplicationTests {
|
||||
|
||||
@Test
|
||||
void testCustomContextPath() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/admin/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
|
||||
@@ -35,9 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=0", "management.server.address=127.0.0.1",
|
||||
"management.server.servlet.context-path:/admin" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.server.port=0",
|
||||
"management.server.address=127.0.0.1", "management.server.servlet.context-path:/admin" })
|
||||
class ManagementAddressActuatorApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
@@ -49,16 +48,14 @@ class ManagementAddressActuatorApplicationTests {
|
||||
@Test
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate()
|
||||
.getForEntity("http://localhost:" + this.port, Map.class);
|
||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity("http://localhost:"
|
||||
+ this.managementPort + "/admin/actuator/health", String.class);
|
||||
ResponseEntity<String> entity = new TestRestTemplate().withBasicAuth("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/admin/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@ class ManagementPathSampleActuatorApplicationTests {
|
||||
|
||||
@Test
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/admin/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
|
||||
@@ -37,10 +37,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=0",
|
||||
"management.endpoints.web.base-path=/admin",
|
||||
"management.endpoint.health.show-details=never" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.server.port=0",
|
||||
"management.endpoints.web.base-path=/admin", "management.endpoint.health.show-details=never" })
|
||||
class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
@@ -67,17 +65,15 @@ class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
void testMetrics() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/admin/metrics", Map.class);
|
||||
ResponseEntity<Map> entity = new TestRestTemplate()
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/admin/metrics", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/admin/health",
|
||||
String.class);
|
||||
ResponseEntity<String> entity = new TestRestTemplate().withBasicAuth("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/admin/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}");
|
||||
}
|
||||
@@ -86,19 +82,15 @@ class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
void testEnvNotFound() {
|
||||
String unknownProperty = "test-does-not-exist";
|
||||
assertThat(this.environment.containsProperty(unknownProperty)).isFalse();
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity("http://localhost:"
|
||||
+ this.managementPort + "/admin/env/" + unknownProperty,
|
||||
String.class);
|
||||
ResponseEntity<String> entity = new TestRestTemplate().withBasicAuth("user", getPassword()).getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/admin/env/" + unknownProperty, String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMissing() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/admin/missing",
|
||||
String.class);
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/admin/missing", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
assertThat(entity.getBody()).contains("\"status\":404");
|
||||
}
|
||||
@@ -118,8 +110,7 @@ class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
void testManagementErrorPage() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/error",
|
||||
Map.class);
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/error", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
|
||||
@@ -35,8 +35,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"management.server.port=0", "management.endpoint.health.show-details=always" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=0", "management.endpoint.health.show-details=always" })
|
||||
class ManagementPortSampleActuatorApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
@@ -60,18 +60,15 @@ class ManagementPortSampleActuatorApplicationTests {
|
||||
void testMetrics() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/actuator/metrics",
|
||||
Map.class);
|
||||
ResponseEntity<Map> entity = new TestRestTemplate()
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/actuator/metrics", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/actuator/health",
|
||||
String.class);
|
||||
ResponseEntity<String> entity = new TestRestTemplate().withBasicAuth("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
assertThat(entity.getBody()).contains("\"example\"");
|
||||
@@ -82,8 +79,7 @@ class ManagementPortSampleActuatorApplicationTests {
|
||||
void testErrorPage() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/error",
|
||||
Map.class);
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/error", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
|
||||
@@ -32,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
|
||||
"management.server.port=0", "spring.main.lazy-initialization=true" })
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=0", "spring.main.lazy-initialization=true" })
|
||||
class ManagementPortWithLazyInitializationTests {
|
||||
|
||||
@LocalManagementPort
|
||||
@@ -41,10 +41,8 @@ class ManagementPortWithLazyInitializationTests {
|
||||
|
||||
@Test
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", "password").getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/actuator/health",
|
||||
String.class);
|
||||
ResponseEntity<String> entity = new TestRestTemplate().withBasicAuth("user", "password")
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=-1" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "management.server.port=-1" })
|
||||
class NoManagementSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -44,8 +43,8 @@ class NoManagementSampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
@@ -56,8 +55,8 @@ class NoManagementSampleActuatorApplicationTests {
|
||||
void testMetricsNotAvailable() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/metrics", Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/metrics",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,7 @@ class SampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testMetricsIsSecure() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/actuator/metrics",
|
||||
Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/actuator/metrics", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
entity = this.restTemplate.getForEntity("/actuator/metrics/", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
@@ -80,8 +79,8 @@ class SampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
@@ -93,8 +92,7 @@ class SampleActuatorApplicationTests {
|
||||
void testMetrics() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/actuator/metrics", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, Object> body = entity.getBody();
|
||||
@@ -106,8 +104,7 @@ class SampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testEnv() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/actuator/env", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -117,8 +114,7 @@ class SampleActuatorApplicationTests {
|
||||
|
||||
@Test
|
||||
void healthInsecureByDefault() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/health",
|
||||
String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
assertThat(entity.getBody()).doesNotContain("\"hello\":\"1\"");
|
||||
@@ -126,22 +122,18 @@ class SampleActuatorApplicationTests {
|
||||
|
||||
@Test
|
||||
void infoInsecureByDefault() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/info",
|
||||
String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/info", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody())
|
||||
.contains("\"artifact\":\"spring-boot-sample-actuator\"");
|
||||
assertThat(entity.getBody()).contains("\"artifact\":\"spring-boot-sample-actuator\"");
|
||||
assertThat(entity.getBody()).contains("\"someKey\":\"someValue\"");
|
||||
assertThat(entity.getBody()).contains("\"java\":{", "\"source\":\"1.8\"",
|
||||
"\"target\":\"1.8\"");
|
||||
assertThat(entity.getBody()).contains("\"encoding\":{", "\"source\":\"UTF-8\"",
|
||||
"\"reporting\":\"UTF-8\"");
|
||||
assertThat(entity.getBody()).contains("\"java\":{", "\"source\":\"1.8\"", "\"target\":\"1.8\"");
|
||||
assertThat(entity.getBody()).contains("\"encoding\":{", "\"source\":\"UTF-8\"", "\"reporting\":\"UTF-8\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrorPage() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/foo", String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/foo",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
String body = entity.getBody();
|
||||
assertThat(body).contains("\"error\":");
|
||||
@@ -152,9 +144,8 @@ class SampleActuatorApplicationTests {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||
HttpEntity<?> request = new HttpEntity<Void>(headers);
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.exchange("/foo", HttpMethod.GET, request, String.class);
|
||||
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword()).exchange("/foo",
|
||||
HttpMethod.GET, request, String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
String body = entity.getBody();
|
||||
assertThat(body).as("Body was null").isNotNull();
|
||||
@@ -164,8 +155,8 @@ class SampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testErrorPageDirectAccess() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/error", Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/error",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
@@ -177,8 +168,7 @@ class SampleActuatorApplicationTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testBeans() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/actuator/beans", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).containsOnlyKeys("contexts");
|
||||
@@ -188,17 +178,14 @@ class SampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testConfigProps() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/actuator/configprops", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
Map<String, Object> body = entity.getBody();
|
||||
Map<String, Object> contexts = (Map<String, Object>) body.get("contexts");
|
||||
Map<String, Object> context = (Map<String, Object>) contexts
|
||||
.get(this.applicationContext.getId());
|
||||
Map<String, Object> context = (Map<String, Object>) contexts.get(this.applicationContext.getId());
|
||||
Map<String, Object> beans = (Map<String, Object>) context.get("beans");
|
||||
assertThat(beans)
|
||||
.containsKey("spring.datasource-" + DataSourceProperties.class.getName());
|
||||
assertThat(beans).containsKey("spring.datasource-" + DataSourceProperties.class.getName());
|
||||
}
|
||||
|
||||
private String getPassword() {
|
||||
|
||||
@@ -34,8 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "spring.mvc.servlet.path=/spring" })
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "spring.mvc.servlet.path=/spring" })
|
||||
class ServletPathSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -44,8 +43,7 @@ class ServletPathSampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testErrorPath() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/spring/error", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -56,8 +54,7 @@ class ServletPathSampleActuatorApplicationTests {
|
||||
|
||||
@Test
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<String> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/spring/actuator/health", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
|
||||
@@ -66,8 +63,7 @@ class ServletPathSampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testHomeIsSecure() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/",
|
||||
Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
|
||||
@@ -38,10 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@SpringBootTest(
|
||||
classes = { ShutdownSampleActuatorApplicationTests.SecurityConfiguration.class,
|
||||
SampleActuatorApplication.class },
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@SpringBootTest(classes = { ShutdownSampleActuatorApplicationTests.SecurityConfiguration.class,
|
||||
SampleActuatorApplication.class }, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
class ShutdownSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
@@ -50,8 +48,8 @@ class ShutdownSampleActuatorApplicationTests {
|
||||
@Test
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword()).getForEntity("/",
|
||||
Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> body = entity.getBody();
|
||||
@@ -62,8 +60,7 @@ class ShutdownSampleActuatorApplicationTests {
|
||||
@DirtiesContext
|
||||
public void testShutdown() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
ResponseEntity<Map> entity = this.restTemplate.withBasicAuth("user", getPassword())
|
||||
.postForEntity("/actuator/shutdown", null, Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user