1
0
mirror of https://github.com/django/django.git synced 2025-10-31 01:25:32 +00:00

Refs #35959 -- Added render_password_as_hash auth template tag for password rendering.

This commit is contained in:
Sarah Boyce
2025-04-16 15:44:00 -03:00
committed by nessita
parent d469db978e
commit 8a0ad1ebe3
6 changed files with 88 additions and 25 deletions

View File

@@ -1445,6 +1445,29 @@ class ReadOnlyPasswordHashTest(SimpleTestCase):
"</div>",
)
def test_render_no_password(self):
widget = ReadOnlyPasswordHashWidget()
self.assertHTMLEqual(
widget.render("name", None, {}),
"<div><p><strong>No password set.</p><p>"
'<a role="button" class="button" href="../password/">Set password</a>'
"</p></div>",
)
@override_settings(
PASSWORD_HASHERS=["django.contrib.auth.hashers.PBKDF2PasswordHasher"]
)
def test_render_invalid_password_format(self):
widget = ReadOnlyPasswordHashWidget()
value = "pbkdf2_sh"
self.assertHTMLEqual(
widget.render("name", value, {}),
"<div><p>"
"<strong>Invalid password format or unknown hashing algorithm.</strong>"
'</p><p><a role="button" class="button" href="../password/">Reset password'
"</a></p></div>",
)
def test_readonly_field_has_changed(self):
field = ReadOnlyPasswordHashField()
self.assertIs(field.disabled, True)