|
|
|
|
@ -16,6 +16,7 @@
@@ -16,6 +16,7 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.actuate.context.properties; |
|
|
|
|
|
|
|
|
|
import java.net.URI; |
|
|
|
|
import java.time.Duration; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@@ -46,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
* @author Dave Syer |
|
|
|
|
* @author Andy Wilkinson |
|
|
|
|
* @author Stephane Nicoll |
|
|
|
|
* @author HaiTao Zhang |
|
|
|
|
*/ |
|
|
|
|
class ConfigurationPropertiesReportEndpointTests { |
|
|
|
|
|
|
|
|
|
@ -174,6 +176,22 @@ class ConfigurationPropertiesReportEndpointTests {
@@ -174,6 +176,22 @@ class ConfigurationPropertiesReportEndpointTests {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void sanitizedUriWithSensitiveInfo() { |
|
|
|
|
load((context, properties) -> { |
|
|
|
|
Map<String, Object> nestedProperties = properties.getBeans().get("testProperties").getProperties(); |
|
|
|
|
assertThat(nestedProperties.get("sensitiveUri")).isEqualTo("http://user:******@localhost:8080"); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void sanitizedUriWithNoPassword() { |
|
|
|
|
load((context, properties) -> { |
|
|
|
|
Map<String, Object> nestedProperties = properties.getBeans().get("testProperties").getProperties(); |
|
|
|
|
assertThat(nestedProperties.get("noPasswordUri")).isEqualTo("http://user:******@localhost:8080"); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
|
void listsOfListsAreSanitized() { |
|
|
|
|
@ -266,6 +284,10 @@ class ConfigurationPropertiesReportEndpointTests {
@@ -266,6 +284,10 @@ class ConfigurationPropertiesReportEndpointTests {
|
|
|
|
|
|
|
|
|
|
private Duration duration = Duration.ofSeconds(10); |
|
|
|
|
|
|
|
|
|
private URI sensitiveUri = URI.create("http://user:password@localhost:8080"); |
|
|
|
|
|
|
|
|
|
private URI noPasswordUri = URI.create("http://user:p@localhost:8080"); |
|
|
|
|
|
|
|
|
|
TestProperties() { |
|
|
|
|
this.secrets.put("mine", "myPrivateThing"); |
|
|
|
|
this.secrets.put("yours", "yourPrivateThing"); |
|
|
|
|
@ -377,6 +399,22 @@ class ConfigurationPropertiesReportEndpointTests {
@@ -377,6 +399,22 @@ class ConfigurationPropertiesReportEndpointTests {
|
|
|
|
|
this.duration = duration; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setSensitiveUri(URI sensitiveUri) { |
|
|
|
|
this.sensitiveUri = sensitiveUri; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public URI getSensitiveUri() { |
|
|
|
|
return this.sensitiveUri; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setNoPasswordUri(URI noPasswordUri) { |
|
|
|
|
this.noPasswordUri = noPasswordUri; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public URI getNoPasswordUri() { |
|
|
|
|
return this.noPasswordUri; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class Hidden { |
|
|
|
|
|
|
|
|
|
private String mine = "mySecret"; |
|
|
|
|
|