Skip to content

Commit

Permalink
tests(headless): Verify email of other user while signed in
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Aug 23, 2024
1 parent 560cb24 commit d30b641
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion allauth/headless/account/tests/test_email_verification.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
from allauth.account.models import EmailAddress, get_emailconfirmation_model
from allauth.account.models import (
EmailAddress,
EmailConfirmationHMAC,
get_emailconfirmation_model,
)
from allauth.headless.constants import Flow


def test_verify_email_other_user(auth_client, user, user_factory, headless_reverse):
other_user = user_factory(email_verified=False)
email_address = EmailAddress.objects.get(user=other_user, verified=False)
assert not email_address.verified
key = EmailConfirmationHMAC(email_address).key
resp = auth_client.post(
headless_reverse("headless:account:verify_email"),
data={"key": key},
content_type="application/json",
)
assert resp.status_code == 200
data = resp.json()
# We're still authenticated as the user originally logged in, not the
# other_user.
assert data["data"]["user"]["id"] == user.pk


def test_auth_unverified_email(
client, user_factory, password_factory, settings, headless_reverse
):
Expand Down

0 comments on commit d30b641

Please sign in to comment.