add missing import for SSHA and add tests

This commit is contained in:
Anthony Bourguignon
2023-02-22 12:49:29 +01:00
parent f44b5607b8
commit 79235b0e7f
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ Advanced (ie. stronger) password hashers.
This module relies on `passlib` to provide more secure hashers.
"""
from passlib.hash import bcrypt, md5_crypt, sha256_crypt, sha512_crypt
from passlib.hash import bcrypt, md5_crypt, sha256_crypt, sha512_crypt, ldap_salted_sha1
try:
from argon2 import PasswordHasher as argon2_hasher
+8 -1
View File
@@ -110,6 +110,12 @@ class AuthenticationTestCase(ModoTestCase):
user.refresh_from_db()
self.assertTrue(user.password.startswith("{SHA256}"))
self.client.logout()
self.set_global_parameter("password_scheme", "ssha")
self.client.post(reverse("core:login"), data)
user.refresh_from_db()
self.assertTrue(user.password.startswith("{SSHA}"))
if argon2 is not None:
self.client.logout()
self.set_global_parameter("password_scheme", "argon2id")
@@ -176,7 +182,7 @@ class AuthenticationTestCase(ModoTestCase):
"""Validate Dovecot supported schemes with fake command output."""
exec_cmd_mock.return_value = (
0,
"MD5 MD5-CRYPT SHA SHA1 SHA256 SHA512 SMD5 SSHA SSHA256 SSHA512 "
"MD5 MD5-CRYPT SHA SHA1 SSHA SHA256 SHA512 SMD5 SSHA SSHA256 SSHA512 "
"PLAIN CLEAR CLEARTEXT PLAIN-TRUNC CRAM-MD5 SCRAM-SHA-1 HMAC-MD5 "
"DIGEST-MD5 PLAIN-MD4 PLAIN-MD5 LDAP-MD5 LANMAN NTLM OTP SKEY RPA "
"PBKDF2 CRYPT SHA256-CRYPT SHA512-CRYPT"
@@ -187,6 +193,7 @@ class AuthenticationTestCase(ModoTestCase):
"{MD5-CRYPT}",
"{SHA}",
"{SHA1}",
"{SSHA}",
"{SHA256}",
"{SHA512}",
"{SMD5}",