UT: Add NTHashSchema

This commit is contained in:
Mike Salvatore 2022-07-06 12:07:44 -04:00
parent def2381da6
commit 58fcc3761c
2 changed files with 25 additions and 1 deletions

View File

@ -1,6 +1,15 @@
from dataclasses import dataclass, field
from marshmallow import fields
from . import CredentialComponentType, ICredentialComponent
from .credential_component_schema import CredentialComponentSchema, CredentialTypeField
from .validators import ntlm_hash_validator
class NTHashSchema(CredentialComponentSchema):
credential_type = CredentialTypeField(CredentialComponentType.NT_HASH)
nt_hash = fields.Str(validate=ntlm_hash_validator)
@dataclass(frozen=True)

View File

@ -1,8 +1,9 @@
import pytest
from marshmallow.exceptions import ValidationError
from common.credentials import CredentialComponentType, LMHash, Password, Username
from common.credentials import CredentialComponentType, LMHash, NTHash, Password, Username
from common.credentials.lm_hash import LMHashSchema
from common.credentials.nt_hash import NTHashSchema
from common.credentials.password import PasswordSchema
from common.credentials.username import UsernameSchema
@ -20,6 +21,13 @@ PARAMETRIZED_PARAMETER_VALUES = [
"lm_hash",
"E52CAC67419A9A224A3B108F3FA6CB6D",
),
(
NTHash,
NTHashSchema,
CredentialComponentType.NT_HASH,
"nt_hash",
"E52CAC67419A9A224A3B108F3FA6CB6D",
),
]
@ -33,6 +41,13 @@ INVALID_VALUES = {
"0123456789012345678901234568901",
"E52GAC67419A9A224A3B108F3FA6CB6D",
),
CredentialComponentType.NT_HASH: (
None,
1,
2.0,
"0123456789012345678901234568901",
"E52GAC67419A9A224A3B108F3FA6CB6D",
),
}