summaryrefslogtreecommitdiff
path: root/tests/test_client
diff options
context:
space:
mode:
authorBen Demboski <ben@joltlabs.com>2016-08-05 17:18:12 -0700
committerTim Graham <timograham@gmail.com>2016-08-06 08:42:17 -0400
commitd68b145a6f6e5e5dc1775cdaa904d83ee28ed615 (patch)
treeeb985d0576eaf85b45b8f4df6237225b589c926e /tests/test_client
parent9f79fe756f60082e97ce84347a4b2f4cfd098c6d (diff)
[1.10.x] Fixed #27027 -- Restored Client.force_login() defaulting to the first auth backend.
Backport of fc8f097117af7ada616fad20ae5b417fcf740413 from master
Diffstat (limited to 'tests/test_client')
-rw-r--r--tests/test_client/tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index 5594e71e12..f50d863c24 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -532,12 +532,30 @@ class ClientTest(TestCase):
# Log in
self.client.force_login(self.u1, backend='test_client.auth_backends.TestClientBackend')
+ self.assertEqual(self.u1.backend, 'test_client.auth_backends.TestClientBackend')
# Request a page that requires a login
response = self.client.get('/login_protected_view/')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context['user'].username, 'testclient')
+ @override_settings(
+ AUTHENTICATION_BACKENDS=[
+ 'django.contrib.auth.backends.ModelBackend',
+ 'test_client.auth_backends.TestClientBackend',
+ ],
+ )
+ def test_force_login_without_backend(self):
+ """
+ force_login() without passing a backend and with multiple backends
+ configured should automatically use the first backend.
+ """
+ self.client.force_login(self.u1)
+ response = self.client.get('/login_protected_view/')
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.context['user'].username, 'testclient')
+ 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()