Search in sources :

Example 1 with EnvironmentEntryDescriptor

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

the class EnvironmentEndpointTests method uriPropertyWithSensitiveInfo.

@Test
void uriPropertyWithSensitiveInfo() {
    ConfigurableEnvironment environment = new StandardEnvironment();
    TestPropertyValues.of("sensitive.uri=http://user:password@localhost:8080").applyTo(environment);
    EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("sensitive.uri");
    assertThat(descriptor.getProperty().getValue()).isEqualTo("http://user:******@localhost:8080");
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 2 with EnvironmentEntryDescriptor

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

the class EnvironmentEndpointTests method propertyEntryNotFound.

@Test
void propertyEntryNotFound() {
    ConfigurableEnvironment environment = emptyEnvironment();
    environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", "bar"));
    EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("does.not.exist");
    assertThat(descriptor).isNotNull();
    assertThat(descriptor.getProperty()).isNull();
    Map<String, PropertySourceEntryDescriptor> sources = propertySources(descriptor);
    assertThat(sources.keySet()).containsExactly("test");
    assertPropertySourceEntryDescriptor(sources.get("test"), null, null);
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) PropertySourceEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) Test(org.junit.jupiter.api.Test)

Example 3 with EnvironmentEntryDescriptor

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

the class EnvironmentEndpointTests method propertyEntry.

@Test
void propertyEntry() {
    TestPropertyValues.of("my.foo=another").applyToSystemProperties(() -> {
        StandardEnvironment environment = new StandardEnvironment();
        TestPropertyValues.of("my.foo=bar", "my.foo2=bar2").applyTo(environment, TestPropertyValues.Type.MAP, "test");
        EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("my.foo");
        assertThat(descriptor).isNotNull();
        assertThat(descriptor.getProperty()).isNotNull();
        assertThat(descriptor.getProperty().getSource()).isEqualTo("test");
        assertThat(descriptor.getProperty().getValue()).isEqualTo("bar");
        Map<String, PropertySourceEntryDescriptor> sources = propertySources(descriptor);
        assertThat(sources.keySet()).containsExactly("test", "systemProperties", "systemEnvironment");
        assertPropertySourceEntryDescriptor(sources.get("test"), "bar", null);
        assertPropertySourceEntryDescriptor(sources.get("systemProperties"), "another", null);
        assertPropertySourceEntryDescriptor(sources.get("systemEnvironment"), null, null);
        return null;
    });
}
Also used : PropertySourceEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 4 with EnvironmentEntryDescriptor

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

the class EnvironmentEndpointTests method addressesPropertyWithMultipleEntriesEachWithSensitiveInfo.

@Test
void addressesPropertyWithMultipleEntriesEachWithSensitiveInfo() {
    ConfigurableEnvironment environment = new StandardEnvironment();
    TestPropertyValues.of("sensitive.addresses=http://user:password@localhost:8080,http://user2:password2@localhost:8082").applyTo(environment);
    EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("sensitive.addresses");
    assertThat(descriptor.getProperty().getValue()).isEqualTo("http://user:******@localhost:8080,http://user2:******@localhost:8082");
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Example 5 with EnvironmentEntryDescriptor

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

the class EnvironmentEndpointTests method originAndOriginParents.

@Test
void originAndOriginParents() {
    StandardEnvironment environment = new StandardEnvironment();
    OriginParentMockPropertySource propertySource = new OriginParentMockPropertySource();
    propertySource.setProperty("name", "test");
    environment.getPropertySources().addFirst(propertySource);
    EnvironmentEntryDescriptor descriptor = new EnvironmentEndpoint(environment).environmentEntry("name");
    PropertySourceEntryDescriptor entryDescriptor = propertySources(descriptor).get("mockProperties");
    assertThat(entryDescriptor.getProperty().getOrigin()).isEqualTo("name");
    assertThat(entryDescriptor.getProperty().getOriginParents()).containsExactly("spring", "boot");
}
Also used : PropertySourceEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor) EnvironmentEntryDescriptor(org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor) StandardEnvironment(org.springframework.core.env.StandardEnvironment) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)5 EnvironmentEntryDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.EnvironmentEntryDescriptor)5 StandardEnvironment (org.springframework.core.env.StandardEnvironment)4 PropertySourceEntryDescriptor (org.springframework.boot.actuate.env.EnvironmentEndpoint.PropertySourceEntryDescriptor)3 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)3