UT: added slow marks and changed some names, related to credential tests

This commit is contained in:
vakarisz 2022-02-28 16:59:15 +02:00
parent 748178a00c
commit 4f58a69c54
3 changed files with 9 additions and 3 deletions

View File

@ -158,18 +158,18 @@ def test_get_stolen_creds_exploit(fake_mongo):
@pytest.mark.slow
@pytest.mark.usefixtures("uses_database", "uses_encryptor")
def test_get_stolen_creds_system_info(fake_mongo):
def test_get_stolen_creds_from_db(fake_mongo):
fake_mongo.db.monkey.insert_one(MONKEY_TELEM)
save_telemetry(SYSTEM_INFO_TELEMETRY_TELEM)
stolen_creds_system_info = ReportService.get_stolen_creds()
expected_stolen_creds_system_info = [
expected_stolen_creds_from_db = [
{"origin": HOSTNAME, "type": "Clear Password", "username": USER},
{"origin": HOSTNAME, "type": "LM hash", "username": USER},
{"origin": HOSTNAME, "type": "NTLM hash", "username": USER},
]
assert expected_stolen_creds_system_info == stolen_creds_system_info
assert expected_stolen_creds_from_db == stolen_creds_system_info
@pytest.mark.usefixtures("uses_database")

View File

@ -53,6 +53,7 @@ cred_empty_telem = deepcopy(CREDENTIAL_TELEM_TEMPLATE)
cred_empty_telem["data"] = [{"identities": [], "secrets": []}]
@pytest.mark.slow
@pytest.mark.usefixtures("uses_database", "fake_mongo", "insert_fake_monkey")
def test_cred_username_parsing():
parse_credentials(cred_telem_usernames)
@ -60,6 +61,7 @@ def test_cred_username_parsing():
assert fake_username in dpath.util.get(config, USER_LIST_PATH)
@pytest.mark.slow
@pytest.mark.usefixtures("uses_database", "fake_mongo", "insert_fake_monkey")
def test_cred_special_username_parsing():
parse_credentials(cred_telem_special_usernames)
@ -67,6 +69,7 @@ def test_cred_special_username_parsing():
assert fake_special_username in dpath.util.get(config, USER_LIST_PATH)
@pytest.mark.slow
@pytest.mark.usefixtures("uses_database", "fake_mongo", "insert_fake_monkey")
def test_cred_telemetry_parsing():
parse_credentials(cred_telem)
@ -77,6 +80,7 @@ def test_cred_telemetry_parsing():
assert fake_password in dpath.util.get(config, PASSWORD_LIST_PATH)
@pytest.mark.slow
@pytest.mark.usefixtures("uses_database", "fake_mongo", "insert_fake_monkey")
def test_cred_storage_in_db():
parse_credentials(cred_telem)
@ -90,6 +94,7 @@ def test_cred_storage_in_db():
assert CredentialComponentType.NT_HASH.name in stolen_creds.secrets
@pytest.mark.slow
@pytest.mark.usefixtures("uses_database", "fake_mongo", "insert_fake_monkey")
def test_empty_cred_telemetry_parsing():
default_config = deepcopy(ConfigService.get_config(should_decrypt=True))

View File

@ -32,6 +32,7 @@ ssh_telem = deepcopy(CREDENTIAL_TELEM_TEMPLATE)
ssh_telem["data"] = [{"identities": [fake_identity], "secrets": [fake_secret_full]}]
@pytest.mark.slow
@pytest.mark.usefixtures("uses_encryptor", "uses_database", "fake_mongo", "insert_fake_monkey")
def test_ssh_credential_parsing():
parse_credentials(ssh_telem)