summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTamas Szabo <tszabo@ccg.murdoch.edu.au>2017-05-15 06:22:58 +0800
committerTim Graham <timograham@gmail.com>2017-05-15 08:15:18 -0400
commitd945b7e42a8d45cb13b1bd0420b420cf563482f1 (patch)
tree7b171da67e0ddfdad6e7ae8a4d33e416ff9ad4ce /tests
parent84f6098aaf8d9cca521f7776134564b7f5ed704a (diff)
[1.11.x] Fixed #28207 -- Fixed contrib.auth.authenticate() if multiple auth backends don't accept a request.
Backport of 3008f30f194af386c354416be4c483f0f6b15f33 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/auth_tests/test_auth_backends_deprecation.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/auth_tests/test_auth_backends_deprecation.py b/tests/auth_tests/test_auth_backends_deprecation.py
index 0d45fee7a4..7ee53a0bc6 100644
--- a/tests/auth_tests/test_auth_backends_deprecation.py
+++ b/tests/auth_tests/test_auth_backends_deprecation.py
@@ -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
+ )