use of org.springframework.boot.actuate.env.EnvironmentEndpoint in project spring-boot by spring-projects.
the class EnvironmentEndpointAutoConfiguration method environmentEndpoint.
@Bean
@ConditionalOnMissingBean
public EnvironmentEndpoint environmentEndpoint(Environment environment, EnvironmentEndpointProperties properties, ObjectProvider<SanitizingFunction> sanitizingFunctions) {
EnvironmentEndpoint endpoint = new EnvironmentEndpoint(environment, sanitizingFunctions);
String[] keysToSanitize = properties.getKeysToSanitize();
if (keysToSanitize != null) {
endpoint.setKeysToSanitize(keysToSanitize);
}
String[] additionalKeysToSanitize = properties.getAdditionalKeysToSanitize();
if (additionalKeysToSanitize != null) {
endpoint.keysToSanitize(additionalKeysToSanitize);
}
return endpoint;
}
use of org.springframework.boot.actuate.env.EnvironmentEndpoint in project spring-boot by spring-projects.
the class EnvironmentEndpointAutoConfigurationTests method sanitizingFunctionsCanBeConfiguredViaTheEnvironment.
@Test
void sanitizingFunctionsCanBeConfiguredViaTheEnvironment() {
this.contextRunner.withUserConfiguration(SanitizingFunctionConfiguration.class).withPropertyValues("management.endpoints.web.exposure.include=env").withSystemProperties("custom=123456", "password=123456").run((context) -> {
assertThat(context).hasSingleBean(EnvironmentEndpoint.class);
EnvironmentEndpoint endpoint = context.getBean(EnvironmentEndpoint.class);
EnvironmentDescriptor env = endpoint.environment(null);
Map<String, PropertyValueDescriptor> systemProperties = getSource("systemProperties", env).getProperties();
assertThat(systemProperties.get("custom").getValue()).isEqualTo("$$$");
assertThat(systemProperties.get("password").getValue()).isEqualTo("******");
});
}
Aggregations