Maybe working testing of the new redirect functionality
This commit is contained in:
parent
e24bde7917
commit
f51e000af0
@ -1,11 +1,12 @@
|
|||||||
from contextvars import ContextVar
|
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from allauth.account.adapter import get_adapter
|
from allauth.account.adapter import get_adapter
|
||||||
|
from allauth.core import context
|
||||||
from allauth.socialaccount.adapter import get_adapter as get_social_adapter
|
from allauth.socialaccount.adapter import get_adapter as get_social_adapter
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
from django.test import override_settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
@ -21,14 +22,13 @@ class TestCustomAccountAdapter(TestCase):
|
|||||||
settings.ACCOUNT_ALLOW_SIGNUPS = False
|
settings.ACCOUNT_ALLOW_SIGNUPS = False
|
||||||
self.assertFalse(adapter.is_open_for_signup(None))
|
self.assertFalse(adapter.is_open_for_signup(None))
|
||||||
|
|
||||||
@mock.patch("allauth.core.context._request_var")
|
def test_is_safe_url(self):
|
||||||
def test_is_safe_url(self, mock_request_var):
|
|
||||||
request = HttpRequest()
|
request = HttpRequest()
|
||||||
request.get_host = mock.Mock(return_value="example.com")
|
request.get_host = mock.Mock(return_value="example.com")
|
||||||
mock_request_var.return_value = ContextVar("request", default=request)
|
with context.request_context(request):
|
||||||
adapter = get_adapter()
|
adapter = get_adapter()
|
||||||
|
with override_settings(ALLOWED_HOSTS=["*"]):
|
||||||
|
|
||||||
settings.ALLOWED_HOSTS = ["*"]
|
|
||||||
# True because request host is same
|
# True because request host is same
|
||||||
url = "https://example.com"
|
url = "https://example.com"
|
||||||
self.assertTrue(adapter.is_safe_url(url))
|
self.assertTrue(adapter.is_safe_url(url))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user