mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #31443 -- Fixed login redirection in auth mixins when LOGIN_URL is off-site URL.
This commit is contained in:
committed by
Mariusz Felisiak
parent
136ec9b62b
commit
cc7c16af98
@@ -94,6 +94,20 @@ class AccessMixinTests(TestCase):
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response.url, '/accounts/login/?next=/rand')
|
||||
|
||||
def test_access_mixin_permission_denied_remote_login_url(self):
|
||||
class AView(AlwaysFalseView):
|
||||
login_url = 'https://www.remote.example.com/login'
|
||||
|
||||
view = AView.as_view()
|
||||
request = self.factory.get('/rand')
|
||||
request.user = AnonymousUser()
|
||||
response = view(request)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(
|
||||
response.url,
|
||||
'https://www.remote.example.com/login?next=http%3A//testserver/rand',
|
||||
)
|
||||
|
||||
@mock.patch.object(models.User, 'is_authenticated', False)
|
||||
def test_stacked_mixins_not_logged_in(self):
|
||||
user = models.User.objects.create(username='joe', password='qwerty')
|
||||
|
||||
Reference in New Issue
Block a user