diff --git a/gestalt-core/src/test/java/org/github/gestalt/config/GestaltTest.java b/gestalt-core/src/test/java/org/github/gestalt/config/GestaltTest.java index 97ef82c9c..aa473a9ce 100644 --- a/gestalt-core/src/test/java/org/github/gestalt/config/GestaltTest.java +++ b/gestalt-core/src/test/java/org/github/gestalt/config/GestaltTest.java @@ -1748,6 +1748,31 @@ public void testSecretMasking() throws GestaltException { "port=LeafNode{value='&&&&&'}, uri=LeafNode{value='my.sql.com'}}}", rootNode); } + @Test + public void testSecretMaskingDefault() throws GestaltException { + Map configs = new HashMap<>(); + configs.put("db.password", "test"); + configs.put("db.port", "abcdef"); + configs.put("db.uri", "my.sql.com"); + configs.put("db.salt", "pepper"); + configs.put("db.secret.user", "12345"); + + Gestalt gestalt = new GestaltBuilder() + .addSource(MapConfigSourceBuilder.builder().setCustomConfig(configs).build()) + .setTreatMissingValuesAsErrors(true) + .setTreatMissingDiscretionaryValuesAsErrors(true) + .setProxyDecoderMode(ProxyDecoderMode.CACHE) + .useCacheDecorator(false) + .build(); + + gestalt.loadConfigs(); + + String rootNode = gestalt.debugPrint(Tags.of()); + + Assertions.assertEquals("MapNode{db=MapNode{password=LeafNode{value='*****'}, salt=LeafNode{value='*****'}, " + + "port=LeafNode{value='abcdef'}, secret=MapNode{user=LeafNode{value='*****'}}, uri=LeafNode{value='my.sql.com'}}}", rootNode); + } + @Test public void testDebugPrint() throws GestaltException { Map configs = new HashMap<>();