From e9136e023ba282b4b8994c40d953307fedfb2c80 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 7 Jul 2022 14:14:05 +0100 Subject: [PATCH] Adapt to trailing slashes no longer being matched by default See gh-31563 --- .../security/reactive/EndpointRequest.java | 6 +++-- .../reactive/EndpointRequestTests.java | 24 ++++++++++++++++++- ...stractEndpointRequestIntegrationTests.java | 2 +- .../MvcEndpointRequestIntegrationTests.java | 4 ++-- ...AbstractWebFluxEndpointHandlerMapping.java | 3 ++- .../AbstractWebMvcEndpointHandlerMapping.java | 8 ++++--- .../AbstractWebEndpointIntegrationTests.java | 6 ++--- .../DefaultWebMvcTagsProviderTests.java | 18 ++++++++++++++ .../web/servlet/WebMvcMetricsFilterTests.java | 14 ++++++++++- ...ractSampleActuatorCustomSecurityTests.java | 5 +++- ...ctuatorCustomSecurityApplicationTests.java | 2 +- ...entPortSampleActuatorApplicationTests.java | 5 ++-- 12 files changed, 79 insertions(+), 18 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java index 7b8cbc0e7d..8698e00133 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java @@ -217,7 +217,7 @@ public final class EndpointRequest { streamPaths(this.excludes, pathMappedEndpoints).forEach(paths::remove); List delegateMatchers = getDelegateMatchers(paths); if (this.includeLinks && StringUtils.hasText(pathMappedEndpoints.getBasePath())) { - delegateMatchers.add(new PathPatternParserServerWebExchangeMatcher(pathMappedEndpoints.getBasePath())); + delegateMatchers.add(new LinksServerWebExchangeMatcher()); } return new OrServerWebExchangeMatcher(delegateMatchers); } @@ -275,7 +275,9 @@ public final class EndpointRequest { private ServerWebExchangeMatcher createDelegate(WebEndpointProperties properties) { if (StringUtils.hasText(properties.getBasePath())) { - return new PathPatternParserServerWebExchangeMatcher(properties.getBasePath()); + return new OrServerWebExchangeMatcher( + new PathPatternParserServerWebExchangeMatcher(properties.getBasePath()), + new PathPatternParserServerWebExchangeMatcher(properties.getBasePath() + "/")); } return EMPTY_MATCHER; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java index bcc85a8d7c..efb69f0c33 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 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. @@ -88,24 +88,28 @@ class EndpointRequestTests { void toEndpointClassShouldMatchEndpointPath() { ServerWebExchangeMatcher matcher = EndpointRequest.to(FooEndpoint.class); assertMatcher(matcher).matches("/actuator/foo"); + assertMatcher(matcher).matches("/actuator/foo/"); } @Test void toEndpointClassShouldNotMatchOtherPath() { ServerWebExchangeMatcher matcher = EndpointRequest.to(FooEndpoint.class); assertMatcher(matcher).doesNotMatch("/actuator/bar"); + assertMatcher(matcher).doesNotMatch("/actuator/bar/"); } @Test void toEndpointIdShouldMatchEndpointPath() { ServerWebExchangeMatcher matcher = EndpointRequest.to("foo"); assertMatcher(matcher).matches("/actuator/foo"); + assertMatcher(matcher).matches("/actuator/foo/"); } @Test void toEndpointIdShouldNotMatchOtherPath() { ServerWebExchangeMatcher matcher = EndpointRequest.to("foo"); assertMatcher(matcher).doesNotMatch("/actuator/bar"); + assertMatcher(matcher).doesNotMatch("/actuator/bar/"); } @Test @@ -136,9 +140,13 @@ class EndpointRequestTests { endpoints.add(mockEndpoint(EndpointId.of("baz"), "baz")); PathMappedEndpoints pathMappedEndpoints = new PathMappedEndpoints("/actuator", () -> endpoints); assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo"); + assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/foo/"); assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz"); + assertMatcher(matcher, pathMappedEndpoints).doesNotMatch("/actuator/baz/"); assertMatcher(matcher).matches("/actuator/bar"); + assertMatcher(matcher).matches("/actuator/bar/"); assertMatcher(matcher).matches("/actuator"); + assertMatcher(matcher).matches("/actuator/"); } @Test @@ -146,30 +154,40 @@ class EndpointRequestTests { ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excludingLinks() .excluding(FooEndpoint.class); assertMatcher(matcher).doesNotMatch("/actuator/foo"); + assertMatcher(matcher).doesNotMatch("/actuator/foo/"); assertMatcher(matcher).doesNotMatch("/actuator"); + assertMatcher(matcher).doesNotMatch("/actuator/"); } @Test void excludeByIdShouldNotMatchExcluded() { ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excluding("foo"); assertMatcher(matcher).doesNotMatch("/actuator/foo"); + assertMatcher(matcher).doesNotMatch("/actuator/foo/"); assertMatcher(matcher).matches("/actuator/bar"); + assertMatcher(matcher).matches("/actuator/bar/"); assertMatcher(matcher).matches("/actuator"); + assertMatcher(matcher).matches("/actuator/"); } @Test void excludeByIdShouldNotMatchLinksIfExcluded() { ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excludingLinks().excluding("foo"); assertMatcher(matcher).doesNotMatch("/actuator/foo"); + assertMatcher(matcher).doesNotMatch("/actuator/foo/"); assertMatcher(matcher).doesNotMatch("/actuator"); + assertMatcher(matcher).doesNotMatch("/actuator/"); } @Test void excludeLinksShouldNotMatchBasePath() { ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint().excludingLinks(); assertMatcher(matcher).doesNotMatch("/actuator"); + assertMatcher(matcher).doesNotMatch("/actuator/"); assertMatcher(matcher).matches("/actuator/foo"); + assertMatcher(matcher).matches("/actuator/foo/"); assertMatcher(matcher).matches("/actuator/bar"); + assertMatcher(matcher).matches("/actuator/bar/"); } @Test @@ -178,14 +196,18 @@ class EndpointRequestTests { RequestMatcherAssert assertMatcher = assertMatcher(matcher, ""); assertMatcher.doesNotMatch("/"); assertMatcher.matches("/foo"); + assertMatcher.matches("/foo/"); assertMatcher.matches("/bar"); + assertMatcher.matches("/bar/"); } @Test void noEndpointPathsBeansShouldNeverMatch() { ServerWebExchangeMatcher matcher = EndpointRequest.toAnyEndpoint(); assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/foo"); + assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/foo/"); assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar"); + assertMatcher(matcher, (PathMappedEndpoints) null).doesNotMatch("/actuator/bar/"); } private RequestMatcherAssert assertMatcher(ServerWebExchangeMatcher matcher) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java index 7f40bc7dde..afa72a9d1f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java @@ -76,7 +76,7 @@ abstract class AbstractEndpointRequestIntegrationTests { getContextRunner().run((context) -> { WebTestClient webTestClient = getWebTestClient(context); webTestClient.get().uri("/actuator").exchange().expectStatus().isOk(); - webTestClient.get().uri("/actuator/").exchange().expectStatus().isOk(); + webTestClient.get().uri("/actuator/").exchange().expectStatus().isNotFound(); }); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/MvcEndpointRequestIntegrationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/MvcEndpointRequestIntegrationTests.java index 86722ba93d..eb16e1a558 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/MvcEndpointRequestIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/MvcEndpointRequestIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 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. @@ -42,7 +42,7 @@ class MvcEndpointRequestIntegrationTests extends AbstractEndpointRequestIntegrat void toLinksWhenServletPathSetShouldMatch() { getContextRunner().withPropertyValues("spring.mvc.servlet.path=/admin").run((context) -> { WebTestClient webTestClient = getWebTestClient(context); - webTestClient.get().uri("/admin/actuator/").exchange().expectStatus().isOk(); + webTestClient.get().uri("/admin/actuator/").exchange().expectStatus().isNotFound(); webTestClient.get().uri("/admin/actuator").exchange().expectStatus().isOk(); }); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java index 3975d3419c..1c0e1ab180 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java @@ -180,8 +180,9 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi private void registerLinksMapping() { String path = this.endpointMapping.getPath(); + String linksPath = StringUtils.hasLength(path) ? path : "/"; String[] produces = StringUtils.toStringArray(this.endpointMediaTypes.getProduced()); - RequestMappingInfo mapping = RequestMappingInfo.paths(path).methods(RequestMethod.GET).produces(produces) + RequestMappingInfo mapping = RequestMappingInfo.paths(linksPath).methods(RequestMethod.GET).produces(produces) .build(); LinksHandler linksHandler = getLinksHandler(); registerMapping(mapping, linksHandler, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java index 54714b8d28..7797ec244b 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java @@ -240,9 +240,11 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin } private void registerLinksMapping() { - RequestMappingInfo mapping = RequestMappingInfo.paths(this.endpointMapping.createSubPath("")) - .methods(RequestMethod.GET).produces(this.endpointMediaTypes.getProduced().toArray(new String[0])) - .options(this.builderConfig).build(); + String path = this.endpointMapping.getPath(); + String linksPath = (StringUtils.hasLength(path)) ? this.endpointMapping.createSubPath("/") : "/"; + RequestMappingInfo mapping = RequestMappingInfo.paths(linksPath).methods(RequestMethod.GET) + .produces(this.endpointMediaTypes.getProduced().toArray(new String[0])).options(this.builderConfig) + .build(); LinksHandler linksHandler = getLinksHandler(); registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links", HttpServletRequest.class, HttpServletResponse.class)); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java index 5520e248f1..6f1a5abb26 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java @@ -123,9 +123,9 @@ public abstract class AbstractWebEndpointIntegrationTests client.get().uri("/test/").exchange().expectStatus().isOk() - .expectBody().jsonPath("All").isEqualTo(true)); + void operationWithTrailingSlashShouldNotMatch() { + load(TestEndpointConfiguration.class, + (client) -> client.get().uri("/test/").exchange().expectStatus().isNotFound()); } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java index 556cde9e9d..b0505c4ee5 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/DefaultWebMvcTagsProviderTests.java @@ -30,6 +30,8 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.actuate.metrics.web.servlet.DefaultWebMvcTagsProvider; import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsContributor; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.web.servlet.HandlerMapping; import static org.assertj.core.api.Assertions.assertThat; @@ -69,6 +71,22 @@ class DefaultWebMvcTagsProviderTests { assertThat(tags).containsOnlyKeys("method", "uri", "alpha", "bravo", "charlie"); } + @Test + void trailingSlashIsIncludedByDefault() { + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/the/uri/"); + request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "{one}/{two}/"); + Map tags = asMap(new DefaultWebMvcTagsProvider().getTags(request, null, null, null)); + assertThat(tags.get("uri").getValue()).isEqualTo("{one}/{two}/"); + } + + @Test + void trailingSlashCanBeIgnored() { + MockHttpServletRequest request = new MockHttpServletRequest("GET", "/the/uri/"); + request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE, "{one}/{two}/"); + Map tags = asMap(new DefaultWebMvcTagsProvider(true).getTags(request, null, null, null)); + assertThat(tags.get("uri").getValue()).isEqualTo("{one}/{two}"); + } + private Map asMap(Iterable tags) { return StreamSupport.stream(tags.spliterator(), false) .collect(Collectors.toMap(Tag::getKey, Function.identity())); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java index 76e230c990..654520d220 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcMetricsFilterTests.java @@ -77,7 +77,10 @@ import org.springframework.web.context.WebApplicationContext; import org.springframework.web.filter.OncePerRequestFilter; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; +import org.springframework.web.util.pattern.PathPatternParser; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; @@ -312,6 +315,7 @@ class WebMvcMetricsFilterTests { @Test void trailingSlashShouldNotRecordDuplicateMetrics() throws Exception { + this.mvc.perform(get("/api/c1/simple/10")).andExpect(status().isOk()); this.mvc.perform(get("/api/c1/simple/10/")).andExpect(status().isOk()); assertThat(this.registry.get("http.server.requests").tags("status", "200", "uri", "/api/c1/simple/{id}").timer() @@ -328,7 +332,7 @@ class WebMvcMetricsFilterTests { @Configuration(proxyBeanMethods = false) @EnableWebMvc @Import({ Controller1.class, Controller2.class }) - static class MetricsFilterApp { + static class MetricsFilterApp implements WebMvcConfigurer { @Bean Clock micrometerClock() { @@ -393,6 +397,14 @@ class WebMvcMetricsFilterTests { return new FaultyWebMvcTagsProvider(); } + @Override + @SuppressWarnings("deprecation") + public void configurePathMatch(PathMatchConfigurer configurer) { + PathPatternParser pathPatternParser = new PathPatternParser(); + pathPatternParser.setMatchOptionalTrailingSeparator(true); + configurer.setPatternParser(pathPatternParser); + } + } @RestController diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java index 94e7773945..c1798d51c7 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/AbstractSampleActuatorCustomSecurityTests.java @@ -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 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); diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java index 221c7daab8..110f017085 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/src/test/java/smoketest/actuator/customsecurity/SampleActuatorCustomSecurityApplicationTests.java @@ -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); } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java index 9e3b73ac51..b1c10e88a4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/src/test/java/smoketest/actuator/ManagementDifferentPortSampleActuatorApplicationTests.java @@ -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 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\""); }