Commit e2a12e77 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '1.4.x' into 1.5.x

parents a0ef61a2 6f3b4db7
...@@ -259,10 +259,9 @@ public class ConfigurationPropertiesReportEndpoint ...@@ -259,10 +259,9 @@ public class ConfigurationPropertiesReportEndpoint
sanitized.add(sanitize(prefix, (Map<String, Object>) item)); sanitized.add(sanitize(prefix, (Map<String, Object>) item));
} }
else if (item instanceof List) { else if (item instanceof List) {
sanitize(prefix, (List<Object>) item); sanitized.add(sanitize(prefix, (List<Object>) item));
} }
else { else {
item = this.sanitizer.sanitize(prefix, item);
sanitized.add(this.sanitizer.sanitize(prefix, item)); sanitized.add(this.sanitizer.sanitize(prefix, item));
} }
} }
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.springframework.boot.actuate.endpoint; package org.springframework.boot.actuate.endpoint;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -212,6 +213,23 @@ public class ConfigurationPropertiesReportEndpointTests ...@@ -212,6 +213,23 @@ public class ConfigurationPropertiesReportEndpointTests
assertThat(item.get("somePassword")).isEqualTo("******"); assertThat(item.get("somePassword")).isEqualTo("******");
} }
@Test
@SuppressWarnings("unchecked")
public void listsOfListsAreSanitized() throws Exception {
ConfigurationPropertiesReportEndpoint report = getEndpointBean();
Map<String, Object> properties = report.invoke();
Map<String, Object> nestedProperties = (Map<String, Object>) ((Map<String, Object>) properties
.get("testProperties")).get("properties");
assertThat(nestedProperties.get("listOfListItems")).isInstanceOf(List.class);
List<List<Object>> listOfLists = (List<List<Object>>) nestedProperties
.get("listOfListItems");
assertThat(listOfLists).hasSize(1);
List<Object> list = listOfLists.get(0);
assertThat(list).hasSize(1);
Map<String, Object> item = (Map<String, Object>) list.get(0);
assertThat(item.get("somePassword")).isEqualTo("******");
}
@Configuration @Configuration
@EnableConfigurationProperties @EnableConfigurationProperties
public static class Parent { public static class Parent {
...@@ -254,10 +272,13 @@ public class ConfigurationPropertiesReportEndpointTests ...@@ -254,10 +272,13 @@ public class ConfigurationPropertiesReportEndpointTests
private List<ListItem> listItems = new ArrayList<ListItem>(); private List<ListItem> listItems = new ArrayList<ListItem>();
private List<List<ListItem>> listOfListItems = new ArrayList<List<ListItem>>();
public TestProperties() { public TestProperties() {
this.secrets.put("mine", "myPrivateThing"); this.secrets.put("mine", "myPrivateThing");
this.secrets.put("yours", "yourPrivateThing"); this.secrets.put("yours", "yourPrivateThing");
this.listItems.add(new ListItem()); this.listItems.add(new ListItem());
this.listOfListItems.add(Arrays.asList(new ListItem()));
} }
public String getDbPassword() { public String getDbPassword() {
...@@ -308,6 +329,14 @@ public class ConfigurationPropertiesReportEndpointTests ...@@ -308,6 +329,14 @@ public class ConfigurationPropertiesReportEndpointTests
this.listItems = listItems; this.listItems = listItems;
} }
public List<List<ListItem>> getListOfListItems() {
return this.listOfListItems;
}
public void setListOfListItems(List<List<ListItem>> listOfListItems) {
this.listOfListItems = listOfListItems;
}
public static class Hidden { public static class Hidden {
private String mine = "mySecret"; private String mine = "mySecret";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment