UT: Add nt/lm hash unit test and data
This commit is contained in:
parent
12bc514a92
commit
f018b85f56
|
@ -0,0 +1,20 @@
|
|||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def valid_ntlm_hash() -> str:
|
||||
return "E520AC67419A9A224A3B108F3FA6CB6D"
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def invalid_ntlm_hashes() -> List[str]:
|
||||
return [
|
||||
0,
|
||||
1,
|
||||
2.0,
|
||||
"invalid",
|
||||
"0123456789012345678901234568901",
|
||||
"E52GAC67419A9A224A3B108F3FA6CB6D",
|
||||
]
|
|
@ -0,0 +1,14 @@
|
|||
import pytest
|
||||
|
||||
from common.credentials import NTHash
|
||||
|
||||
|
||||
def test_construct_valid_nt_hash(valid_ntlm_hash):
|
||||
# This test will fail if an exception is raised
|
||||
NTHash(nt_hash=valid_ntlm_hash)
|
||||
|
||||
|
||||
def test_construct_invalid_nt_hash(invalid_ntlm_hashes):
|
||||
for invalid_hash in invalid_ntlm_hashes:
|
||||
with pytest.raises(ValueError):
|
||||
NTHash(nt_hash=invalid_hash)
|
|
@ -1,26 +0,0 @@
|
|||
import pytest
|
||||
|
||||
from common.credentials import InvalidCredentialComponentError, LMHash, NTHash
|
||||
|
||||
VALID_HASH = "E520AC67419A9A224A3B108F3FA6CB6D"
|
||||
INVALID_HASHES = (
|
||||
0,
|
||||
1,
|
||||
2.0,
|
||||
"invalid",
|
||||
"0123456789012345678901234568901",
|
||||
"E52GAC67419A9A224A3B108F3FA6CB6D",
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ntlm_hash_class", (LMHash, NTHash))
|
||||
def test_construct_valid_ntlm_hash(ntlm_hash_class):
|
||||
# This test will fail if an exception is raised
|
||||
ntlm_hash_class(VALID_HASH)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ntlm_hash_class", (LMHash, NTHash))
|
||||
def test_construct_invalid_ntlm_hash(ntlm_hash_class):
|
||||
for invalid_hash in INVALID_HASHES:
|
||||
with pytest.raises(InvalidCredentialComponentError):
|
||||
ntlm_hash_class(invalid_hash)
|
Loading…
Reference in New Issue