ashb commented on code in PR #75651:
URL: https://github.com/apache/airflow/pull/75651#discussion_r4492047180


##########
shared/secrets_masker/tests/secrets_masker/test_secrets_masker.py:
##########
@@ -1237,6 +1238,36 @@ def test_regex_special_chars_in_secrets(self):
         assert redacted.startswith("Contains ")
         assert " and " in redacted
 
+    def test_multiline_secret_masked_when_wrapped_by_pprint(self):
+        secret = "-----BEGIN KEY-----\nabcDEF123\nxyz789\n-----END KEY-----"
+        secrets_masker = SecretsMasker()
+        configure_secrets_masker_for_test(secrets_masker)
+        secrets_masker.add_mask(secret)
+
+        pod_like = {"spec": {"containers": [{"env": [{"name": "MULTI", 
"value": secret}]}]}}
+        formatted = pprint.pformat(pod_like)

Review Comment:
   I'd rather not rely on the behaviour of pprint or pformat here, I'd rather 
we did something like:
   ```suggestion
           formatted = textwrap.dedent("""
           something="foo"
           value="-----BEGIN KEY-----\n"
                  "abcDEF123\n"
           """)
   ```
   And similarly for the expected result. This lets us much more instantly see 
what this test is actually testing, and that is redacting correctly, and not 
silently passing cos something about pprint has changed. Test name should 
change too



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to