summaryrefslogtreecommitdiff
path: root/tests/auth_tests/test_remote_user.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auth_tests/test_remote_user.py')
-rw-r--r--tests/auth_tests/test_remote_user.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auth_tests/test_remote_user.py b/tests/auth_tests/test_remote_user.py
index a413b97ee4..4e916d80ec 100644
--- a/tests/auth_tests/test_remote_user.py
+++ b/tests/auth_tests/test_remote_user.py
@@ -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.