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


##########
tests/core/test_configuration.py:
##########
@@ -1763,3 +1763,22 @@ def test_config_paths_is_directory(self):
 
         with pytest.raises(IsADirectoryError, match="configuration file, but 
got a directory"):
             write_default_airflow_configuration_if_needed()
+
+    @patch.object(
+        conf,
+        "sensitive_config_values",
+        new_callable=lambda: [("mysection1", "mykey1"), ("mysection2", 
"mykey2")],
+    )
+    @patch("airflow.utils.log.secrets_masker.mask_secret")
+    @patch("airflow.configuration.conf.get")
+    def test_mask_conf_values(self, mock_get, mock_mask_secret, 
mock_sensitive_config_values):
+        mock_get.side_effect = ["supersecret1", "supersecret2"]
+        conf.mask_secrets()
+
+        mock_get.assert_any_call("mysection1", "mykey1")
+        mock_get.assert_any_call("mysection2", "mykey2")

Review Comment:
   Nit, rather than masking `conf.get` please use the existing `@conf_vars` 
decorator.



##########
tests/core/test_settings.py:
##########
@@ -31,7 +31,11 @@
 from airflow.api_internal.internal_api_call import InternalApiConfig
 from airflow.configuration import conf
 from airflow.exceptions import AirflowClusterPolicyViolation, 
AirflowConfigException
-from airflow.settings import _ENABLE_AIP_44, TracebackSession, 
is_usage_data_collection_enabled
+from airflow.settings import (
+    _ENABLE_AIP_44,
+    TracebackSession,
+    is_usage_data_collection_enabled,
+)

Review Comment:
   Nit: unrelated changes in this file now, lets revert these ones
   
   ```suggestion
   from airflow.settings import _ENABLE_AIP_44, TracebackSession, 
is_usage_data_collection_enabled
   ```



##########
airflow/configuration.py:
##########
@@ -772,6 +772,21 @@ def _create_future_warning(name: str, section: str, 
current_value: Any, new_valu
             stacklevel=3,
         )
 
+    def mask_secrets(self):
+        from airflow.utils.log.secrets_masker import mask_secret
+
+        for section, key in conf.sensitive_config_values:
+            try:
+                value = conf.get(section, key)

Review Comment:
   ```suggestion
           for section, key in self.sensitive_config_values:
               try:
                   value = self.get(section, key)
   ```



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