Quellcode durchsuchen

fix for incomplete https://github.com/Kozea/Radicale/pull/1425 and test

Peter Bieringer vor 2 Jahren
Ursprung
Commit
9c9be73093
2 geänderte Dateien mit 10 neuen und 0 gelöschten Zeilen
  1. 4 0
      radicale/auth/htpasswd.py
  2. 6 0
      radicale/tests/test_auth.py

+ 4 - 0
radicale/auth/htpasswd.py

@@ -74,6 +74,10 @@ class Auth(auth.BaseAuth):
             self._verify = self._plain
         elif encryption == "md5":
             self._verify = self._md5apr1
+        elif encryption == "sha256":
+            self._verify = self._sha256
+        elif encryption == "sha512":
+            self._verify = self._sha512
         elif encryption == "bcrypt" or encryption == "autodetect":
             try:
                 import bcrypt

+ 6 - 0
radicale/tests/test_auth.py

@@ -82,6 +82,12 @@ class TestBaseAuthRequests(BaseTest):
         self._test_htpasswd(
             "md5", "😀:$apr1$w4ev89r1$29xO8EvJmS2HEAadQ5qy11", "unicode")
 
+    def test_htpasswd_sha256(self) -> None:
+        self._test_htpasswd("sha256", "tmp:$5$i4Ni4TQq6L5FKss5$ilpTjkmnxkwZeV35GB9cYSsDXTALBn6KtWRJAzNlCL/")
+
+    def test_htpasswd_sha512(self) -> None:
+        self._test_htpasswd("sha512", "tmp:$6$3Qhl8r6FLagYdHYa$UCH9yXCed4A.J9FQsFPYAOXImzZUMfvLa0lwcWOxWYLOF5sE/lF99auQ4jKvHY2vijxmefl7G6kMqZ8JPdhIJ/")
+
     def test_htpasswd_bcrypt(self) -> None:
         self._test_htpasswd("bcrypt", "tmp:$2y$05$oD7hbiQFQlvCM7zoalo/T.MssV3V"
                             "NTRI3w5KDnj8NTUKJNWfVpvRq")