summaryrefslogtreecommitdiff
path: root/tests/auth_tests
diff options
context:
space:
mode:
authorCamilo Nova <camilo.nova@gmail.com>2017-03-07 19:52:26 -0500
committerTim Graham <timograham@gmail.com>2017-03-07 19:54:23 -0500
commit33d2c53fb150d58fe4b212438050eea28bf4bf6f (patch)
tree5e0d6e70e94a606248664d46401668b40f79a4b1 /tests/auth_tests
parent36d640cd1f00493688145dff2ae1c3f19efdb8e7 (diff)
[1.11.x] Fixed #27891 -- Added PasswordResetConfirmView.post_reset_login_backend.
Backport of 5db465d5a6c389b8f9c6e21f7233be9387dc069d from master
Diffstat (limited to 'tests/auth_tests')
-rw-r--r--tests/auth_tests/test_views.py20
-rw-r--r--tests/auth_tests/urls.py7
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/auth_tests/test_views.py b/tests/auth_tests/test_views.py
index 07989a23b0..a66d1e5809 100644
--- a/tests/auth_tests/test_views.py
+++ b/tests/auth_tests/test_views.py
@@ -10,7 +10,9 @@ from importlib import import_module
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,
)
@@ -331,6 +333,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/')
diff --git a/tests/auth_tests/urls.py b/tests/auth_tests/urls.py
index c1bb5aae49..3c85b52564 100644
--- a/tests/auth_tests/urls.py
+++ b/tests/auth_tests/urls.py
@@ -90,6 +90,13 @@ urlpatterns = auth_urlpatterns + [
views.PasswordResetConfirmView.as_view(success_url=reverse_lazy('password_reset'))),
url(r'^reset/post_reset_login/{}/$'.format(uid_token),
views.PasswordResetConfirmView.as_view(post_reset_login=True)),
+ url(
+ r'^reset/post_reset_login_custom_backend/{}/$'.format(uid_token),
+ views.PasswordResetConfirmView.as_view(
+ post_reset_login=True,
+ post_reset_login_backend='django.contrib.auth.backends.AllowAllUsersModelBackend',
+ ),
+ ),
url(r'^password_change/custom/$',
views.PasswordChangeView.as_view(success_url='/custom/')),
url(r'^password_change/custom/named/$',