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");
}
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");
}
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;
});
}
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;
});
}
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");
}
Aggregations