Search in sources :

Example 11 with EnvironmentDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method propertyWithSensitivePlaceholderNotResolved.

@Test
void propertyWithSensitivePlaceholderNotResolved() {
    ConfigurableEnvironment environment = emptyEnvironment();
    TestPropertyValues.of("my.foo: http://${bar.password}://hello").applyTo(environment);
    EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
    assertThat(propertySources(descriptor).get("test").getProperties().get("my.foo").getValue()).isEqualTo("http://${bar.password}://hello");
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Example 12 with EnvironmentDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method propertyWithPlaceholderResolved.

@Test
void propertyWithPlaceholderResolved() {
    ConfigurableEnvironment environment = emptyEnvironment();
    TestPropertyValues.of("my.foo: ${bar.blah}", "bar.blah: hello").applyTo(environment);
    EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
    assertThat(propertySources(descriptor).get("test").getProperties().get("my.foo").getValue()).isEqualTo("hello");
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Example 13 with EnvironmentDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method sensitiveKeysHaveTheirValuesSanitized.

@Test
void sensitiveKeysHaveTheirValuesSanitized() {
    TestPropertyValues.of("dbPassword=123456", "apiKey=123456", "mySecret=123456", "myCredentials=123456", "VCAP_SERVICES=123456").applyToSystemProperties(() -> {
        EnvironmentDescriptor descriptor = new EnvironmentEndpoint(new StandardEnvironment()).environment(null);
        Map<String, PropertyValueDescriptor> systemProperties = propertySources(descriptor).get("systemProperties").getProperties();
        assertThat(systemProperties.get("dbPassword").getValue()).isEqualTo("******");
        assertThat(systemProperties.get("apiKey").getValue()).isEqualTo("******");
        assertThat(systemProperties.get("mySecret").getValue()).isEqualTo("******");
        assertThat(systemProperties.get("myCredentials").getValue()).isEqualTo("******");
        assertThat(systemProperties.get("VCAP_SERVICES").getValue()).isEqualTo("******");
        PropertyValueDescriptor command = systemProperties.get("sun.java.command");
        if (command != null) {
            assertThat(command.getValue()).isEqualTo("******");
        }
        return null;
    });
}
Also used : PropertyValueDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 14 with EnvironmentDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method sensitiveKeysMatchingCustomNameHaveTheirValuesSanitized.

@Test
void sensitiveKeysMatchingCustomNameHaveTheirValuesSanitized() {
    TestPropertyValues.of("dbPassword=123456", "apiKey=123456").applyToSystemProperties(() -> {
        EnvironmentEndpoint endpoint = new EnvironmentEndpoint(new StandardEnvironment());
        endpoint.setKeysToSanitize("key");
        EnvironmentDescriptor descriptor = endpoint.environment(null);
        Map<String, PropertyValueDescriptor> systemProperties = propertySources(descriptor).get("systemProperties").getProperties();
        assertThat(systemProperties.get("dbPassword").getValue()).isEqualTo("123456");
        assertThat(systemProperties.get("apiKey").getValue()).isEqualTo("******");
        return null;
    });
}
Also used : PropertyValueDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 15 with EnvironmentDescriptor

use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.

the class EnvironmentEndpointTests method propertyWithComplexTypeShouldNotFail.

@Test
void propertyWithComplexTypeShouldNotFail() {
    ConfigurableEnvironment environment = emptyEnvironment();
    environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", Collections.singletonMap("bar", "baz")));
    EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
    String value = (String) propertySources(descriptor).get("test").getProperties().get("foo").getValue();
    assertThat(value).isEqualTo("Complex property type java.util.Collections$SingletonMap");
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) EnvironmentDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)17 EnvironmentDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor)17 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)12 PropertyValueDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertyValueDescriptor)7 StandardEnvironment (org.springframework.core.env.StandardEnvironment)5 PropertySourceDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceDescriptor)3 MapPropertySource (org.springframework.core.env.MapPropertySource)2 LinkedHashMap (java.util.LinkedHashMap)1 EnvironmentEndpoint (org.springframework.boot.actuate.env.EnvironmentEndpoint)1 CompositePropertySource (org.springframework.core.env.CompositePropertySource)1