Introduce "server.servlet" configuration prefix
This commit refactors the `ServerProperties` property keys and introduces a separate "server.servlet" namespace to isolate servlet-specific properties from the rest. Closes gh-8066
This commit is contained in:
@@ -337,7 +337,7 @@ public class ManagementWebSecurityAutoConfiguration {
|
||||
String path = management.getContextPath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
AntPathRequestMatcher matcher = new AntPathRequestMatcher(
|
||||
server.getPath(path) + "/**");
|
||||
server.getServlet().getPath(path) + "/**");
|
||||
return matcher;
|
||||
}
|
||||
// Match everything, including the sensitive and non-sensitive paths
|
||||
@@ -364,7 +364,7 @@ public class ManagementWebSecurityAutoConfiguration {
|
||||
List<RequestMatcher> matchers = new ArrayList<RequestMatcher>();
|
||||
EndpointHandlerMapping endpointHandlerMapping = getRequiredEndpointHandlerMapping();
|
||||
for (String path : this.endpointPaths.getPaths(endpointHandlerMapping)) {
|
||||
matchers.add(new AntPathRequestMatcher(server.getPath(path)));
|
||||
matchers.add(new AntPathRequestMatcher(server.getServlet().getPath(path)));
|
||||
}
|
||||
return (matchers.isEmpty() ? MATCH_NONE : new OrRequestMatcher(matchers));
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class BootCuriesHrefIntegrationTests {
|
||||
@Test
|
||||
public void curiesHrefWithCustomContextPath() {
|
||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||
"server.context-path:/context");
|
||||
"server.servlet.context-path:/context");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/context/actuator"))
|
||||
.isEqualTo("http://localhost:" + port
|
||||
+ "/context/docs/#spring_boot_actuator__{rel}");
|
||||
@@ -65,7 +65,7 @@ public class BootCuriesHrefIntegrationTests {
|
||||
@Test
|
||||
public void curiesHrefWithCustomServletPath() {
|
||||
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"))
|
||||
.isEqualTo("http://localhost:" + port
|
||||
+ "/servlet/docs/#spring_boot_actuator__{rel}");
|
||||
@@ -74,7 +74,7 @@ public class BootCuriesHrefIntegrationTests {
|
||||
@Test
|
||||
public void curiesHrefWithCustomServletAndContextPaths() {
|
||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||
"server.context-path:/context", "server.servlet-path:/servlet");
|
||||
"server.servlet.context-path:/context", "server.servlet.path:/servlet");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/context/servlet/actuator"))
|
||||
.isEqualTo("http://localhost:" + port
|
||||
+ "/context/servlet/docs/#spring_boot_actuator__{rel}");
|
||||
@@ -83,7 +83,7 @@ public class BootCuriesHrefIntegrationTests {
|
||||
@Test
|
||||
public void curiesHrefWithCustomServletContextAndManagementContextPaths() {
|
||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||
"server.context-path:/context", "server.servlet-path:/servlet",
|
||||
"server.servlet.context-path:/context", "server.servlet.path:/servlet",
|
||||
"management.context-path:/management");
|
||||
assertThat(getCurieHref("http://localhost:" + port
|
||||
+ "/context/servlet/management/")).isEqualTo("http://localhost:" + port
|
||||
@@ -93,7 +93,7 @@ public class BootCuriesHrefIntegrationTests {
|
||||
@Test
|
||||
public void serverPathsAreIgnoredWithSeparateManagementPort() {
|
||||
int port = load("endpoints.docs.curies.enabled:true", "server.port:0",
|
||||
"server.context-path:/context", "server.servlet-path:/servlet",
|
||||
"server.servlet.context-path:/context", "server.servlet.path:/servlet",
|
||||
"management.port:0");
|
||||
assertThat(getCurieHref("http://localhost:" + port + "/actuator/")).isEqualTo(
|
||||
"http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}");
|
||||
|
||||
@@ -127,7 +127,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
||||
"management.context-path=",
|
||||
"management.security.enabled=false",
|
||||
"server.context-path=",
|
||||
"server.servlet.context-path=",
|
||||
"server.port=" + ports.get().server);
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ public class EndpointWebMvcAutoConfigurationTests {
|
||||
@Test
|
||||
public void onDifferentPortAndMainContext() throws Exception {
|
||||
EnvironmentTestUtils.addEnvironment(this.applicationContext,
|
||||
"server.context-path=/spring",
|
||||
"server.servlet.context-path=/spring",
|
||||
"management.port=" + ports.get().management,
|
||||
"management.context-path=/admin");
|
||||
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
|
||||
|
||||
@@ -51,7 +51,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"server.contextPath=/spring" })
|
||||
"server.servlet.contextPath=/spring" })
|
||||
@DirtiesContext
|
||||
public class HalBrowserMvcEndpointServerContextPathIntegrationTests {
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"server.servlet-path=/spring" })
|
||||
"server.servlet.path=/spring" })
|
||||
@DirtiesContext
|
||||
public class HalBrowserMvcEndpointServerServletPathIntegrationTests {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user