fix tests

This commit is contained in:
Matthieu Bourgain 2024-04-19 15:47:12 +02:00
commit 07ffdeb9d9
No known key found for this signature in database
GPG key ID: 33BA95C808890C39
3 changed files with 18 additions and 7 deletions

View file

@ -106,7 +106,8 @@ def _sha256_digest(key, salt, loops):
def mysql_sha256_password_hash_hex(password, salt):
"""Return a MySQL compatible caching_sha2_password hash in hex format."""
assert len(salt) == 20, "Salt must be 20 characters long."
if len(salt) != 20:
raise ValueError("Salt must be 20 characters long.")
count = 5
iteration = 1000 * count

View file

@ -191,7 +191,7 @@ def user_add(cursor, user, host, host_all, password, encrypted,
generated_hash_string = mysql_sha256_password_hash_hex(password=plugin_auth_string, salt=salt)
else:
module.fail_json(msg="salt not handled for %s authentication plugin" % plugin)
query_with_args = "CREATE USER %s@%s IDENTIFIED WITH %s AS %s", (user, host, plugin, generated_hash_string)
query_with_args = "CREATE USER %s@%s IDENTIFIED WITH %s AS 0x%s", (user, host, plugin, generated_hash_string)
else:
query_with_args = "CREATE USER %s@%s IDENTIFIED WITH %s BY %s", (user, host, plugin, plugin_auth_string)
elif plugin:
@ -372,7 +372,7 @@ def user_mod(cursor, user, host, host_all, password, encrypted,
generated_hash_string = mysql_sha256_password_hash_hex(password=plugin_auth_string, salt=salt)
else:
module.fail_json(msg="salt not handled for %s authentication plugin" % plugin)
query_with_args = "ALTER USER %s@%s IDENTIFIED WITH %s AS %s", (user, host, plugin, generated_hash_string)
query_with_args = "ALTER USER %s@%s IDENTIFIED WITH %s AS 0x%s", (user, host, plugin, generated_hash_string)
else:
query_with_args = "ALTER USER %s@%s IDENTIFIED WITH %s BY %s", (user, host, plugin, plugin_auth_string)
else: