diff options
| author | Camilo Nova <camilo.nova@gmail.com> | 2017-03-07 19:52:26 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-03-07 19:52:26 -0500 |
| commit | 5db465d5a6c389b8f9c6e21f7233be9387dc069d (patch) | |
| tree | c4bad7cdac2348067445553cb206f432f38a64b0 /tests/auth_tests/test_views.py | |
| parent | 72ff9d53e66d6b59ae5d8a1b830f5fc798eb75d0 (diff) | |
Fixed #27891 -- Added PasswordResetConfirmView.post_reset_login_backend.
Diffstat (limited to 'tests/auth_tests/test_views.py')
| -rw-r--r-- | tests/auth_tests/test_views.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py index 9284772268..40c48b7e9e 100644 --- a/tests/auth_tests/test_views.py +++ b/tests/auth_tests/test_views.py @@ -8,7 +8,9 @@ from urllib.parse import ParseResult, quote, urlparse from django.apps import apps from django.conf import settings from django.contrib.admin.models import LogEntry -from django.contrib.auth import REDIRECT_FIELD_NAME, SESSION_KEY +from django.contrib.auth import ( + BACKEND_SESSION_KEY, REDIRECT_FIELD_NAME, SESSION_KEY, +) from django.contrib.auth.forms import ( AuthenticationForm, PasswordChangeForm, SetPasswordForm, ) @@ -327,6 +329,22 @@ class PasswordResetTest(AuthViewsTestCase): self.assertRedirects(response, '/reset/done/', fetch_redirect_response=False) self.assertIn(SESSION_KEY, self.client.session) + @override_settings( + AUTHENTICATION_BACKENDS=[ + 'django.contrib.auth.backends.ModelBackend', + 'django.contrib.auth.backends.AllowAllUsersModelBackend', + ] + ) + def test_confirm_login_post_reset_custom_backend(self): + # This backend is specified in the url(). + backend = 'django.contrib.auth.backends.AllowAllUsersModelBackend' + url, path = self._test_confirm_start() + path = path.replace('/reset/', '/reset/post_reset_login_custom_backend/') + response = self.client.post(path, {'new_password1': 'anewpassword', 'new_password2': 'anewpassword'}) + self.assertRedirects(response, '/reset/done/', fetch_redirect_response=False) + self.assertIn(SESSION_KEY, self.client.session) + self.assertEqual(self.client.session[BACKEND_SESSION_KEY], backend) + def test_confirm_login_post_reset_already_logged_in(self): url, path = self._test_confirm_start() path = path.replace('/reset/', '/reset/post_reset_login/') |
