Skip to content

Commit c8da226

Browse files
fix(data_classes): return None from TransferFamilyAuthorizer.password when the event has none (#8715)
Co-authored-by: Leandro Damascena <lcdama@amazon.pt>
1 parent 8074a54 commit c8da226

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎aws_lambda_powertools/utilities/data_classes/transfer_family_event.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def username(self) -> str:
1818
def password(self) -> str | None:
1919
"""
2020
The password used for authentication.
21-
None in case customer authenticating with certificates
21+
None when the event has no password, e.g. when the user authenticates with an SSH key
2222
"""
23-
return self["password"]
23+
return self.get("password")
2424

2525
@property
2626
def protocol(self) -> str:

‎tests/unit/data_classes/required_dependencies/test_transfer_family_event.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ def test_transfer_family_authorizer_event():
2020
assert parsed_event.source_ip == raw_event["sourceIp"]
2121

2222

23+
def test_transfer_family_authorizer_event_without_password():
24+
# GIVEN an authorizer event with no password, as for a user authenticating with an SSH key
25+
raw_event = load_event("transferFamilyAuthorizer.json")
26+
del raw_event["password"]
27+
28+
# WHEN reading the password
29+
# THEN it is None, matching the property's type and the Pydantic model's default
30+
assert TransferFamilyAuthorizer(raw_event).password is None
31+
32+
2333
@pytest.mark.parametrize("home_directory_type", ["LOGICAL", "PATH"])
2434
def test_build_authentication_response_s3(home_directory_type):
2535
# GIVEN a Authorizer response

0 commit comments

Comments
 (0)