Remove passlib assumption from pycrypto tests

This commit is contained in:
Marek Czernek 2024-07-17 16:21:11 +02:00 committed by Daniel Wozniak
parent 29d4137e0b
commit 0675d1fec7

View file

@ -57,21 +57,20 @@ def test_gen_hash_crypt(algorithm, expected):
"""
Test gen_hash with crypt library
"""
with patch("salt.utils.pycrypto.methods", {}):
ret = salt.utils.pycrypto.gen_hash(
crypt_salt=expected["salt"], password=passwd, algorithm=algorithm
)
assert ret == expected["hashed"]
ret = salt.utils.pycrypto.gen_hash(
crypt_salt=expected["salt"], password=passwd, algorithm=algorithm
)
assert ret == expected["hashed"]
ret = salt.utils.pycrypto.gen_hash(
crypt_salt=expected["badsalt"], password=passwd, algorithm=algorithm
)
assert ret != expected["hashed"]
ret = salt.utils.pycrypto.gen_hash(
crypt_salt=expected["badsalt"], password=passwd, algorithm=algorithm
)
assert ret != expected["hashed"]
ret = salt.utils.pycrypto.gen_hash(
crypt_salt=None, password=passwd, algorithm=algorithm
)
assert ret != expected["hashed"]
ret = salt.utils.pycrypto.gen_hash(
crypt_salt=None, password=passwd, algorithm=algorithm
)
assert ret != expected["hashed"]
@pytest.mark.skipif(not salt.utils.pycrypto.HAS_CRYPT, reason="crypt not available")