Adapt to trailing slashes no longer being matched by default
See gh-31563
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2022 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.
|
||||
@@ -118,6 +118,9 @@ abstract class AbstractSampleActuatorCustomSecurityTests {
|
||||
ResponseEntity<Object> entity = adminRestTemplate().getForEntity(getManagementPath() + "/actuator/env",
|
||||
Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
entity = adminRestTemplate().getForEntity(getManagementPath() + "/actuator/env/", Object.class);
|
||||
// EndpointRequest matches the trailing slash but MVC doesn't
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
|
||||
entity = adminRestTemplate().getForEntity(
|
||||
getManagementPath() + "/actuator/env/management.endpoints.web.exposure.include", Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
|
||||
@@ -76,7 +76,7 @@ class SampleActuatorCustomSecurityApplicationTests extends AbstractSampleActuato
|
||||
Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
entity = beansRestTemplate().getForEntity(getManagementPath() + "/actuator/beans/", Object.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author HaiTao Zhang
|
||||
*/
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.endpoints.web.base-path=/", "management.server.port=0" })
|
||||
properties = { "management.endpoints.web.base-path=/", "management.server.port=0",
|
||||
"logging.level.org.springframework.web=trace" })
|
||||
class ManagementDifferentPortSampleActuatorApplicationTests {
|
||||
|
||||
@LocalManagementPort
|
||||
@@ -42,7 +43,7 @@ class ManagementDifferentPortSampleActuatorApplicationTests {
|
||||
@Test
|
||||
void linksEndpointShouldBeAvailable() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate("user", "password")
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/", String.class);
|
||||
.getForEntity("http://localhost:" + this.managementPort, String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(entity.getBody()).contains("\"_links\"");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user