amoghrajesh commented on code in PR #58767:
URL: https://github.com/apache/airflow/pull/58767#discussion_r2567884066


##########
task-sdk/tests/task_sdk/execution_time/test_task_runner.py:
##########
@@ -2662,6 +2663,50 @@ def execute(self, context):
                 )
                 assert kwargs["from_email"] == self.FROM
 
+    def test_rendered_templates_mask_secrets(self, create_runtime_ti, 
mock_supervisor_comms):
+        """Test that secrets registered with mask_secret() are redacted in 
rendered template fields."""
+        from airflow.sdk.log import mask_secret
+
+        class CustomOperator(BaseOperator):
+            template_fields = ("username", "region")
+
+            def __init__(self, username, region, *args, **kwargs):
+                super().__init__(*args, **kwargs)
+                self.username = username
+                self.region = region
+
+            def execute(self, context):
+                # Only mask username
+                mask_secret(self.username)
+
+        task = CustomOperator(
+            task_id="test_masking",
+            username="admin_user_12345",
+            region="us-west-2",
+        )
+
+        runtime_ti = create_runtime_ti(task=task, 
dag_id="test_secrets_in_rtif")
+        run(runtime_ti, context=runtime_ti.get_template_context(), 
log=mock.MagicMock())
+
+        assert (
+            call(
+                msg=SetRenderedFields(
+                    rendered_fields={"username": "admin_user_12345", "region": 
"us-west-2"},

Review Comment:
   You are right, needs adding of the decorator for redaction and registering 
with the masker



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