use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method sensitiveKeysMatchingCustomPatternHaveTheirValuesSanitized.
@Test
void sensitiveKeysMatchingCustomPatternHaveTheirValuesSanitized() {
TestPropertyValues.of("dbPassword=123456", "apiKey=123456").applyToSystemProperties(() -> {
EnvironmentEndpoint endpoint = new EnvironmentEndpoint(new StandardEnvironment());
endpoint.setKeysToSanitize(".*pass.*");
EnvironmentDescriptor descriptor = endpoint.environment(null);
Map<String, PropertyValueDescriptor> systemProperties = propertySources(descriptor).get("systemProperties").getProperties();
assertThat(systemProperties.get("dbPassword").getValue()).isEqualTo("******");
assertThat(systemProperties.get("apiKey").getValue()).isEqualTo("123456");
return null;
});
}
use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method basicResponse.
@Test
void basicResponse() {
ConfigurableEnvironment environment = emptyEnvironment();
environment.getPropertySources().addLast(singleKeyPropertySource("one", "my.key", "first"));
environment.getPropertySources().addLast(singleKeyPropertySource("two", "my.key", "second"));
EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
assertThat(descriptor.getActiveProfiles()).isEmpty();
Map<String, PropertySourceDescriptor> sources = propertySources(descriptor);
assertThat(sources.keySet()).containsExactly("one", "two");
assertThat(sources.get("one").getProperties()).containsOnlyKeys("my.key");
assertThat(sources.get("two").getProperties()).containsOnlyKeys("my.key");
}
use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method multipleSourcesWithSameProperty.
@Test
void multipleSourcesWithSameProperty() {
ConfigurableEnvironment environment = emptyEnvironment();
environment.getPropertySources().addFirst(singleKeyPropertySource("one", "a", "alpha"));
environment.getPropertySources().addFirst(singleKeyPropertySource("two", "a", "apple"));
EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
Map<String, PropertySourceDescriptor> sources = propertySources(descriptor);
assertThat(sources.keySet()).containsExactly("two", "one");
assertThat(sources.get("one").getProperties().get("a").getValue()).isEqualTo("alpha");
assertThat(sources.get("two").getProperties().get("a").getValue()).isEqualTo("apple");
}
use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method propertyWithSensitivePlaceholderWithCustomFunctionResolved.
@Test
void propertyWithSensitivePlaceholderWithCustomFunctionResolved() {
ConfigurableEnvironment environment = emptyEnvironment();
TestPropertyValues.of("my.foo: http://${bar.password}://hello", "bar.password: hello").applyTo(environment);
EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment, Collections.singletonList((data) -> data.withValue(data.getPropertySource().getName() + "******"))).environment(null);
assertThat(propertySources(descriptor).get("test").getProperties().get("my.foo").getValue()).isEqualTo("test******");
}
use of org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentDescriptor in project spring-boot by spring-projects.
the class EnvironmentEndpointTests method sensitiveKeysMatchingCredentialsPatternHaveTheirValuesSanitized.
@Test
void sensitiveKeysMatchingCredentialsPatternHaveTheirValuesSanitized() {
TestPropertyValues.of("my.services.amqp-free.credentials.uri=123456", "credentials.http_api_uri=123456", "my.services.cleardb-free.credentials=123456", "foo.mycredentials.uri=123456").applyToSystemProperties(() -> {
EnvironmentDescriptor descriptor = new EnvironmentEndpoint(new StandardEnvironment()).environment(null);
Map<String, PropertyValueDescriptor> systemProperties = propertySources(descriptor).get("systemProperties").getProperties();
assertThat(systemProperties.get("my.services.amqp-free.credentials.uri").getValue()).isEqualTo("******");
assertThat(systemProperties.get("credentials.http_api_uri").getValue()).isEqualTo("******");
assertThat(systemProperties.get("my.services.cleardb-free.credentials").getValue()).isEqualTo("******");
assertThat(systemProperties.get("foo.mycredentials.uri").getValue()).isEqualTo("******");
return null;
});
}
Aggregations