SkipPatternConfiguration will reuse management.server.base-path property (#1883)
fixes gh-1880
This commit is contained in:
committed by
GitHub
parent
7fa4538dfc
commit
e8c0c5eaba
@@ -24,6 +24,7 @@ import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ConditionalOnManagementPort;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementPortType;
|
||||
@@ -211,9 +212,14 @@ class SkipPatternConfiguration {
|
||||
@ConditionalOnProperty(name = "management.server.servlet.context-path", havingValue = "/",
|
||||
matchIfMissing = true)
|
||||
SingleSkipPattern skipPatternForActuatorEndpointsDifferentPort(Environment environment,
|
||||
final ServerProperties serverProperties, final WebEndpointProperties webEndpointProperties,
|
||||
final WebEndpointProperties webEndpointProperties,
|
||||
ObjectProvider<ManagementServerProperties> managementServerProperties,
|
||||
final EndpointsSupplier<ExposableWebEndpoint> endpointsSupplier) {
|
||||
return () -> getEndpointsPatterns(environment, null, webEndpointProperties, endpointsSupplier);
|
||||
return () -> {
|
||||
ManagementServerProperties props = managementServerProperties.getIfAvailable();
|
||||
return getEndpointsPatterns(environment, props != null ? props.getBasePath() : null,
|
||||
webEndpointProperties, endpointsSupplier);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -212,6 +212,20 @@ public class SkipPatternProviderConfigTest {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_endpoints_with_base_path_when_management_port_is_different() {
|
||||
contextRunner
|
||||
.withConfiguration(
|
||||
UserConfigurations.of(ServerPropertiesConfig.class, ManagementServerPropertiesConfig.class))
|
||||
.withPropertyValues("management.server.base-path=/foo", "management.endpoints.web.base-path=/actuator",
|
||||
"management.server.port=0")
|
||||
.run(context -> {
|
||||
BDDAssertions.then(extractAllPatterns(context)).containsExactlyInAnyOrder(
|
||||
"/foo/actuator(/|/(health|health/.*|info|info/.*))?",
|
||||
SleuthWebProperties.DEFAULT_SKIP_PATTERN);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void should_return_endpoints_with_context_path_and_base_path_set_to_root_different_port_with_placeholder() {
|
||||
contextRunner.withConfiguration(UserConfigurations.of(ServerPropertiesConfig.class))
|
||||
@@ -313,6 +327,12 @@ public class SkipPatternProviderConfigTest {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(ManagementServerProperties.class)
|
||||
static class ManagementServerPropertiesConfig {
|
||||
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
static class EmptyEndpoints {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user