From d7a5db711bf9aa3f4ff43cee2785f7eb5d16ee87 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 21 Apr 2019 02:24:46 -0400 Subject: [PATCH] Add test and fix current user password change view Signed-off-by: Roberto Rosario --- mayan/apps/authentication/tests/test_views.py | 19 +++++++++++++++++++ mayan/apps/authentication/views.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/mayan/apps/authentication/tests/test_views.py b/mayan/apps/authentication/tests/test_views.py index e67d00826a..70e0a1c788 100644 --- a/mayan/apps/authentication/tests/test_views.py +++ b/mayan/apps/authentication/tests/test_views.py @@ -19,6 +19,25 @@ from ..settings import setting_maximum_session_length from .literals import TEST_EMAIL_AUTHENTICATION_BACKEND +class CurrentUserViewTestCase(GenericViewTestCase): + def test_current_user_set_password_view(self): + new_password = 'new_password_123' + + response = self.post( + viewname='authentication:password_change_view', data={ + 'old_password': self._test_case_user.cleartext_password, + 'new_password1': new_password, + 'new_password2': new_password + }, follow=True + # The follow is to test this and the next redirect, two tests in + # one. + ) + self.assertEqual(response.status_code, 200) + + self._test_case_user.refresh_from_db() + self.assertTrue(self._test_case_user.check_password(raw_password=new_password)) + + class UserLoginTestCase(GenericViewTestCase): """ Test that users can login via the supported authentication methods diff --git a/mayan/apps/authentication/views.py b/mayan/apps/authentication/views.py index d6d7232d8f..f0d1823778 100644 --- a/mayan/apps/authentication/views.py +++ b/mayan/apps/authentication/views.py @@ -69,7 +69,7 @@ class MayanPasswordChangeDoneView(PasswordChangeDoneView): message=_('Your password has been successfully changed.'), request=self.request ) - return redirect(to='common:current_user_details') + return redirect(to='user_management:current_user_details') class MayanPasswordChangeView(PasswordChangeView):