diff options
| author | Alexander Gaevsky <sasha@sasha0.ru> | 2016-02-05 16:46:19 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-03-23 09:01:48 -0400 |
| commit | e0a3d937309a82b8beea8f41b17d8b6298da2a86 (patch) | |
| tree | 0e6cd936b358687686a1f3b99b726da3c6a5ac5f /tests/auth_tests/test_remote_user.py | |
| parent | 1555d50ea40f22524b58e71bf15f3fc69a7c9591 (diff) | |
Fixed #25232 -- Made ModelBackend/RemoteUserBackend reject inactive users.
Diffstat (limited to 'tests/auth_tests/test_remote_user.py')
| -rw-r--r-- | tests/auth_tests/test_remote_user.py | 15 |
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. |
