|
17 | 17 | package org.springframework.boot.actuate.endpoint;
|
18 | 18 |
|
19 | 19 | import java.util.ArrayList;
|
| 20 | +import java.util.Arrays; |
20 | 21 | import java.util.HashMap;
|
21 | 22 | import java.util.List;
|
22 | 23 | import java.util.Map;
|
@@ -212,6 +213,23 @@ public void listsAreSanitized() throws Exception {
|
212 | 213 | assertThat(item.get("somePassword")).isEqualTo("******");
|
213 | 214 | }
|
214 | 215 |
|
| 216 | + @Test |
| 217 | + @SuppressWarnings("unchecked") |
| 218 | + public void listsOfListsAreSanitized() throws Exception { |
| 219 | + ConfigurationPropertiesReportEndpoint report = getEndpointBean(); |
| 220 | + Map<String, Object> properties = report.invoke(); |
| 221 | + Map<String, Object> nestedProperties = (Map<String, Object>) ((Map<String, Object>) properties |
| 222 | + .get("testProperties")).get("properties"); |
| 223 | + assertThat(nestedProperties.get("listOfListItems")).isInstanceOf(List.class); |
| 224 | + List<List<Object>> listOfLists = (List<List<Object>>) nestedProperties |
| 225 | + .get("listOfListItems"); |
| 226 | + assertThat(listOfLists).hasSize(1); |
| 227 | + List<Object> list = listOfLists.get(0); |
| 228 | + assertThat(list).hasSize(1); |
| 229 | + Map<String, Object> item = (Map<String, Object>) list.get(0); |
| 230 | + assertThat(item.get("somePassword")).isEqualTo("******"); |
| 231 | + } |
| 232 | + |
215 | 233 | @Configuration
|
216 | 234 | @EnableConfigurationProperties
|
217 | 235 | public static class Parent {
|
@@ -254,10 +272,13 @@ public static class TestProperties {
|
254 | 272 |
|
255 | 273 | private List<ListItem> listItems = new ArrayList<ListItem>();
|
256 | 274 |
|
| 275 | + private List<List<ListItem>> listOfListItems = new ArrayList<List<ListItem>>(); |
| 276 | + |
257 | 277 | public TestProperties() {
|
258 | 278 | this.secrets.put("mine", "myPrivateThing");
|
259 | 279 | this.secrets.put("yours", "yourPrivateThing");
|
260 | 280 | this.listItems.add(new ListItem());
|
| 281 | + this.listOfListItems.add(Arrays.asList(new ListItem())); |
261 | 282 | }
|
262 | 283 |
|
263 | 284 | public String getDbPassword() {
|
@@ -308,6 +329,14 @@ public void setListItems(List<ListItem> listItems) {
|
308 | 329 | this.listItems = listItems;
|
309 | 330 | }
|
310 | 331 |
|
| 332 | + public List<List<ListItem>> getListOfListItems() { |
| 333 | + return this.listOfListItems; |
| 334 | + } |
| 335 | + |
| 336 | + public void setListOfListItems(List<List<ListItem>> listOfListItems) { |
| 337 | + this.listOfListItems = listOfListItems; |
| 338 | + } |
| 339 | + |
311 | 340 | public static class Hidden {
|
312 | 341 |
|
313 | 342 | private String mine = "mySecret";
|
|
0 commit comments