Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airflow-core/src/airflow/cli/commands/connection_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def full_details(conn: Connection) -> dict[str, Any]:
"password": conn.password,
"port": conn.port,
"is_encrypted": conn.is_encrypted,
"is_extra_encrypted": conn.is_encrypted,
"is_extra_encrypted": conn.is_extra_encrypted,
"extra_dejson": conn.extra_dejson,
"get_uri": conn.get_uri(),
}
Expand All @@ -113,7 +113,7 @@ def masked_sensitive(conn: Connection) -> dict[str, Any]:
"password": SENSITIVE_PLACEHOLDER if conn.password else conn.password,
"port": conn.port,
"is_encrypted": conn.is_encrypted,
"is_extra_encrypted": conn.is_encrypted,
"is_extra_encrypted": conn.is_extra_encrypted,
"extra_dejson": SENSITIVE_PLACEHOLDER if conn.extra_dejson else conn.extra_dejson,
"get_uri": _mask_uri_credentials(conn.get_uri()),
}
Expand Down
34 changes: 34 additions & 0 deletions airflow-core/tests/unit/cli/commands/test_connection_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,40 @@ def test_mask_uri_credentials(self, uri, expected):
assert result == expected


class TestConnectionDisplayMapper:
"""Regression tests for ``ConnectionDisplayMapper`` attribute mapping."""

@pytest.mark.parametrize(
"mapper_fn",
[
pytest.param(
connection_command.ConnectionDisplayMapper.full_details,
id="full_details",
),
pytest.param(
connection_command.ConnectionDisplayMapper.masked_sensitive,
id="masked_sensitive",
),
],
)
@pytest.mark.parametrize(
("is_encrypted", "is_extra_encrypted"),
[
pytest.param(True, False, id="password-only-encrypted"),
pytest.param(False, True, id="extra-only-encrypted"),
],
)
def test_maps_encryption_flags_to_correct_keys(self, mapper_fn, is_encrypted, is_extra_encrypted):
conn = Connection(conn_id="test_mapper", conn_type="http")
conn.is_encrypted = is_encrypted
conn.is_extra_encrypted = is_extra_encrypted

result = mapper_fn(conn)

assert result["is_encrypted"] == is_encrypted
assert result["is_extra_encrypted"] == is_extra_encrypted


class TestCliExportConnections:
parser = cli_parser.get_parser()

Expand Down
Loading