pierrejeambrun commented on code in PR #53943:
URL: https://github.com/apache/airflow/pull/53943#discussion_r2244832068


##########
task-sdk/tests/task_sdk/definitions/test_secrets_masker.py:
##########
@@ -729,3 +731,356 @@ def test_mixed_structured_unstructured_data(self):
             assert "***" in redacted_data["description"]
             assert redacted_data["nested"]["token"] == "***"
             assert redacted_data["nested"]["info"] == "No secrets here"
+
+
+class TestSecretsMaskerMerge:
+    """Test the merge functionality for restoring original values from 
redacted data."""
+
+    @pytest.mark.parametrize(
+        ("new_value", "old_value", "name", "expected"),
+        [
+            ("***", "original_secret", "password", "original_secret"),
+            ("new_secret", "original_secret", "password", "new_secret"),
+            ("***", "original_value", "normal_field", "***"),
+            ("new_value", "original_value", "normal_field", "new_value"),
+            ("***", "original_value", None, "***"),
+            ("new_value", "original_value", None, "new_value"),
+        ],
+    )
+    def test_merge_simple_strings(self, new_value, old_value, name, expected):
+        secrets_masker = SecretsMasker()
+        with 
patch("airflow.sdk.execution_time.secrets_masker._secrets_masker", 
return_value=secrets_masker):
+            result = merge(new_value, old_value, name)
+            assert result == expected
+
+    def test_merge_dictionaries(self):
+        secrets_masker = SecretsMasker()
+
+        old_data = {
+            "password": "original_password",
+            "api_key": "original_api_key",
+            "normal_field": "original_normal",
+            "token": "original_token",
+        }
+
+        new_data = {
+            "password": "***",
+            "api_key": "new_api_key",
+            "normal_field": "new_normal",
+            "token": "***",
+        }
+
+        expected = {
+            "password": "original_password",
+            "api_key": "new_api_key",
+            "normal_field": "new_normal",
+            "token": "original_token",
+        }

Review Comment:
   I removed the key, it's already covered by the two other sensitive field. 
(one updated, on not)



-- 
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: commits-unsubscr...@airflow.apache.org

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

Reply via email to