Skip to content

Commit

Permalink
tests(account): Redirect URL on email verification
Browse files Browse the repository at this point in the history
  • Loading branch information
pennersr committed Sep 5, 2024
1 parent 20e559b commit 5c48f11
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions allauth/account/tests/test_email_verification.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import timedelta
from unittest.mock import Mock

from django.conf import settings
from django.contrib.auth import SESSION_KEY, get_user_model
from django.core.cache import cache
from django.urls import reverse
Expand All @@ -15,6 +14,7 @@
)

from allauth.account import app_settings
from allauth.account.adapter import DefaultAccountAdapter
from allauth.account.models import (
EmailAddress,
EmailConfirmation,
Expand All @@ -23,19 +23,33 @@
from allauth.account.signals import user_logged_in


class TestEmailVerificationAdapter(DefaultAccountAdapter):
SIGNUP_REDIRECT_URL = "/foobar"

def get_signup_redirect_url(self, request):
return self.SIGNUP_REDIRECT_URL


@pytest.mark.parametrize(
"query,expected_location",
"adapter,query,expected_location",
[
("", settings.LOGIN_REDIRECT_URL),
("?next=/foo", "/foo"),
(None, "", app_settings.SIGNUP_REDIRECT_URL),
(None, "?next=/foo", "/foo"),
(
"allauth.account.tests.test_email_verification.TestEmailVerificationAdapter",
"",
TestEmailVerificationAdapter.SIGNUP_REDIRECT_URL,
),
],
)
def test_login_on_verification(
client, db, query, expected_location, password_factory, settings
adapter, client, db, query, expected_location, password_factory, settings
):
settings.ACCOUNT_EMAIL_VERIFICATION = app_settings.EmailVerificationMethod.MANDATORY
settings.ACCOUNT_EMAIL_CONFIRMATION_HMAC = True
settings.ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
if adapter:
settings.ACCOUNT_ADAPTER = adapter
password = password_factory()
resp = client.post(
reverse("account_signup"),
Expand Down

0 comments on commit 5c48f11

Please sign in to comment.