Skip to content

Commit

Permalink
Force lower case of email when registering
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Sep 26, 2024
1 parent 70a6646 commit 839f457
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hass_nabucasa/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def async_register(
await self.cloud.run_executor(
partial(
cognito.register,
email,
email.lower(),
password,
client_metadata=client_metadata,
),
Expand Down
11 changes: 11 additions & 0 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ async def test_register(mock_cognito, cloud_mock):
assert call.kwargs["client_metadata"] == {"test": "metadata"}


async def test_register_lowercase_email(mock_cognito, cloud_mock):
"""Test forcing lowercase email when registering an account."""
auth = auth_api.CognitoAuth(cloud_mock)
await auth.async_register("[email protected]", "password")
assert len(mock_cognito.register.mock_calls) == 1

call = mock_cognito.register.mock_calls[0]
result_user = call.args[0]
assert result_user == "[email protected]"


async def test_register_fails(mock_cognito, cloud_mock):
"""Test registering an account."""
mock_cognito.register.side_effect = aws_error("SomeError")
Expand Down

0 comments on commit 839f457

Please sign in to comment.