Add property to configure base-path for web endpoints.

Also, move properties corresponding to management server under
`management.server.*`.

Closes gh-10230
This commit is contained in:
Madhura Bhave
2017-10-16 15:05:32 -07:00
parent 68db43cf44
commit d307eba0a3
29 changed files with 184 additions and 96 deletions

View File

@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0", "management.context-path=/admin" })
"management.server.port=0", "management.server.context-path=/management"})
@DirtiesContext
public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
@@ -60,7 +60,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
@Test
public void testSecureActuator() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/health",
"http://localhost:" + this.managementPort + "/management/application/health",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
@@ -68,7 +68,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
@Test
public void testInsecureActuator() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
"http://localhost:" + this.managementPort + "/admin/status",
"http://localhost:" + this.managementPort + "/management/application/status",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
@@ -78,7 +78,7 @@ public class InsecureManagementPortAndPathSampleActuatorApplicationTests {
public void testMissing() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate("admin", "admin")
.getForEntity(
"http://localhost:" + this.managementPort + "/admin/missing",
"http://localhost:" + this.managementPort + "/management/application/missing",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(entity.getBody()).contains("\"status\":404");

View File

@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port:0" })
"management.server.port:0" })
@DirtiesContext
public class SampleActuatorUiApplicationPortTests {

View File

@@ -2,7 +2,7 @@ service.name=Phil
# logging.file=/tmp/logs/app.log
# logging.level.org.springframework.security=DEBUG
management.address=127.0.0.1
management.server.address=127.0.0.1
endpoints.default.web.enabled=true
endpoints.shutdown.enabled=true

View File

@@ -40,8 +40,8 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0", "management.address=127.0.0.1",
"management.context-path:/admin" })
"management.server.port=0", "management.server.address=127.0.0.1",
"management.server.context-path:/admin" })
@DirtiesContext
public class ManagementAddressActuatorApplicationTests {
@@ -63,7 +63,7 @@ public class ManagementAddressActuatorApplicationTests {
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate()
.withBasicAuth("user", getPassword())
.getForEntity("http://localhost:" + this.managementPort + "/admin/health",
.getForEntity("http://localhost:" + this.managementPort + "/admin/application/health",
String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");

View File

@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.context_path=/admin" })
"management.endpoints.web.base-path=/admin" })
@DirtiesContext
public class ManagementPathSampleActuatorApplicationTests {

View File

@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0", "management.context-path=/admin" })
"management.server.port=0", "management.endpoints.web.base-path=/admin" })
@DirtiesContext
public class ManagementPortAndPathSampleActuatorApplicationTests {

View File

@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=0" })
"management.server.port=0" })
@DirtiesContext
public class ManagementPortSampleActuatorApplicationTests {

View File

@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"management.port=-1" })
"management.server.port=-1" })
@DirtiesContext
public class NoManagementSampleActuatorApplicationTests {

View File

@@ -1,2 +1,2 @@
server.error.path: /oops
management.context-path: /admin
management.endpoints.web.base-path: /admin