test for modify_user function
@@ -655,6 +655,40 @@ def test_user_duplicates(storage_socket):
assert storage_socket.remove_user("george") is False
+def test_modify_user(storage_socket):
+
+ r, pw = storage_socket.add_user("george", "oldpw", permissions=['write'])
+ assert r is True
+
+ # unknown user
+ r, msg = storage_socket.modify_user("geoff", reset_password=True)
+ assert r is False
+
+ # update password...
+ r, msg = storage_socket.modify_user("george", password="newpw")
+ assert r is True
+ # ... should update the password without changing permissions
+ assert storage_socket.verify_user("george", "newpw", 'write')[0] is True
+
+ # update permissions...
+ r, msg = storage_socket.modify_user("george", permissions=['read', 'write'])
+ assert r is True
+ # ... should update the permissions without changing the password
+ assert storage_socket.verify_user("george", "newpw", 'read')[0] is True
+ assert storage_socket.verify_user("george", "oldpw", 'read')[0] is True
+
+ r, msg = storage_socket.modify_user("george", reset_password=True)
+ print(msg)
+ assert r is True
+ assert storage_socket.verify_user("george", "newpw", 'write')[0] is False
+
+ r, msg = storage_socket.modify_user("george", reset_password=True, password="foo")
+ assert r is False
+
+ assert storage_socket.remove_user("george") is True
+
+
+
def test_user_permissions_default(storage_socket):
r, pw = storage_socket.add_user("george", "shortpw")
