diff --git a/AUTHORS.md b/AUTHORS.md index 1eff52cdc..6a4e0241f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -176,6 +176,7 @@ date of first contribution): * [Moiz Rasheed](https://github.com/msrasheed) * [Scott Martin](https://github.com/smartin015) * [Shyam Sunder](https://github.com/sgsunder) + * [Christopher Perrin](https://github.com/cperrin88) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/access/users.py b/src/octoprint/access/users.py index 25facd782..20285bdd6 100644 --- a/src/octoprint/access/users.py +++ b/src/octoprint/access/users.py @@ -27,7 +27,7 @@ try: # test if we can actually hash and verify, if not we won't use this backend hash = argon2.hash("test") - argon2.verify("test", hash) + assert argon2.verify("test", hash) password_hashers.append(argon2) except Exception: diff --git a/tests/access/users/test_usermanager.py b/tests/access/users/test_usermanager.py index b566492dc..29a6312ba 100644 --- a/tests/access/users/test_usermanager.py +++ b/tests/access/users/test_usermanager.py @@ -21,3 +21,17 @@ class UserManagerTest(unittest.TestCase): # should not throw an exception octoprint.access.users.UserManager.create_password_hash(password) + + def test_createPasswordHash_is_valid(self): + password = "test1234" + password_hash = octoprint.access.users.UserManager.create_password_hash(password) + user = octoprint.access.users.User( + "username", + password_hash, + True, + permissions=[], + apikey="apikey", + settings={"key": "value"}, + ) + + self.assertTrue(user.check_password(password))