mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #25232 -- Made ModelBackend/RemoteUserBackend reject inactive users.
This commit is contained in:
committed by
Tim Graham
parent
1555d50ea4
commit
e0a3d93730
@@ -145,6 +145,11 @@ class RemoteUserTest(TestCase):
|
||||
# In backends that do not create new users, it is '' (anonymous user)
|
||||
self.assertNotEqual(response.context['user'].username, 'knownuser')
|
||||
|
||||
def test_inactive_user(self):
|
||||
User.objects.create(username='knownuser', is_active=False)
|
||||
response = self.client.get('/remote_user/', **{self.header: 'knownuser'})
|
||||
self.assertTrue(response.context['user'].is_anonymous())
|
||||
|
||||
|
||||
class RemoteUserNoCreateBackend(RemoteUserBackend):
|
||||
"""Backend that doesn't create unknown users."""
|
||||
@@ -166,6 +171,16 @@ class RemoteUserNoCreateTest(RemoteUserTest):
|
||||
self.assertEqual(User.objects.count(), num_users)
|
||||
|
||||
|
||||
class AllowAllUsersRemoteUserBackendTest(RemoteUserTest):
|
||||
"""Backend that allows inactive users."""
|
||||
backend = 'django.contrib.auth.backends.AllowAllUsersRemoteUserBackend'
|
||||
|
||||
def test_inactive_user(self):
|
||||
user = User.objects.create(username='knownuser', is_active=False)
|
||||
response = self.client.get('/remote_user/', **{self.header: self.known_user})
|
||||
self.assertEqual(response.context['user'].username, user.username)
|
||||
|
||||
|
||||
class CustomRemoteUserBackend(RemoteUserBackend):
|
||||
"""
|
||||
Backend that overrides RemoteUserBackend methods.
|
||||
|
||||
Reference in New Issue
Block a user