Skip to content

Commit

Permalink
Added a test for the logging change
Browse files Browse the repository at this point in the history
  • Loading branch information
aritra24 committed Jan 20, 2024
1 parent 7502443 commit 1d9a3c8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/utils/log/test_secrets_masker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import pytest

from airflow import settings
from airflow.models import Connection
from airflow.utils.log.secrets_masker import (
RedactedIO,
SecretsMasker,
Expand Down Expand Up @@ -80,7 +81,6 @@ def logger(caplog):
logger.addFilter(filt)

filt.add_mask("password")

return logger


Expand Down Expand Up @@ -340,6 +340,22 @@ def test_redact_state_enum(self, logger, caplog, state, expected):
assert caplog.text == f"INFO State: {expected}\n"
assert "TypeError" not in caplog.text

def test_masking_quoted_strings_in_connection(self, logger, caplog):
secrets_masker = [fltr for fltr in logger.filters if isinstance(fltr, SecretsMasker)][0]
with patch("airflow.utils.log.secrets_masker._secrets_masker", return_value=secrets_masker):
test_conn_attributes = dict(
conn_type="scheme",
host="host/location",
schema="schema",
login="user",
password="should_be_hidden!",
port=1234,
extra=None,
)
conn = Connection(**test_conn_attributes)
logger.info(conn.get_uri())
assert "should_be_hidden" not in caplog.text


class TestShouldHideValueForKey:
@pytest.mark.parametrize(
Expand Down

0 comments on commit 1d9a3c8

Please sign in to comment.