diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/EnvironmentEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/EnvironmentEndpointDocumentationTests.java index 061f6e8eaf8e..55703f33da21 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/EnvironmentEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/EnvironmentEndpointDocumentationTests.java @@ -64,6 +64,9 @@ class EnvironmentEndpointDocumentationTests extends MockMvcEndpointDocumentation private static final FieldDescriptor activeProfiles = fieldWithPath("activeProfiles") .description("Names of the active profiles, if any."); + private static final FieldDescriptor defaultProfiles = fieldWithPath("defaultProfiles") + .description("Names of the default profiles, if any."); + private static final FieldDescriptor propertySources = fieldWithPath("propertySources") .description("Property sources in order of precedence."); @@ -79,7 +82,7 @@ void env() throws Exception { replacePattern(Pattern.compile( "org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/"), ""), filterProperties()), - responseFields(activeProfiles, propertySources, propertySourceName, + responseFields(activeProfiles, defaultProfiles, propertySources, propertySourceName, fieldWithPath("propertySources.[].properties") .description("Properties in the property source keyed by property name."), fieldWithPath("propertySources.[].properties.*.value") @@ -101,7 +104,7 @@ void singlePropertyFromEnv() throws Exception { .optional(), fieldWithPath("property.source").description("Name of the source of the property."), fieldWithPath("property.value").description("Value of the property."), activeProfiles, - propertySources, propertySourceName, + defaultProfiles, propertySources, propertySourceName, fieldWithPath("propertySources.[].property") .description("Property in the property source, if any.") .optional(), diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java index 1358f6f0636e..0abdb53fc4d6 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java @@ -101,7 +101,8 @@ private EnvironmentDescriptor getEnvironmentDescriptor(Predicate propert propertyNamePredicate, showUnsanitized)); } }); - return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()), propertySources); + return new EnvironmentDescriptor(Arrays.asList(this.environment.getActiveProfiles()), + Arrays.asList(this.environment.getDefaultProfiles()), propertySources); } @ReadOperation @@ -114,7 +115,7 @@ EnvironmentEntryDescriptor getEnvironmentEntryDescriptor(String propertyName, bo Map descriptors = getPropertySourceDescriptors(propertyName, showUnsanitized); PropertySummaryDescriptor summary = getPropertySummaryDescriptor(descriptors); return new EnvironmentEntryDescriptor(summary, Arrays.asList(this.environment.getActiveProfiles()), - toPropertySourceDescriptors(descriptors)); + Arrays.asList(this.environment.getDefaultProfiles()), toPropertySourceDescriptors(descriptors)); } private List toPropertySourceDescriptors( @@ -209,10 +210,14 @@ public static final class EnvironmentDescriptor implements OperationResponseBody private final List activeProfiles; + private final List defaultProfiles; + private final List propertySources; - private EnvironmentDescriptor(List activeProfiles, List propertySources) { + private EnvironmentDescriptor(List activeProfiles, List defaultProfiles, + List propertySources) { this.activeProfiles = activeProfiles; + this.defaultProfiles = defaultProfiles; this.propertySources = propertySources; } @@ -220,6 +225,10 @@ public List getActiveProfiles() { return this.activeProfiles; } + public List getDefaultProfiles() { + return this.defaultProfiles; + } + public List getPropertySources() { return this.propertySources; } @@ -236,12 +245,15 @@ public static final class EnvironmentEntryDescriptor { private final List activeProfiles; + private final List defaultProfiles; + private final List propertySources; EnvironmentEntryDescriptor(PropertySummaryDescriptor property, List activeProfiles, - List propertySources) { + List defaultProfiles, List propertySources) { this.property = property; this.activeProfiles = activeProfiles; + this.defaultProfiles = defaultProfiles; this.propertySources = propertySources; } @@ -253,6 +265,10 @@ public List getActiveProfiles() { return this.activeProfiles; } + public List getDefaultProfiles() { + return this.defaultProfiles; + } + public List getPropertySources() { return this.propertySources; } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointWebExtensionTests.java index febf1ee346fd..fa00f3cd0e0c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/env/EnvironmentEndpointWebExtensionTests.java @@ -86,7 +86,8 @@ void whenShowValuesIsWhenAuthorizedAndSecurityContextIsNotAuthorized() { private void verifyPrefixed(SecurityContext securityContext, boolean showUnsanitized) { given(this.delegate.getEnvironmentEntryDescriptor("test", showUnsanitized)) - .willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList())); + .willReturn(new EnvironmentEntryDescriptor(null, Collections.emptyList(), Collections.emptyList(), + Collections.emptyList())); this.webExtension.environmentEntry(securityContext, "test"); then(this.delegate).should().getEnvironmentEntryDescriptor("test", showUnsanitized); }