summaryrefslogtreecommitdiff
path: root/tests/test_client
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_client')
-rw-r--r--tests/test_client/auth_backends.py4
-rw-r--r--tests/test_client/tests.py11
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_client/auth_backends.py b/tests/test_client/auth_backends.py
index c886dce336..1bb1d96eeb 100644
--- a/tests/test_client/auth_backends.py
+++ b/tests/test_client/auth_backends.py
@@ -3,3 +3,7 @@ from django.contrib.auth.backends import ModelBackend
class TestClientBackend(ModelBackend):
pass
+
+
+class BackendWithoutGetUserMethod(object):
+ pass
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index d3eb782347..a499ee7fce 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -549,6 +549,17 @@ class ClientTest(TestCase):
self.assertEqual(response.context['user'].username, 'testclient')
self.assertEqual(self.u1.backend, 'django.contrib.auth.backends.ModelBackend')
+ @override_settings(AUTHENTICATION_BACKENDS=[
+ 'test_client.auth_backends.BackendWithoutGetUserMethod',
+ 'django.contrib.auth.backends.ModelBackend',
+ ])
+ def test_force_login_with_backend_missing_get_user(self):
+ """
+ force_login() skips auth backends without a get_user() method.
+ """
+ self.client.force_login(self.u1)
+ self.assertEqual(self.u1.backend, 'django.contrib.auth.backends.ModelBackend')
+
@override_settings(SESSION_ENGINE="django.contrib.sessions.backends.signed_cookies")
def test_logout_cookie_sessions(self):
self.test_logout()