summaryrefslogtreecommitdiff
path: root/tests/auth_tests
diff options
context:
space:
mode:
authorieatkittens <samuelm@gadventures.com>2016-03-11 17:22:51 -0500
committerTim Graham <timograham@gmail.com>2016-03-12 16:44:39 -0500
commitab8af342b1d5dbe40502f1adfe8c7a6b746c8004 (patch)
tree58980fec0fc68db49f2a750515e7765d2026b1e7 /tests/auth_tests
parentb3610f38facb33704c1fd77590c6a2fa07c40fa7 (diff)
Fixed #26343 -- Sent user_login_failed signal if an auth backend raises PermissionDenied.
Diffstat (limited to 'tests/auth_tests')
-rw-r--r--tests/auth_tests/test_auth_backends.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/auth_tests/test_auth_backends.py b/tests/auth_tests/test_auth_backends.py
index 2f28c6cdf1..fee1a66bd4 100644
--- a/tests/auth_tests/test_auth_backends.py
+++ b/tests/auth_tests/test_auth_backends.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from datetime import date
from django.contrib.auth import (
- BACKEND_SESSION_KEY, SESSION_KEY, authenticate, get_user,
+ BACKEND_SESSION_KEY, SESSION_KEY, authenticate, get_user, signals,
)
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.hashers import MD5PasswordHasher
@@ -475,12 +475,21 @@ class PermissionDeniedBackendTest(TestCase):
def setUp(self):
self.user1 = User.objects.create_user('test', 'test@example.com', 'test')
- self.user1.save()
+ self.user_login_failed = []
+ signals.user_login_failed.connect(self.user_login_failed_listener)
+
+ def tearDown(self):
+ signals.user_login_failed.disconnect(self.user_login_failed_listener)
+
+ def user_login_failed_listener(self, sender, credentials, **kwargs):
+ self.user_login_failed.append(credentials)
@modify_settings(AUTHENTICATION_BACKENDS={'prepend': backend})
def test_permission_denied(self):
"user is not authenticated after a backend raises permission denied #2550"
self.assertEqual(authenticate(username='test', password='test'), None)
+ # user_login_failed signal is sent.
+ self.assertEqual(self.user_login_failed, [{'password': '********************', 'username': 'test'}])
@modify_settings(AUTHENTICATION_BACKENDS={'append': backend})
def test_authenticates(self):