Skip to content

Commit

Permalink
chore: add extra testing around secret masking
Browse files Browse the repository at this point in the history
  • Loading branch information
credmond-git committed Mar 21, 2024
1 parent 155d3ec commit d18835f
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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<String, String> configs = new HashMap<>();
Expand Down

0 comments on commit d18835f

Please sign in to comment.