diff options
| author | Tim Graham <timograham@gmail.com> | 2018-01-23 13:20:18 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-02-01 09:18:33 -0500 |
| commit | 57b95fedad5e0b83fc9c81466b7d1751c6427aae (patch) | |
| tree | 1f6f1066fc8aa01e89124875bdb9dd62073bc9c4 /tests/auth_tests/test_forms.py | |
| parent | 1c9233b1b9f903e4e2cb20a724e8c22aee4aacb2 (diff) | |
[1.11.x] Fixed CVE-2018-6188 -- Fixed information leakage in AuthenticationForm.
Reverted 359370a8b8ca0efe99b1d4630b291ec060b69225 (refs #28645).
This is a security fix.
Diffstat (limited to 'tests/auth_tests/test_forms.py')
| -rw-r--r-- | tests/auth_tests/test_forms.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/auth_tests/test_forms.py b/tests/auth_tests/test_forms.py index b82bbc58f4..e09285277f 100644 --- a/tests/auth_tests/test_forms.py +++ b/tests/auth_tests/test_forms.py @@ -249,6 +249,9 @@ class UserCreationFormTest(TestDataMixin, TestCase): ) +# To verify that the login form rejects inactive users, use an authentication +# backend that allows them. +@override_settings(AUTHENTICATION_BACKENDS=['django.contrib.auth.backends.AllowAllUsersModelBackend']) class AuthenticationFormTest(TestDataMixin, TestCase): def test_invalid_username(self): @@ -278,6 +281,24 @@ class AuthenticationFormTest(TestDataMixin, TestCase): self.assertFalse(form.is_valid()) self.assertEqual(form.non_field_errors(), [force_text(form.error_messages['inactive'])]) + # Use an authentication backend that rejects inactive users. + @override_settings(AUTHENTICATION_BACKENDS=['django.contrib.auth.backends.ModelBackend']) + def test_inactive_user_incorrect_password(self): + """An invalid login doesn't leak the inactive status of a user.""" + data = { + 'username': 'inactive', + 'password': 'incorrect', + } + form = AuthenticationForm(None, data) + self.assertFalse(form.is_valid()) + self.assertEqual( + form.non_field_errors(), [ + form.error_messages['invalid_login'] % { + 'username': User._meta.get_field('username').verbose_name + } + ] + ) + def test_login_failed(self): signal_calls = [] |
