aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-03-08 11:42:04 +0300
committerFrederick Muriuki Muriithi2023-03-08 11:42:04 +0300
commita35d16f9a191afbb31e2c185e87e5eec5e23122f (patch)
tree2e56592510b7c4c8a53f513999d7104c1a1eb51a /tests
parent5a8cc0d7fc241494580cd4a060690eaf09ff46d7 (diff)
downloadgenenetwork3-a35d16f9a191afbb31e2c185e87e5eec5e23122f.tar.gz
auth: users: Use the same basic functions for password hashing
To avoid repeating the same thing in multiple places, leading to errors and breakages, reuse the same basic functions for password hashing.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/auth/fixtures/user_fixtures.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/tests/unit/auth/fixtures/user_fixtures.py b/tests/unit/auth/fixtures/user_fixtures.py
index 4e42abe..d248f54 100644
--- a/tests/unit/auth/fixtures/user_fixtures.py
+++ b/tests/unit/auth/fixtures/user_fixtures.py
@@ -2,10 +2,9 @@
import uuid
import pytest
-import bcrypt
from gn3.auth import db
-from gn3.auth.authentication.users import User
+from gn3.auth.authentication.users import User, hash_password
TEST_USERS = (
User(uuid.UUID("ecb52977-3004-469e-9428-2a1856725c7f"), "group@lead.er",
@@ -50,9 +49,8 @@ def fxtr_users_with_passwords(fxtr_users): # pylint: disable=[redefined-outer-na
"""Fixture: add passwords to the users"""
conn, users = fxtr_users
user_passwords_params = tuple(
- (str(user.user_id), bcrypt.hashpw(
- f"password_for_user_{idx:03}".encode("utf8"),
- bcrypt.gensalt()))
+ (str(user.user_id), hash_password(
+ f"password_for_user_{idx:03}".encode("utf8")))
for idx, user in enumerate(users, start=1))
with db.cursor(conn) as cursor: