Search in sources :

Example 1 with EnvironmentEndpoint

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;
}
Also used : EnvironmentEndpoint(org.springframework.boot.actuate.env.EnvironmentEndpoint) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with EnvironmentEndpoint

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("******");
    });
}
Also used : EnvironmentEndpoint(org.springframework.boot.actuate.env.EnvironmentEndpoint) PropertyValueDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

EnvironmentEndpoint (org.springframework.boot.actuate.env.EnvironmentEndpoint)2 Test (org.junit.jupiter.api.Test)1 EnvironmentDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor)1 PropertyValueDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1