Rename default endpoint settings to "default"

Closes gh-10098
pull/10101/head
Stephane Nicoll 7 years ago
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 * according to the {@code enabledByDefault} flag {@code types} flag that the
* {@link Endpoint} may be restricted to. * {@link Endpoint} may be restricted to.
* <p> * <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 * 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 * specific {@link EndpointType}, if any. If any property are set, they are evaluated with
* a sensible order of precedence. * a sensible order of precedence.
* <p> * <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. * {@code endpoints.<id>.enabled} is {@code true}, the condition will match.
* <p> * <p>
* This condition must be placed on a {@code @Bean} method producing an endpoint as its id * 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)) { if (!StringUtils.hasText(endpointId)) {
throw new IllegalArgumentException("Endpoint id must have a value"); throw new IllegalArgumentException("Endpoint id must have a value");
} }
if (endpointId.equals("all")) { if (endpointId.equals("default")) {
throw new IllegalArgumentException("Endpoint id 'all' is a reserved value " throw new IllegalArgumentException("Endpoint id 'default' is a reserved "
+ "and cannot be used by an endpoint"); + "value and cannot be used by an endpoint");
} }
if (endpointType != null) { if (endpointType != null) {
@ -97,26 +97,26 @@ public class EndpointEnablementProvider {
} }
if (endpointType != null) { if (endpointType != null) {
String globalTypeKey = createTechSpecificKey("all", endpointType); String defaultTypeKey = createTechSpecificKey("default", endpointType);
EndpointEnablement globalTypeOutcome = getEnablementFor(globalTypeKey); EndpointEnablement globalTypeOutcome = getEnablementFor(defaultTypeKey);
if (globalTypeOutcome != null) { if (globalTypeOutcome != null) {
return globalTypeOutcome; return globalTypeOutcome;
} }
if (!endpointType.isEnabledByDefault()) { if (!endpointType.isEnabledByDefault()) {
return defaultEndpointEnablement("all", false, endpointType); return defaultEndpointEnablement("default", false, endpointType);
} }
} }
else { else {
// Check if there is a global tech required // Check if there is a global tech required
EndpointEnablement anyTechGeneralOutcome = getAnyTechSpecificOutcomeFor( EndpointEnablement anyTechGeneralOutcome = getAnyTechSpecificOutcomeFor(
"all"); "default");
if (anyTechGeneralOutcome != null) { if (anyTechGeneralOutcome != null) {
return anyTechGeneralOutcome; return anyTechGeneralOutcome;
} }
} }
String globalKey = createKey("all", "enabled"); String defaultKey = createKey("default", "enabled");
EndpointEnablement globalOutCome = getEnablementFor(globalKey); EndpointEnablement globalOutCome = getEnablementFor(defaultKey);
if (globalOutCome != null) { if (globalOutCome != null) {
return globalOutCome; return globalOutCome;
} }

@ -1,22 +1,4 @@
{"properties": [ {"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", "name": "endpoints.configprops.keys-to-sanitize",
"type": "java.lang.String[]", "type": "java.lang.String[]",
@ -31,6 +13,24 @@
"vcap_services" "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", "name": "endpoints.env.keys-to-sanitize",
"type": "java.lang.String[]", "type": "java.lang.String[]",
@ -458,7 +458,7 @@
"description": "Enable endpoints.", "description": "Enable endpoints.",
"defaultValue": true, "defaultValue": true,
"deprecation": { "deprecation": {
"replacement": "endpoints.all.enabled", "replacement": "endpoints.default.enabled",
"level": "error" "level": "error"
} }
}, },
@ -623,7 +623,7 @@
"description": "Enable JMX export of all endpoints.", "description": "Enable JMX export of all endpoints.",
"defaultValue": true, "defaultValue": true,
"deprecation": { "deprecation": {
"replacement": "endpoints.all.jmx.enabled", "replacement": "endpoints.default.jmx.enabled",
"level": "error" "level": "error"
} }
}, },

