mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Rename default endpoint settings to "default"
Closes gh-10098
This commit is contained in:
parent
edd7cea1c3
commit
98455e30dc
@ -31,12 +31,12 @@ import org.springframework.context.annotation.Conditional;
|
||||
* according to the {@code enabledByDefault} flag {@code types} flag that the
|
||||
* {@link Endpoint} may be restricted to.
|
||||
* <p>
|
||||
* If no specific {@code endpoints.<id>.*} or {@code endpoints.all.*} properties are
|
||||
* If no specific {@code endpoints.<id>.*} or {@code endpoints.default.*} properties are
|
||||
* defined, the condition matches the {@code enabledByDefault} value regardless of the
|
||||
* specific {@link EndpointType}, if any. If any property are set, they are evaluated with
|
||||
* a sensible order of precedence.
|
||||
* <p>
|
||||
* For instance if {@code endpoints.all.enabled} is {@code false} but
|
||||
* For instance if {@code endpoints.default.enabled} is {@code false} but
|
||||
* {@code endpoints.<id>.enabled} is {@code true}, the condition will match.
|
||||
* <p>
|
||||
* This condition must be placed on a {@code @Bean} method producing an endpoint as its id
|
||||
|
@ -63,9 +63,9 @@ public class EndpointEnablementProvider {
|
||||
if (!StringUtils.hasText(endpointId)) {
|
||||
throw new IllegalArgumentException("Endpoint id must have a value");
|
||||
}
|
||||
if (endpointId.equals("all")) {
|
||||
throw new IllegalArgumentException("Endpoint id 'all' is a reserved value "
|
||||
+ "and cannot be used by an endpoint");
|
||||
if (endpointId.equals("default")) {
|
||||
throw new IllegalArgumentException("Endpoint id 'default' is a reserved "
|
||||
+ "value and cannot be used by an endpoint");
|
||||
}
|
||||
|
||||
if (endpointType != null) {
|
||||
@ -97,26 +97,26 @@ public class EndpointEnablementProvider {
|
||||
}
|
||||
|
||||
if (endpointType != null) {
|
||||
String globalTypeKey = createTechSpecificKey("all", endpointType);
|
||||
EndpointEnablement globalTypeOutcome = getEnablementFor(globalTypeKey);
|
||||
String defaultTypeKey = createTechSpecificKey("default", endpointType);
|
||||
EndpointEnablement globalTypeOutcome = getEnablementFor(defaultTypeKey);
|
||||
if (globalTypeOutcome != null) {
|
||||
return globalTypeOutcome;
|
||||
}
|
||||
if (!endpointType.isEnabledByDefault()) {
|
||||
return defaultEndpointEnablement("all", false, endpointType);
|
||||
return defaultEndpointEnablement("default", false, endpointType);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Check if there is a global tech required
|
||||
EndpointEnablement anyTechGeneralOutcome = getAnyTechSpecificOutcomeFor(
|
||||
"all");
|
||||
"default");
|
||||
if (anyTechGeneralOutcome != null) {
|
||||
return anyTechGeneralOutcome;
|
||||
}
|
||||
}
|
||||
|
||||
String globalKey = createKey("all", "enabled");
|
||||
EndpointEnablement globalOutCome = getEnablementFor(globalKey);
|
||||
String defaultKey = createKey("default", "enabled");
|
||||
EndpointEnablement globalOutCome = getEnablementFor(defaultKey);
|
||||
if (globalOutCome != null) {
|
||||
return globalOutCome;
|
||||
}
|
||||
|
@ -1,22 +1,4 @@
|
||||
{"properties": [
|
||||
{
|
||||
"name": "endpoints.all.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.all.jmx.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as JMX MBeans.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.all.web.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as Web endpoints.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "endpoints.configprops.keys-to-sanitize",
|
||||
"type": "java.lang.String[]",
|
||||
@ -31,6 +13,24 @@
|
||||
"vcap_services"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "endpoints.default.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints by default.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.default.jmx.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as JMX MBeans by default.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.default.web.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as Web endpoints by default.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "endpoints.env.keys-to-sanitize",
|
||||
"type": "java.lang.String[]",
|
||||
@ -458,7 +458,7 @@
|
||||
"description": "Enable endpoints.",
|
||||
"defaultValue": true,
|
||||
"deprecation": {
|
||||
"replacement": "endpoints.all.enabled",
|
||||
"replacement": "endpoints.default.enabled",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
@ -623,7 +623,7 @@
|
||||
"description": "Enable JMX export of all endpoints.",
|
||||
"defaultValue": true,
|
||||
"deprecation": {
|
||||
"replacement": "endpoints.all.jmx.enabled",
|
||||
"replacement": "endpoints.default.jmx.enabled",
|
||||
"level": "error"
|
||||
}
|
||||
},
|
||||
|
@ -54,14 +54,14 @@ public class ConditionalOnEnabledEndpointTests {
|
||||
@Test
|
||||
public void disabledViaGeneralProperty() {
|
||||
this.contextRunner.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false")
|
||||
.withPropertyValues("endpoints.default.enabled=false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enabledOverrideViaSpecificProperty() {
|
||||
this.contextRunner.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false",
|
||||
.withPropertyValues("endpoints.default.enabled=false",
|
||||
"endpoints.foo.enabled=true")
|
||||
.run((context) -> assertThat(context).hasBean("foo"));
|
||||
}
|
||||
@ -94,34 +94,34 @@ public class ConditionalOnEnabledEndpointTests {
|
||||
@Test
|
||||
public void enabledOverrideViaGeneralWebProperty() {
|
||||
this.contextRunner.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false",
|
||||
"endpoints.all.web.enabled=true")
|
||||
.withPropertyValues("endpoints.default.enabled=false",
|
||||
"endpoints.default.web.enabled=true")
|
||||
.run((context) -> assertThat(context).hasBean("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enabledOverrideViaGeneralJmxProperty() {
|
||||
this.contextRunner.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false",
|
||||
"endpoints.all.jmx.enabled=true")
|
||||
.withPropertyValues("endpoints.default.enabled=false",
|
||||
"endpoints.default.jmx.enabled=true")
|
||||
.run((context) -> assertThat(context).hasBean("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enabledOverrideViaGeneralAnyProperty() {
|
||||
this.contextRunner.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false",
|
||||
"endpoints.all.web.enabled=false",
|
||||
"endpoints.all.jmx.enabled=true")
|
||||
.withPropertyValues("endpoints.default.enabled=false",
|
||||
"endpoints.default.web.enabled=false",
|
||||
"endpoints.default.jmx.enabled=true")
|
||||
.run((context) -> assertThat(context).hasBean("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disabledEvenWithEnabledGeneralProperties() {
|
||||
this.contextRunner.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=true",
|
||||
"endpoints.all.web.enabled=true",
|
||||
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=false")
|
||||
.withPropertyValues("endpoints.default.enabled=true",
|
||||
"endpoints.default.web.enabled=true",
|
||||
"endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
|
||||
}
|
||||
|
||||
@ -134,21 +134,21 @@ public class ConditionalOnEnabledEndpointTests {
|
||||
@Test
|
||||
public void disabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() {
|
||||
this.contextRunner.withUserConfiguration(BarConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=true")
|
||||
.withPropertyValues("endpoints.default.enabled=true")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() {
|
||||
this.contextRunner.withUserConfiguration(BarConfig.class)
|
||||
.withPropertyValues("endpoints.all.web.enabled=true")
|
||||
.withPropertyValues("endpoints.default.web.enabled=true")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void disabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() {
|
||||
this.contextRunner.withUserConfiguration(BarConfig.class)
|
||||
.withPropertyValues("endpoints.all.jmx.enabled=true")
|
||||
.withPropertyValues("endpoints.default.jmx.enabled=true")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("bar"));
|
||||
}
|
||||
|
||||
@ -184,7 +184,7 @@ public class ConditionalOnEnabledEndpointTests {
|
||||
@Test
|
||||
public void enabledOnlyWebByDefault() {
|
||||
this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
|
||||
.withPropertyValues("endpoints.all.web.enabled=true")
|
||||
.withPropertyValues("endpoints.default.web.enabled=true")
|
||||
.run((context) -> assertThat(context).hasBean("onlyweb"));
|
||||
}
|
||||
|
||||
@ -205,15 +205,15 @@ public class ConditionalOnEnabledEndpointTests {
|
||||
@Test
|
||||
public void enableOverridesOnlyWebViaGeneralJmxPropertyHasNoEffect() {
|
||||
this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false",
|
||||
"endpoints.all.jmx.enabled=true")
|
||||
.withPropertyValues("endpoints.default.enabled=false",
|
||||
"endpoints.default.jmx.enabled=true")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("onlyweb"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enableOverridesOnlyWebViaSpecificJmxPropertyHasNoEffect() {
|
||||
this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false",
|
||||
.withPropertyValues("endpoints.default.enabled=false",
|
||||
"endpoints.onlyweb.jmx.enabled=false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("onlyweb"));
|
||||
}
|
||||
@ -221,7 +221,7 @@ public class ConditionalOnEnabledEndpointTests {
|
||||
@Test
|
||||
public void enableOverridesOnlyWebViaSpecificWebProperty() {
|
||||
this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
|
||||
.withPropertyValues("endpoints.all.enabled=false",
|
||||
.withPropertyValues("endpoints.default.enabled=false",
|
||||
"endpoints.onlyweb.web.enabled=true")
|
||||
.run((context) -> assertThat(context).hasBean("onlyweb"));
|
||||
}
|
||||
@ -229,7 +229,7 @@ public class ConditionalOnEnabledEndpointTests {
|
||||
@Test
|
||||
public void disabledOnlyWebEvenWithEnabledGeneralProperties() {
|
||||
this.contextRunner.withUserConfiguration(OnlyWebConfig.class).withPropertyValues(
|
||||
"endpoints.all.enabled=true", "endpoints.all.web.enabled=true",
|
||||
"endpoints.default.enabled=true", "endpoints.default.web.enabled=true",
|
||||
"endpoints.onlyweb.enabled=true", "endpoints.onlyweb.web.enabled=false")
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class JmxEndpointInfrastructureAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void jmxEndpointsCanBeDisabled() {
|
||||
this.contextRunner.withPropertyValues("endpoints.all.jmx.enabled:false")
|
||||
this.contextRunner.withPropertyValues("endpoints.default.jmx.enabled:false")
|
||||
.run((context) -> {
|
||||
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
|
||||
checkEndpointMBeans(mBeanServer, new String[0],
|
||||
@ -73,7 +73,7 @@ public class JmxEndpointInfrastructureAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void singleJmxEndpointCanBeEnabled() {
|
||||
this.contextRunner.withPropertyValues("endpoints.all.jmx.enabled=false",
|
||||
this.contextRunner.withPropertyValues("endpoints.default.jmx.enabled=false",
|
||||
"endpoints.beans.jmx.enabled=true").run((context) -> {
|
||||
MBeanServer mBeanServer = context.getBean(MBeanServer.class);
|
||||
checkEndpointMBeans(mBeanServer, new String[] { "beans" },
|
||||
|
@ -82,7 +82,7 @@ public class WebMvcEndpointInfrastructureAutoConfigurationTests {
|
||||
@Test
|
||||
public void webEndpointsCanBeEnabled() {
|
||||
WebApplicationContextRunner contextRunner = this.contextRunner
|
||||
.withPropertyValues("endpoints.all.web.enabled=true");
|
||||
.withPropertyValues("endpoints.default.web.enabled=true");
|
||||
contextRunner.run(context -> {
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
assertThat(isExposed(mockMvc, HttpMethod.GET, "/application/autoconfig"))
|
||||
@ -111,7 +111,7 @@ public class WebMvcEndpointInfrastructureAutoConfigurationTests {
|
||||
@Test
|
||||
public void singleWebEndpointCanBeEnabled() {
|
||||
WebApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues(
|
||||
"endpoints.all.web.enabled=false", "endpoints.beans.web.enabled=true");
|
||||
"endpoints.default.web.enabled=false", "endpoints.beans.web.enabled=true");
|
||||
contextRunner.run((context) -> {
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
|
||||
assertThat(isExposed(mockMvc, HttpMethod.GET, "/application/autoconfig"))
|
||||
|
@ -47,9 +47,9 @@ public class EndpointEnablementProviderTests {
|
||||
@Test
|
||||
public void cannotDetermineEnablementOfEndpointAll() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Endpoint id 'all' is a reserved value and cannot "
|
||||
this.thrown.expectMessage("Endpoint id 'default' is a reserved value and cannot "
|
||||
+ "be used by an endpoint");
|
||||
determineEnablement("all", true);
|
||||
determineEnablement("default", true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -66,14 +66,14 @@ public class EndpointEnablementProviderTests {
|
||||
|
||||
@Test
|
||||
public void generalDisabledViaGeneralProperty() {
|
||||
validate(determineEnablement("foo", true, "endpoints.all.enabled=false"), false,
|
||||
"found property endpoints.all.enabled");
|
||||
validate(determineEnablement("foo", true, "endpoints.default.enabled=false"), false,
|
||||
"found property endpoints.default.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generalEnabledOverrideViaSpecificProperty() {
|
||||
validate(
|
||||
determineEnablement("foo", true, "endpoints.all.enabled=false",
|
||||
determineEnablement("foo", true, "endpoints.default.enabled=false",
|
||||
"endpoints.foo.enabled=true"),
|
||||
true, "found property endpoints.foo.enabled");
|
||||
}
|
||||
@ -104,32 +104,32 @@ public class EndpointEnablementProviderTests {
|
||||
@Test
|
||||
public void generalEnabledOverrideViaGeneralWebProperty() {
|
||||
validate(
|
||||
determineEnablement("foo", true, "endpoints.all.enabled=false",
|
||||
"endpoints.all.web.enabled=true"),
|
||||
true, "found property endpoints.all.web.enabled");
|
||||
determineEnablement("foo", true, "endpoints.default.enabled=false",
|
||||
"endpoints.default.web.enabled=true"),
|
||||
true, "found property endpoints.default.web.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generalEnabledOverrideViaGeneralJmxProperty() {
|
||||
validate(
|
||||
determineEnablement("foo", true, "endpoints.all.enabled=false",
|
||||
"endpoints.all.jmx.enabled=true"),
|
||||
true, "found property endpoints.all.jmx.enabled");
|
||||
determineEnablement("foo", true, "endpoints.default.enabled=false",
|
||||
"endpoints.default.jmx.enabled=true"),
|
||||
true, "found property endpoints.default.jmx.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generalEnabledOverrideViaGeneralAnyProperty() {
|
||||
validate(determineEnablement("foo", true, "endpoints.all.enabled=false",
|
||||
"endpoints.all.web.enabled=false", "endpoints.all.jmx.enabled=true"),
|
||||
true, "found property endpoints.all.jmx.enabled");
|
||||
validate(determineEnablement("foo", true, "endpoints.default.enabled=false",
|
||||
"endpoints.default.web.enabled=false", "endpoints.default.jmx.enabled=true"),
|
||||
true, "found property endpoints.default.jmx.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generalDisabledEvenWithEnabledGeneralProperties() {
|
||||
validate(
|
||||
determineEnablement("foo", true, "endpoints.all.enabled=true",
|
||||
"endpoints.all.web.enabled=true",
|
||||
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=false"),
|
||||
determineEnablement("foo", true, "endpoints.default.enabled=true",
|
||||
"endpoints.default.web.enabled=true",
|
||||
"endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=false"),
|
||||
false, "found property endpoints.foo.enabled");
|
||||
}
|
||||
|
||||
@ -141,19 +141,19 @@ public class EndpointEnablementProviderTests {
|
||||
|
||||
@Test
|
||||
public void generalDisabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() {
|
||||
validate(determineEnablement("bar", false, "endpoints.all.enabled=true"), false,
|
||||
validate(determineEnablement("bar", false, "endpoints.default.enabled=true"), false,
|
||||
"endpoint 'bar' is disabled by default");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generalDisabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() {
|
||||
validate(determineEnablement("bar", false, "endpoints.all.web.enabled=true"),
|
||||
validate(determineEnablement("bar", false, "endpoints.default.web.enabled=true"),
|
||||
false, "endpoint 'bar' is disabled by default");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generalDisabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() {
|
||||
validate(determineEnablement("bar", false, "endpoints.all.jmx.enabled=true"),
|
||||
validate(determineEnablement("bar", false, "endpoints.default.jmx.enabled=true"),
|
||||
false, "endpoint 'bar' is disabled by default");
|
||||
}
|
||||
|
||||
@ -217,15 +217,15 @@ public class EndpointEnablementProviderTests {
|
||||
public void specificDisabledViaGeneralProperty() {
|
||||
validate(
|
||||
determineEnablement("foo", true, EndpointType.JMX,
|
||||
"endpoints.all.enabled=false"),
|
||||
false, "found property endpoints.all.enabled");
|
||||
"endpoints.default.enabled=false"),
|
||||
false, "found property endpoints.default.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificEnabledOverrideViaEndpointProperty() {
|
||||
validate(
|
||||
determineEnablement("foo", true, EndpointType.WEB,
|
||||
"endpoints.all.enabled=false", "endpoints.foo.enabled=true"),
|
||||
"endpoints.default.enabled=false", "endpoints.foo.enabled=true"),
|
||||
true, "found property endpoints.foo.enabled");
|
||||
}
|
||||
|
||||
@ -249,24 +249,24 @@ public class EndpointEnablementProviderTests {
|
||||
public void specificEnabledOverrideViaGeneralWebProperty() {
|
||||
validate(
|
||||
determineEnablement("foo", true, EndpointType.WEB,
|
||||
"endpoints.all.enabled=false", "endpoints.all.web.enabled=true"),
|
||||
true, "found property endpoints.all.web.enabled");
|
||||
"endpoints.default.enabled=false", "endpoints.default.web.enabled=true"),
|
||||
true, "found property endpoints.default.web.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificEnabledOverrideHasNoEffectWithUnrelatedTechProperty() {
|
||||
validate(
|
||||
determineEnablement("foo", true, EndpointType.JMX,
|
||||
"endpoints.all.enabled=false", "endpoints.all.web.enabled=true"),
|
||||
false, "found property endpoints.all.enabled");
|
||||
"endpoints.default.enabled=false", "endpoints.default.web.enabled=true"),
|
||||
false, "found property endpoints.default.enabled");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void specificDisabledWithEndpointPropertyEvenWithEnabledGeneralProperties() {
|
||||
validate(
|
||||
determineEnablement("foo", true, EndpointType.WEB,
|
||||
"endpoints.all.enabled=true", "endpoints.all.web.enabled=true",
|
||||
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=false"),
|
||||
"endpoints.default.enabled=true", "endpoints.default.web.enabled=true",
|
||||
"endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=false"),
|
||||
false, "found property endpoints.foo.enabled");
|
||||
}
|
||||
|
||||
@ -274,8 +274,8 @@ public class EndpointEnablementProviderTests {
|
||||
public void specificDisabledWithTechPropertyEvenWithEnabledGeneralProperties() {
|
||||
validate(
|
||||
determineEnablement("foo", true, EndpointType.WEB,
|
||||
"endpoints.all.enabled=true", "endpoints.all.web.enabled=true",
|
||||
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=true",
|
||||
"endpoints.default.enabled=true", "endpoints.default.web.enabled=true",
|
||||
"endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=true",
|
||||
"endpoints.foo.web.enabled=false"),
|
||||
false, "found property endpoints.foo.web.enabled");
|
||||
}
|
||||
@ -290,7 +290,7 @@ public class EndpointEnablementProviderTests {
|
||||
public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() {
|
||||
validate(
|
||||
determineEnablement("bar", false, EndpointType.WEB,
|
||||
"endpoints.all.enabled=true"),
|
||||
"endpoints.default.enabled=true"),
|
||||
false, "endpoint 'bar' (web) is disabled by default");
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ public class EndpointEnablementProviderTests {
|
||||
public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() {
|
||||
validate(
|
||||
determineEnablement("bar", false, EndpointType.WEB,
|
||||
"endpoints.all.web.enabled=true"),
|
||||
"endpoints.default.web.enabled=true"),
|
||||
false, "endpoint 'bar' (web) is disabled by default");
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ public class EndpointEnablementProviderTests {
|
||||
public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() {
|
||||
validate(
|
||||
determineEnablement("bar", false, EndpointType.WEB,
|
||||
"endpoints.all.jmx.enabled=true"),
|
||||
"endpoints.default.jmx.enabled=true"),
|
||||
false, "endpoint 'bar' (web) is disabled by default");
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class WebEndpointManagementContextConfigurationTests {
|
||||
|
||||
private void beanIsAutoConfigured(Class<?> beanType, Class<?>... config) {
|
||||
contextRunner()
|
||||
.withPropertyValues("endpoints.all.web.enabled:true")
|
||||
.withPropertyValues("endpoints.default.web.enabled:true")
|
||||
.withUserConfiguration(config)
|
||||
.run((context) -> assertThat(context).hasSingleBean(beanType));
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class MvcEndpointCorsIntegrationTests {
|
||||
EndpointInfrastructureAutoConfiguration.class,
|
||||
EndpointAutoConfiguration.class, ManagementContextAutoConfiguration.class,
|
||||
ServletEndpointAutoConfiguration.class);
|
||||
TestPropertyValues.of("endpoints.all.web.enabled:true")
|
||||
TestPropertyValues.of("endpoints.default.web.enabled:true")
|
||||
.applyTo(this.context);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class MvcEndpointIntegrationTests {
|
||||
this.context = new AnnotationConfigWebApplicationContext();
|
||||
this.context.register(SecureConfiguration.class);
|
||||
TestPropertyValues.of("management.context-path:/management",
|
||||
"endpoints.all.web.enabled=true")
|
||||
"endpoints.default.web.enabled=true")
|
||||
.applyTo(this.context);
|
||||
MockMvc mockMvc = createSecureMockMvc();
|
||||
mockMvc.perform(get("/management/beans")).andExpect(status().isOk());
|
||||
|
@ -79,8 +79,8 @@ import org.springframework.web.util.DefaultUriBuilderFactory.EncodingMode;
|
||||
* {@link org.springframework.core.env.Environment} are reset at the end of every test.
|
||||
* This means that {@link TestPropertyValues} can be used in a test without affecting the
|
||||
* {@code Environment} of other tests in the same class.
|
||||
* The runner always sets the flag `endpoints.all.web.enabled` to true so that web endpoints
|
||||
* are enabled.
|
||||
* The runner always sets the flag `endpoints.default.web.enabled` to true so that web
|
||||
* endpoints are enabled.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@ -192,7 +192,8 @@ public class WebEndpointsRunner extends Suite {
|
||||
private MvcWebEndpointsRunner(Class<?> klass) throws InitializationError {
|
||||
super(klass, "Spring MVC", (classes) -> {
|
||||
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of("endpoints.all.web.enabled:true").applyTo(context);
|
||||
TestPropertyValues.of("endpoints.default.web.enabled=true")
|
||||
.applyTo(context);
|
||||
classes.add(MvcTestConfiguration.class);
|
||||
context.register(classes.toArray(new Class<?>[classes.size()]));
|
||||
context.refresh();
|
||||
@ -224,7 +225,8 @@ public class WebEndpointsRunner extends Suite {
|
||||
private JerseyWebEndpointsRunner(Class<?> klass) throws InitializationError {
|
||||
super(klass, "Jersey", (classes) -> {
|
||||
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext();
|
||||
TestPropertyValues.of("endpoints.all.web.enabled:true").applyTo(context);
|
||||
TestPropertyValues.of("endpoints.default.web.enabled=true")
|
||||
.applyTo(context);
|
||||
classes.add(JerseyAppConfiguration.class);
|
||||
classes.add(JerseyInfrastructureConfiguration.class);
|
||||
context.register(classes.toArray(new Class<?>[classes.size()]));
|
||||
@ -264,7 +266,7 @@ public class WebEndpointsRunner extends Suite {
|
||||
private ReactiveWebEndpointsRunner(Class<?> klass) throws InitializationError {
|
||||
super(klass, "Reactive", (classes) -> {
|
||||
ReactiveWebServerApplicationContext context = new ReactiveWebServerApplicationContext();
|
||||
TestPropertyValues.of("endpoints.all.web.enabled:true").applyTo(context);
|
||||
TestPropertyValues.of("endpoints.default.web.enabled:true").applyTo(context);
|
||||
classes.add(ReactiveInfrastructureConfiguration.class);
|
||||
context.register(classes.toArray(new Class<?>[classes.size()]));
|
||||
context.refresh();
|
||||
|
@ -1084,11 +1084,6 @@ content into your application; rather pick only the properties that you need.
|
||||
# ACTUATOR PROPERTIES
|
||||
# ----------------------------------------
|
||||
|
||||
# ALL ENDPOINTS
|
||||
endpoints.all.enabled=true # Enable all endpoints.
|
||||
endpoints.all.jmx.enabled=true # Enable all endpoints as JMX MBeans.
|
||||
endpoints.all.web.enabled=false # Enable all endpoints as Web endpoints.
|
||||
|
||||
# AUDIT EVENTS ENDPOINT ({sc-spring-boot-actuator}/endpoint/AuditEventsEndpoint.{sc-ext}[AuditEventsEndpoint])
|
||||
endpoints.auditevents.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
|
||||
endpoints.auditevents.enabled=true # Enable the auditevents endpoint.
|
||||
@ -1114,6 +1109,11 @@ content into your application; rather pick only the properties that you need.
|
||||
endpoints.configprops.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions.
|
||||
endpoints.configprops.web.enabled=false # Expose the configprops endpoint as a Web endpoint.
|
||||
|
||||
# ENDPOINT DEFAULT SETTINGS
|
||||
endpoints.default.enabled=true # Enable all endpoints by default.
|
||||
endpoints.default.jmx.enabled=true # Enable all endpoints as JMX MBeans by default.
|
||||
endpoints.default.web.enabled=false # Enable all endpoints as Web endpoints by default.
|
||||
|
||||
# ENVIRONMENT ENDPOINT ({sc-spring-boot-actuator}/endpoint/EnvironmentEndpoint.{sc-ext}[EnvironmentEndpoint])
|
||||
endpoints.env.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
|
||||
endpoints.env.enabled=true # Enable the env endpoint.
|
||||
|
@ -211,12 +211,12 @@ NOTE: The prefix ‟`endpoints` + `.` + `name`” is used to uniquely identify t
|
||||
that is being configured.
|
||||
|
||||
By default, all endpoints except for `shutdown` are enabled. If you prefer to
|
||||
specifically "`opt-in`" endpoint enablement you can use the `endpoints.all.enabled`
|
||||
specifically "`opt-in`" endpoint enablement you can use the `endpoints.default.enabled`
|
||||
property. For example, the following will disable _all_ endpoints except for `info`:
|
||||
|
||||
[source,properties,indent=0]
|
||||
----
|
||||
endpoints.all.enabled=false
|
||||
endpoints.default.enabled=false
|
||||
endpoints.info.enabled=true
|
||||
----
|
||||
|
||||
@ -758,12 +758,12 @@ example `application.properties`:
|
||||
|
||||
[[production-ready-disable-jmx-endpoints]]
|
||||
=== Disabling JMX endpoints
|
||||
If you don't want to expose endpoints over JMX you can set the `endpoints.all.jmx.enabled`
|
||||
If you don't want to expose endpoints over JMX you can set the `endpoints.default.jmx.enabled`
|
||||
property to `false`:
|
||||
|
||||
[source,properties,indent=0]
|
||||
----
|
||||
endpoints.all.jmx.enabled=false
|
||||
endpoints.default.jmx.enabled=false
|
||||
----
|
||||
|
||||
|
||||
|
@ -1 +1 @@
|
||||
endpoints.all.web.enabled=true
|
||||
endpoints.default.web.enabled=true
|
@ -1,2 +1,2 @@
|
||||
endpoints.shutdown.enabled=true
|
||||
endpoints.all.web.enabled=true
|
||||
endpoints.default.web.enabled=true
|
@ -1,3 +1,3 @@
|
||||
health.diskspace.enabled=false
|
||||
endpoints.all.web.enabled=true
|
||||
endpoints.default.web.enabled=true
|
||||
management.jolokia.enabled=true
|
@ -11,7 +11,7 @@ server.tomcat.accesslog.pattern=%h %t "%r" %s %b
|
||||
security.require-ssl=false
|
||||
#spring.jackson.serialization.INDENT_OUTPUT=true
|
||||
spring.jmx.enabled=true
|
||||
endpoints.all.web.enabled=true
|
||||
endpoints.default.web.enabled=true
|
||||
|
||||
spring.jackson.serialization.write_dates_as_timestamps=false
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
server.port=8081
|
||||
endpoints.all.web.enabled=true
|
||||
endpoints.default.web.enabled=true
|
||||
security.oauth2.resource.id=service
|
||||
security.oauth2.resource.userInfoUri=http://localhost:8080/user
|
||||
logging.level.org.springframework.security=DEBUG
|
||||
|
@ -1,3 +1,3 @@
|
||||
spring.thymeleaf.cache: false
|
||||
logging.level.org.springframework.security: INFO
|
||||
endpoints.all.web.enabled=true
|
||||
endpoints.default.web.enabled=true
|
Loading…
Reference in New Issue
Block a user