1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

Fixed #27542 -- Made Client.force_login() skip auth backends without get_user().

This commit is contained in:
Anton Samarchyan
2016-11-30 13:37:07 -05:00
committed by Tim Graham
parent e690eb405f
commit 47744a0a4e
3 changed files with 22 additions and 1 deletions

View File

@@ -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()