1
0
Fork 0

Use password validation in change password flow

This also moves the form validation into a form instead of doing it in
the view.
This commit is contained in:
Mouse Reeve 2022-07-15 10:45:08 -07:00
parent 4a65ee326a
commit 659ee96002
4 changed files with 70 additions and 45 deletions

View file

@ -46,8 +46,8 @@ class ChangePasswordViews(TestCase):
"",
{
"current_password": "password",
"password": "hi",
"confirm-password": "hi",
"password": "longwordsecure",
"confirm_password": "longwordsecure",
},
)
request.user = self.local_user
@ -64,8 +64,8 @@ class ChangePasswordViews(TestCase):
"",
{
"current_password": "not my password",
"password": "hi",
"confirm-password": "hihi",
"password": "longwordsecure",
"confirm_password": "hihi",
},
)
request.user = self.local_user
@ -81,8 +81,25 @@ class ChangePasswordViews(TestCase):
"",
{
"current_password": "password",
"password": "hi",
"confirm-password": "hihi",
"password": "longwordsecure",
"confirm_password": "hihi",
},
)
request.user = self.local_user
result = view(request)
validate_html(result.render())
self.assertEqual(self.local_user.password, password_hash)
def test_password_change_invalid(self):
"""change password"""
view = views.ChangePassword.as_view()
password_hash = self.local_user.password
request = self.factory.post(
"",
{
"current_password": "password",
"password": "hi",
"confirm_password": "hi",
},
)
request.user = self.local_user