Skip to content

Commit

Permalink
test: add test for lowercase email address
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschreiber committed Oct 23, 2023
1 parent 3dfe5a5 commit 5153ba5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions terraso_backend/tests/collaboration/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def pending_membership_not_registered_mixed_case_email():
return mixer.blend(Membership, pending_email="[email protected]", user=None)


@pytest.fixture
def pending_membership_not_registered_lowercase_email():
return mixer.blend(Membership, pending_email="[email protected]", user=None)


@mock_s3
def test_signup_signal_membership_update_with_mixed_case_email(
client, access_tokens_google, pending_membership_not_registered_mixed_case_email, respx_mock
Expand All @@ -49,3 +54,22 @@ def test_signup_signal_membership_update_with_mixed_case_email(

membership = Membership.objects.get(id=pending_membership_not_registered_mixed_case_email.id)
assert membership.user is not None


@mock_s3
def test_signup_signal_membership_update_with_lowercase_email(
client, access_tokens_google, pending_membership_not_registered_lowercase_email, respx_mock
):
membership = Membership.objects.get(id=pending_membership_not_registered_lowercase_email.id)
assert membership.user is None

respx_mock.post(GoogleProvider.GOOGLE_TOKEN_URI).mock(
return_value=Response(200, json=access_tokens_google)
)
url = reverse("terraso_auth:google-callback")
response = client.get(url, {"code": "testing-code-google-auth"})

assert response.status_code == 302

membership = Membership.objects.get(id=pending_membership_not_registered_lowercase_email.id)
assert membership.user is not None

0 comments on commit 5153ba5

Please sign in to comment.