@ -54,14 +54,14 @@ public class ConditionalOnEnabledEndpointTests {
@Test @Test
public void disabledViaGeneralProperty() { public void disabledViaGeneralProperty() {
this.contextRunner.withUserConfiguration(FooConfig.class) this.contextRunner.withUserConfiguration(FooConfig.class)
.withPropertyValues("endpoints.all.enabled=false") .withPropertyValues("endpoints.default.enabled=false")
.run((context) -> assertThat(context).doesNotHaveBean("foo")); .run((context) -> assertThat(context).doesNotHaveBean("foo"));
} }
@Test @Test
public void enabledOverrideViaSpecificProperty() { public void enabledOverrideViaSpecificProperty() {
this.contextRunner.withUserConfiguration(FooConfig.class) this.contextRunner.withUserConfiguration(FooConfig.class)
.withPropertyValues("endpoints.all.enabled=false", .withPropertyValues("endpoints.default.enabled=false",
"endpoints.foo.enabled=true") "endpoints.foo.enabled=true")
.run((context) -> assertThat(context).hasBean("foo")); .run((context) -> assertThat(context).hasBean("foo"));
} }
@ -94,34 +94,34 @@ public class ConditionalOnEnabledEndpointTests {
@Test @Test
public void enabledOverrideViaGeneralWebProperty() { public void enabledOverrideViaGeneralWebProperty() {
this.contextRunner.withUserConfiguration(FooConfig.class) this.contextRunner.withUserConfiguration(FooConfig.class)
.withPropertyValues("endpoints.all.enabled=false", .withPropertyValues("endpoints.default.enabled=false",
"endpoints.all.web.enabled=true") "endpoints.default.web.enabled=true")
.run((context) -> assertThat(context).hasBean("foo")); .run((context) -> assertThat(context).hasBean("foo"));
} }
@Test @Test
public void enabledOverrideViaGeneralJmxProperty() { public void enabledOverrideViaGeneralJmxProperty() {
this.contextRunner.withUserConfiguration(FooConfig.class) this.contextRunner.withUserConfiguration(FooConfig.class)
.withPropertyValues("endpoints.all.enabled=false", .withPropertyValues("endpoints.default.enabled=false",
"endpoints.all.jmx.enabled=true") "endpoints.default.jmx.enabled=true")
.run((context) -> assertThat(context).hasBean("foo")); .run((context) -> assertThat(context).hasBean("foo"));
} }
@Test @Test
public void enabledOverrideViaGeneralAnyProperty() { public void enabledOverrideViaGeneralAnyProperty() {
this.contextRunner.withUserConfiguration(FooConfig.class) this.contextRunner.withUserConfiguration(FooConfig.class)
.withPropertyValues("endpoints.all.enabled=false", .withPropertyValues("endpoints.default.enabled=false",
"endpoints.all.web.enabled=false", "endpoints.default.web.enabled=false",
"endpoints.all.jmx.enabled=true") "endpoints.default.jmx.enabled=true")
.run((context) -> assertThat(context).hasBean("foo")); .run((context) -> assertThat(context).hasBean("foo"));
} }
@Test @Test
public void disabledEvenWithEnabledGeneralProperties() { public void disabledEvenWithEnabledGeneralProperties() {
this.contextRunner.withUserConfiguration(FooConfig.class) this.contextRunner.withUserConfiguration(FooConfig.class)
.withPropertyValues("endpoints.all.enabled=true", .withPropertyValues("endpoints.default.enabled=true",
"endpoints.all.web.enabled=true", "endpoints.default.web.enabled=true",
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=false") "endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=false")
.run((context) -> assertThat(context).doesNotHaveBean("foo")); .run((context) -> assertThat(context).doesNotHaveBean("foo"));
} }
@ -134,21 +134,21 @@ public class ConditionalOnEnabledEndpointTests {
@Test @Test
public void disabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() { public void disabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() {
this.contextRunner.withUserConfiguration(BarConfig.class) this.contextRunner.withUserConfiguration(BarConfig.class)
.withPropertyValues("endpoints.all.enabled=true") .withPropertyValues("endpoints.default.enabled=true")
.run((context) -> assertThat(context).doesNotHaveBean("bar")); .run((context) -> assertThat(context).doesNotHaveBean("bar"));
} }
@Test @Test
public void disabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() { public void disabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() {
this.contextRunner.withUserConfiguration(BarConfig.class) this.contextRunner.withUserConfiguration(BarConfig.class)
.withPropertyValues("endpoints.all.web.enabled=true") .withPropertyValues("endpoints.default.web.enabled=true")
.run((context) -> assertThat(context).doesNotHaveBean("bar")); .run((context) -> assertThat(context).doesNotHaveBean("bar"));
} }
@Test @Test
public void disabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() { public void disabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() {
this.contextRunner.withUserConfiguration(BarConfig.class) this.contextRunner.withUserConfiguration(BarConfig.class)
.withPropertyValues("endpoints.all.jmx.enabled=true") .withPropertyValues("endpoints.default.jmx.enabled=true")
.run((context) -> assertThat(context).doesNotHaveBean("bar")); .run((context) -> assertThat(context).doesNotHaveBean("bar"));
} }
@ -184,7 +184,7 @@ public class ConditionalOnEnabledEndpointTests {
@Test @Test
public void enabledOnlyWebByDefault() { public void enabledOnlyWebByDefault() {
this.contextRunner.withUserConfiguration(OnlyWebConfig.class) this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
.withPropertyValues("endpoints.all.web.enabled=true") .withPropertyValues("endpoints.default.web.enabled=true")
.run((context) -> assertThat(context).hasBean("onlyweb")); .run((context) -> assertThat(context).hasBean("onlyweb"));
} }
@ -205,15 +205,15 @@ public class ConditionalOnEnabledEndpointTests {
@Test @Test
public void enableOverridesOnlyWebViaGeneralJmxPropertyHasNoEffect() { public void enableOverridesOnlyWebViaGeneralJmxPropertyHasNoEffect() {
this.contextRunner.withUserConfiguration(OnlyWebConfig.class) this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
.withPropertyValues("endpoints.all.enabled=false", .withPropertyValues("endpoints.default.enabled=false",
"endpoints.all.jmx.enabled=true") "endpoints.default.jmx.enabled=true")
.run((context) -> assertThat(context).doesNotHaveBean("onlyweb")); .run((context) -> assertThat(context).doesNotHaveBean("onlyweb"));
} }
@Test @Test
public void enableOverridesOnlyWebViaSpecificJmxPropertyHasNoEffect() { public void enableOverridesOnlyWebViaSpecificJmxPropertyHasNoEffect() {
this.contextRunner.withUserConfiguration(OnlyWebConfig.class) this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
.withPropertyValues("endpoints.all.enabled=false", .withPropertyValues("endpoints.default.enabled=false",
"endpoints.onlyweb.jmx.enabled=false") "endpoints.onlyweb.jmx.enabled=false")
.run((context) -> assertThat(context).doesNotHaveBean("onlyweb")); .run((context) -> assertThat(context).doesNotHaveBean("onlyweb"));
} }
@ -221,7 +221,7 @@ public class ConditionalOnEnabledEndpointTests {
@Test @Test
public void enableOverridesOnlyWebViaSpecificWebProperty() { public void enableOverridesOnlyWebViaSpecificWebProperty() {
this.contextRunner.withUserConfiguration(OnlyWebConfig.class) this.contextRunner.withUserConfiguration(OnlyWebConfig.class)
.withPropertyValues("endpoints.all.enabled=false", .withPropertyValues("endpoints.default.enabled=false",
"endpoints.onlyweb.web.enabled=true") "endpoints.onlyweb.web.enabled=true")
.run((context) -> assertThat(context).hasBean("onlyweb")); .run((context) -> assertThat(context).hasBean("onlyweb"));
} }
@ -229,7 +229,7 @@ public class ConditionalOnEnabledEndpointTests {
@Test @Test
public void disabledOnlyWebEvenWithEnabledGeneralProperties() { public void disabledOnlyWebEvenWithEnabledGeneralProperties() {
this.contextRunner.withUserConfiguration(OnlyWebConfig.class).withPropertyValues( 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") "endpoints.onlyweb.enabled=true", "endpoints.onlyweb.web.enabled=false")
.run((context) -> assertThat(context).doesNotHaveBean("foo")); .run((context) -> assertThat(context).doesNotHaveBean("foo"));
} }

@ -60,7 +60,7 @@ public class JmxEndpointInfrastructureAutoConfigurationTests {
@Test @Test
public void jmxEndpointsCanBeDisabled() { public void jmxEndpointsCanBeDisabled() {
this.contextRunner.withPropertyValues("endpoints.all.jmx.enabled:false") this.contextRunner.withPropertyValues("endpoints.default.jmx.enabled:false")
.run((context) -> { .run((context) -> {
MBeanServer mBeanServer = context.getBean(MBeanServer.class); MBeanServer mBeanServer = context.getBean(MBeanServer.class);
checkEndpointMBeans(mBeanServer, new String[0], checkEndpointMBeans(mBeanServer, new String[0],
@ -73,7 +73,7 @@ public class JmxEndpointInfrastructureAutoConfigurationTests {
@Test @Test
public void singleJmxEndpointCanBeEnabled() { 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) -> { "endpoints.beans.jmx.enabled=true").run((context) -> {
MBeanServer mBeanServer = context.getBean(MBeanServer.class); MBeanServer mBeanServer = context.getBean(MBeanServer.class);
checkEndpointMBeans(mBeanServer, new String[] { "beans" }, checkEndpointMBeans(mBeanServer, new String[] { "beans" },

@ -82,7 +82,7 @@ public class WebMvcEndpointInfrastructureAutoConfigurationTests {
@Test @Test
public void webEndpointsCanBeEnabled() { public void webEndpointsCanBeEnabled() {
WebApplicationContextRunner contextRunner = this.contextRunner WebApplicationContextRunner contextRunner = this.contextRunner
.withPropertyValues("endpoints.all.web.enabled=true"); .withPropertyValues("endpoints.default.web.enabled=true");
contextRunner.run(context -> { contextRunner.run(context -> {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
assertThat(isExposed(mockMvc, HttpMethod.GET, "/application/autoconfig")) assertThat(isExposed(mockMvc, HttpMethod.GET, "/application/autoconfig"))
@ -111,7 +111,7 @@ public class WebMvcEndpointInfrastructureAutoConfigurationTests {
@Test @Test
public void singleWebEndpointCanBeEnabled() { public void singleWebEndpointCanBeEnabled() {
WebApplicationContextRunner contextRunner = this.contextRunner.withPropertyValues( 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) -> { contextRunner.run((context) -> {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();
assertThat(isExposed(mockMvc, HttpMethod.GET, "/application/autoconfig")) assertThat(isExposed(mockMvc, HttpMethod.GET, "/application/autoconfig"))

@ -47,9 +47,9 @@ public class EndpointEnablementProviderTests {
@Test @Test
public void cannotDetermineEnablementOfEndpointAll() { public void cannotDetermineEnablementOfEndpointAll() {
this.thrown.expect(IllegalArgumentException.class); 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"); + "be used by an endpoint");
determineEnablement("all", true); determineEnablement("default", true);
} }
@Test @Test
@ -66,14 +66,14 @@ public class EndpointEnablementProviderTests {
@Test @Test
public void generalDisabledViaGeneralProperty() { public void generalDisabledViaGeneralProperty() {
validate(determineEnablement("foo", true, "endpoints.all.enabled=false"), false, validate(determineEnablement("foo", true, "endpoints.default.enabled=false"), false,
"found property endpoints.all.enabled"); "found property endpoints.default.enabled");
} }
@Test @Test
public void generalEnabledOverrideViaSpecificProperty() { public void generalEnabledOverrideViaSpecificProperty() {
validate( validate(
determineEnablement("foo", true, "endpoints.all.enabled=false", determineEnablement("foo", true, "endpoints.default.enabled=false",
"endpoints.foo.enabled=true"), "endpoints.foo.enabled=true"),
true, "found property endpoints.foo.enabled"); true, "found property endpoints.foo.enabled");
} }
@ -104,32 +104,32 @@ public class EndpointEnablementProviderTests {
@Test @Test
public void generalEnabledOverrideViaGeneralWebProperty() { public void generalEnabledOverrideViaGeneralWebProperty() {
validate( validate(
determineEnablement("foo", true, "endpoints.all.enabled=false", determineEnablement("foo", true, "endpoints.default.enabled=false",
"endpoints.all.web.enabled=true"), "endpoints.default.web.enabled=true"),
true, "found property endpoints.all.web.enabled"); true, "found property endpoints.default.web.enabled");
} }
@Test @Test
public void generalEnabledOverrideViaGeneralJmxProperty() { public void generalEnabledOverrideViaGeneralJmxProperty() {
validate( validate(
determineEnablement("foo", true, "endpoints.all.enabled=false", determineEnablement("foo", true, "endpoints.default.enabled=false",
"endpoints.all.jmx.enabled=true"), "endpoints.default.jmx.enabled=true"),
true, "found property endpoints.all.jmx.enabled"); true, "found property endpoints.default.jmx.enabled");
} }
@Test @Test
public void generalEnabledOverrideViaGeneralAnyProperty() { public void generalEnabledOverrideViaGeneralAnyProperty() {
validate(determineEnablement("foo", true, "endpoints.all.enabled=false", validate(determineEnablement("foo", true, "endpoints.default.enabled=false",
"endpoints.all.web.enabled=false", "endpoints.all.jmx.enabled=true"), "endpoints.default.web.enabled=false", "endpoints.default.jmx.enabled=true"),
true, "found property endpoints.all.jmx.enabled"); true, "found property endpoints.default.jmx.enabled");
} }
@Test @Test
public void generalDisabledEvenWithEnabledGeneralProperties() { public void generalDisabledEvenWithEnabledGeneralProperties() {
validate( validate(
determineEnablement("foo", true, "endpoints.all.enabled=true", determineEnablement("foo", true, "endpoints.default.enabled=true",
"endpoints.all.web.enabled=true", "endpoints.default.web.enabled=true",
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=false"), "endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=false"),
false, "found property endpoints.foo.enabled"); false, "found property endpoints.foo.enabled");
} }
@ -141,19 +141,19 @@ public class EndpointEnablementProviderTests {
@Test @Test
public void generalDisabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() { 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"); "endpoint 'bar' is disabled by default");
} }
@Test @Test
public void generalDisabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() { 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"); false, "endpoint 'bar' is disabled by default");
} }
@Test @Test
public void generalDisabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() { 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"); false, "endpoint 'bar' is disabled by default");
} }
@ -217,15 +217,15 @@ public class EndpointEnablementProviderTests {
public void specificDisabledViaGeneralProperty() { public void specificDisabledViaGeneralProperty() {
validate( validate(
determineEnablement("foo", true, EndpointType.JMX, determineEnablement("foo", true, EndpointType.JMX,
"endpoints.all.enabled=false"), "endpoints.default.enabled=false"),
false, "found property endpoints.all.enabled"); false, "found property endpoints.default.enabled");
} }
@Test @Test
public void specificEnabledOverrideViaEndpointProperty() { public void specificEnabledOverrideViaEndpointProperty() {
validate( validate(
determineEnablement("foo", true, EndpointType.WEB, 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"); true, "found property endpoints.foo.enabled");
} }
@ -249,24 +249,24 @@ public class EndpointEnablementProviderTests {
public void specificEnabledOverrideViaGeneralWebProperty() { public void specificEnabledOverrideViaGeneralWebProperty() {
validate( validate(
determineEnablement("foo", true, EndpointType.WEB, determineEnablement("foo", true, EndpointType.WEB,
"endpoints.all.enabled=false", "endpoints.all.web.enabled=true"), "endpoints.default.enabled=false", "endpoints.default.web.enabled=true"),
true, "found property endpoints.all.web.enabled"); true, "found property endpoints.default.web.enabled");
} }
@Test @Test
public void specificEnabledOverrideHasNoEffectWithUnrelatedTechProperty() { public void specificEnabledOverrideHasNoEffectWithUnrelatedTechProperty() {
validate( validate(
determineEnablement("foo", true, EndpointType.JMX, determineEnablement("foo", true, EndpointType.JMX,
"endpoints.all.enabled=false", "endpoints.all.web.enabled=true"), "endpoints.default.enabled=false", "endpoints.default.web.enabled=true"),
false, "found property endpoints.all.enabled"); false, "found property endpoints.default.enabled");
} }
@Test @Test
public void specificDisabledWithEndpointPropertyEvenWithEnabledGeneralProperties() { public void specificDisabledWithEndpointPropertyEvenWithEnabledGeneralProperties() {
validate( validate(
determineEnablement("foo", true, EndpointType.WEB, determineEnablement("foo", true, EndpointType.WEB,
"endpoints.all.enabled=true", "endpoints.all.web.enabled=true", "endpoints.default.enabled=true", "endpoints.default.web.enabled=true",
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=false"), "endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=false"),
false, "found property endpoints.foo.enabled"); false, "found property endpoints.foo.enabled");
} }
@ -274,8 +274,8 @@ public class EndpointEnablementProviderTests {
public void specificDisabledWithTechPropertyEvenWithEnabledGeneralProperties() { public void specificDisabledWithTechPropertyEvenWithEnabledGeneralProperties() {
validate( validate(
determineEnablement("foo", true, EndpointType.WEB, determineEnablement("foo", true, EndpointType.WEB,
"endpoints.all.enabled=true", "endpoints.all.web.enabled=true", "endpoints.default.enabled=true", "endpoints.default.web.enabled=true",
"endpoints.all.jmx.enabled=true", "endpoints.foo.enabled=true", "endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=true",
"endpoints.foo.web.enabled=false"), "endpoints.foo.web.enabled=false"),
false, "found property endpoints.foo.web.enabled"); false, "found property endpoints.foo.web.enabled");
} }
@ -290,7 +290,7 @@ public class EndpointEnablementProviderTests {
public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() { public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() {
validate( validate(
determineEnablement("bar", false, EndpointType.WEB, determineEnablement("bar", false, EndpointType.WEB,
"endpoints.all.enabled=true"), "endpoints.default.enabled=true"),
false, "endpoint 'bar' (web) is disabled by default"); false, "endpoint 'bar' (web) is disabled by default");
} }
@ -298,7 +298,7 @@ public class EndpointEnablementProviderTests {
public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() { public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() {
validate( validate(
determineEnablement("bar", false, EndpointType.WEB, determineEnablement("bar", false, EndpointType.WEB,
"endpoints.all.web.enabled=true"), "endpoints.default.web.enabled=true"),
false, "endpoint 'bar' (web) is disabled by default"); false, "endpoint 'bar' (web) is disabled by default");
} }
@ -306,7 +306,7 @@ public class EndpointEnablementProviderTests {
public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() { public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() {
validate( validate(
determineEnablement("bar", false, EndpointType.WEB, determineEnablement("bar", false, EndpointType.WEB,
"endpoints.all.jmx.enabled=true"), "endpoints.default.jmx.enabled=true"),
false, "endpoint 'bar' (web) is disabled by default"); false, "endpoint 'bar' (web) is disabled by default");
} }

@ -162,7 +162,7 @@ public class WebEndpointManagementContextConfigurationTests {
private void beanIsAutoConfigured(Class<?> beanType, Class<?>... config) { private void beanIsAutoConfigured(Class<?> beanType, Class<?>... config) {
contextRunner() contextRunner()
.withPropertyValues("endpoints.all.web.enabled:true") .withPropertyValues("endpoints.default.web.enabled:true")
.withUserConfiguration(config) .withUserConfiguration(config)
.run((context) -> assertThat(context).hasSingleBean(beanType)); .run((context) -> assertThat(context).hasSingleBean(beanType));
} }

@ -65,7 +65,7 @@ public class MvcEndpointCorsIntegrationTests {
EndpointInfrastructureAutoConfiguration.class, EndpointInfrastructureAutoConfiguration.class,
EndpointAutoConfiguration.class, ManagementContextAutoConfiguration.class, EndpointAutoConfiguration.class, ManagementContextAutoConfiguration.class,
ServletEndpointAutoConfiguration.class); ServletEndpointAutoConfiguration.class);
TestPropertyValues.of("endpoints.all.web.enabled:true") TestPropertyValues.of("endpoints.default.web.enabled:true")
.applyTo(this.context); .applyTo(this.context);
} }

@ -92,7 +92,7 @@ public class MvcEndpointIntegrationTests {
this.context = new AnnotationConfigWebApplicationContext(); this.context = new AnnotationConfigWebApplicationContext();
this.context.register(SecureConfiguration.class); this.context.register(SecureConfiguration.class);
TestPropertyValues.of("management.context-path:/management", TestPropertyValues.of("management.context-path:/management",
"endpoints.all.web.enabled=true") "endpoints.default.web.enabled=true")
.applyTo(this.context); .applyTo(this.context);
MockMvc mockMvc = createSecureMockMvc(); MockMvc mockMvc = createSecureMockMvc();
mockMvc.perform(get("/management/beans")).andExpect(status().isOk()); 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. * {@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 * This means that {@link TestPropertyValues} can be used in a test without affecting the
* {@code Environment} of other tests in the same class. * {@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 * The runner always sets the flag `endpoints.default.web.enabled` to true so that web
* are enabled. * endpoints are enabled.
* *
* @author Andy Wilkinson * @author Andy Wilkinson
*/ */
@ -192,7 +192,8 @@ public class WebEndpointsRunner extends Suite {
private MvcWebEndpointsRunner(Class<?> klass) throws InitializationError { private MvcWebEndpointsRunner(Class<?> klass) throws InitializationError {
super(klass, "Spring MVC", (classes) -> { super(klass, "Spring MVC", (classes) -> {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(); 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); classes.add(MvcTestConfiguration.class);
context.register(classes.toArray(new Class<?>[classes.size()])); context.register(classes.toArray(new Class<?>[classes.size()]));
context.refresh(); context.refresh();
@ -224,7 +225,8 @@ public class WebEndpointsRunner extends Suite {
private JerseyWebEndpointsRunner(Class<?> klass) throws InitializationError { private JerseyWebEndpointsRunner(Class<?> klass) throws InitializationError {
super(klass, "Jersey", (classes) -> { super(klass, "Jersey", (classes) -> {
AnnotationConfigServletWebServerApplicationContext context = new AnnotationConfigServletWebServerApplicationContext(); 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(JerseyAppConfiguration.class);
classes.add(JerseyInfrastructureConfiguration.class); classes.add(JerseyInfrastructureConfiguration.class);
context.register(classes.toArray(new Class<?>[classes.size()])); context.register(classes.toArray(new Class<?>[classes.size()]));
@ -264,7 +266,7 @@ public class WebEndpointsRunner extends Suite {
private ReactiveWebEndpointsRunner(Class<?> klass) throws InitializationError { private ReactiveWebEndpointsRunner(Class<?> klass) throws InitializationError {
super(klass, "Reactive", (classes) -> { super(klass, "Reactive", (classes) -> {
ReactiveWebServerApplicationContext context = new ReactiveWebServerApplicationContext(); 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); classes.add(ReactiveInfrastructureConfiguration.class);
context.register(classes.toArray(new Class<?>[classes.size()])); context.register(classes.toArray(new Class<?>[classes.size()]));
context.refresh(); context.refresh();

@ -1084,11 +1084,6 @@ content into your application; rather pick only the properties that you need.
# ACTUATOR PROPERTIES # 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]) # 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.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
endpoints.auditevents.enabled=true # Enable the auditevents endpoint. 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.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. 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]) # 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.cache.time-to-live=0 # Maximum time in milliseconds that a response can be cached.
endpoints.env.enabled=true # Enable the env endpoint. 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. that is being configured.
By default, all endpoints except for `shutdown` are enabled. If you prefer to 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`: property. For example, the following will disable _all_ endpoints except for `info`:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
endpoints.all.enabled=false endpoints.default.enabled=false
endpoints.info.enabled=true endpoints.info.enabled=true
---- ----
@ -758,12 +758,12 @@ example `application.properties`:
[[production-ready-disable-jmx-endpoints]] [[production-ready-disable-jmx-endpoints]]
=== Disabling 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`: property to `false`:
[source,properties,indent=0] [source,properties,indent=0]
---- ----
endpoints.all.jmx.enabled=false endpoints.default.jmx.enabled=false
---- ----

@ -1,2 +1,2 @@
endpoints.shutdown.enabled=true endpoints.shutdown.enabled=true
endpoints.all.web.enabled=true endpoints.default.web.enabled=true

@ -1,3 +1,3 @@
health.diskspace.enabled=false health.diskspace.enabled=false
endpoints.all.web.enabled=true endpoints.default.web.enabled=true
management.jolokia.enabled=true management.jolokia.enabled=true

@ -11,7 +11,7 @@ server.tomcat.accesslog.pattern=%h %t "%r" %s %b
security.require-ssl=false security.require-ssl=false
#spring.jackson.serialization.INDENT_OUTPUT=true #spring.jackson.serialization.INDENT_OUTPUT=true
spring.jmx.enabled=true spring.jmx.enabled=true
endpoints.all.web.enabled=true endpoints.default.web.enabled=true
spring.jackson.serialization.write_dates_as_timestamps=false spring.jackson.serialization.write_dates_as_timestamps=false

@ -1,5 +1,5 @@
server.port=8081 server.port=8081
endpoints.all.web.enabled=true endpoints.default.web.enabled=true
security.oauth2.resource.id=service security.oauth2.resource.id=service
security.oauth2.resource.userInfoUri=http://localhost:8080/user security.oauth2.resource.userInfoUri=http://localhost:8080/user
logging.level.org.springframework.security=DEBUG logging.level.org.springframework.security=DEBUG

@ -1,3 +1,3 @@
spring.thymeleaf.cache: false spring.thymeleaf.cache: false
logging.level.org.springframework.security: INFO logging.level.org.springframework.security: INFO
endpoints.all.web.enabled=true endpoints.default.web.enabled=true
Loading…
Cancel
Save