You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/05/19 17:51:36 UTC

[GitHub] [kafka] cmccabe commented on a change in pull request #10714: MINOR: add ConfigUtils method for printing configurations

cmccabe commented on a change in pull request #10714:
URL: https://github.com/apache/kafka/pull/10714#discussion_r635462133



##########
File path: clients/src/test/java/org/apache/kafka/common/utils/ConfigUtilsTest.java
##########
@@ -140,4 +144,28 @@ public void testMultipleDeprecations() {
         assertNull(newConfig.get("foo.bar.deprecated"));
         assertNull(newConfig.get("foo.bar.even.more.deprecated"));
     }
+
+    private static final ConfigDef CONFIG = new ConfigDef().
+        define("foo", Type.PASSWORD, Importance.HIGH, "").
+        define("bar", Type.STRING, Importance.HIGH, "").
+        define("quux", Type.INT, Importance.HIGH, "").
+        define("blah", Type.STRING, Importance.HIGH, "");
+
+    @Test
+    public void testConfigMapToRedactedStringForEmptyMap() {
+        assertEquals("{}", ConfigUtils.
+            configMapToRedactedString(Collections.emptyMap(), CONFIG));
+    }
+
+    @Test
+    public void testConfigMapToRedactedStringWithSecrets() {
+        Map<String, Object> testMap1 = new HashMap<>();
+        testMap1.put("bar", "whatever");
+        testMap1.put("quux", Integer.valueOf(123));
+        testMap1.put("foo", "foosecret");
+        testMap1.put("blah", null);
+        testMap1.put("quuux", Integer.valueOf(456));
+        assertEquals("{bar=\"whatever\", blah=null, foo=(redacted), quuux=(redacted), quux=123}",

Review comment:
       ok




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org