From 2ff57f865a718d84cecaf6c7a9ca6de514aacefd Mon Sep 17 00:00:00 2001 From: Ahmed Karic Date: Thu, 13 Jul 2023 15:01:42 +0200 Subject: [PATCH] test/case: upgrade deprecated hash method --- test/case/ietf_system/add_delete_user.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/case/ietf_system/add_delete_user.py b/test/case/ietf_system/add_delete_user.py index 948c8da3..e4282323 100755 --- a/test/case/ietf_system/add_delete_user.py +++ b/test/case/ietf_system/add_delete_user.py @@ -2,11 +2,12 @@ import infamy import copy -import crypt +from passlib.hash import sha256_crypt import random import string import re + def generate_restrictred_credential(): credential = "".join(random.choices(string.ascii_lowercase, k=64)) @@ -15,6 +16,7 @@ def generate_restrictred_credential(): return credential + with infamy.Test() as test: with test.step("Initialize"): env = infamy.Env(infamy.std_topology("1x1")) @@ -23,8 +25,7 @@ with infamy.Test() as test: with test.step("Add new user"): username = generate_restrictred_credential() password = generate_restrictred_credential() - salt = crypt.mksalt(crypt.METHOD_SHA256) - hashed_password = crypt.crypt(password, salt) + hashed_password = sha256_crypt.using(rounds=5000).hash(password) print(f"username: {username}") print(f"password: {password}") print(f"hashed_password: {hashed_password}")