1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #28207 -- Fixed contrib.auth.authenticate() if multiple auth backends don't accept a request.

This commit is contained in:
Tamas Szabo
2017-05-15 06:22:58 +08:00
committed by Tim Graham
parent a7975260b5
commit 3008f30f19
3 changed files with 55 additions and 31 deletions

View File

@@ -50,3 +50,21 @@ class AcceptsRequestBackendTest(SimpleTestCase):
"In %s.authenticate(), move the `request` keyword argument to the "
"first positional argument." % self.request_not_positional_backend
)
@override_settings(AUTHENTICATION_BACKENDS=[request_not_positional_backend, no_request_backend])
def test_both_types_of_deprecation_warning(self):
with warnings.catch_warnings(record=True) as warns:
warnings.simplefilter('always')
authenticate(mock_request, username='username', password='pass')
self.assertEqual(len(warns), 2)
self.assertEqual(
str(warns[0].message),
"In %s.authenticate(), move the `request` keyword argument to the "
"first positional argument." % self.request_not_positional_backend
)
self.assertEqual(
str(warns[1].message),
"Update %s.authenticate() to accept a positional `request` "
"argument." % self.no_request_backend
)