forked from p15670423/monkey
UT: Compare actual propagation credentials vs expected
This commit is contained in:
parent
794277797b
commit
777897cb74
|
@ -4,3 +4,7 @@ from .open_error_file_repository import OpenErrorFileRepository
|
|||
from .in_memory_agent_configuration_repository import InMemoryAgentConfigurationRepository
|
||||
from .in_memory_simulation_configuration import InMemorySimulationRepository
|
||||
from .stub_propagation_credentials_repository import StubPropagationCredentialsRepository
|
||||
from .stub_propagation_credentials_repository import (
|
||||
PROPAGATION_CREDENTIALS_1,
|
||||
PROPAGATION_CREDENTIALS_2,
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@ fake_lm_hash = "299BD128C1101FD6"
|
|||
fake_password_1 = "trytostealthis"
|
||||
fake_password_2 = "password"
|
||||
fake_password_3 = "12345678"
|
||||
propagation_credentials_1 = {
|
||||
PROPAGATION_CREDENTIALS_1 = {
|
||||
"identities": [{"username": fake_username, "credential_type": "USERNAME"}],
|
||||
"secrets": [
|
||||
{"nt_hash": fake_nt_hash, "credential_type": "NT_HASH"},
|
||||
|
@ -19,7 +19,7 @@ propagation_credentials_1 = {
|
|||
],
|
||||
}
|
||||
|
||||
propagation_credentials_2 = {
|
||||
PROPAGATION_CREDENTIALS_2 = {
|
||||
"identities": [
|
||||
{"username": fake_username, "credential_type": "USERNAME"},
|
||||
{"username": fake_special_username, "credential_type": "USERNAME"},
|
||||
|
@ -42,8 +42,8 @@ class StubPropagationCredentialsRepository(ICredentialsRepository):
|
|||
def get_all_credentials(self) -> Sequence[Credentials]:
|
||||
|
||||
return [
|
||||
Credentials.from_mapping(propagation_credentials_1, monkey_guid="some_guid"),
|
||||
Credentials.from_mapping(propagation_credentials_2, monkey_guid="second_guid"),
|
||||
Credentials.from_mapping(PROPAGATION_CREDENTIALS_1, monkey_guid="some_guid"),
|
||||
Credentials.from_mapping(PROPAGATION_CREDENTIALS_2, monkey_guid="second_guid"),
|
||||
]
|
||||
|
||||
def save_configured_credentials(self, credentials: Credentials):
|
||||
|
|
|
@ -2,7 +2,11 @@ import json
|
|||
|
||||
import pytest
|
||||
from tests.common import StubDIContainer
|
||||
from tests.monkey_island import StubPropagationCredentialsRepository
|
||||
from tests.monkey_island import (
|
||||
PROPAGATION_CREDENTIALS_1,
|
||||
PROPAGATION_CREDENTIALS_2,
|
||||
StubPropagationCredentialsRepository,
|
||||
)
|
||||
from tests.unit_tests.monkey_island.conftest import get_url_for_resource
|
||||
|
||||
from monkey_island.cc.repository import ICredentialsRepository
|
||||
|
@ -25,4 +29,10 @@ def test_propagation_credentials_endpoint_get(flask_client):
|
|||
resp = flask_client.get(propagation_credentials_url)
|
||||
|
||||
assert resp.status_code == 200
|
||||
assert len(json.loads(resp.data)["propagation_credentials"]) == 2
|
||||
actual_propagation_credentials = json.loads(resp.data)["propagation_credentials"]
|
||||
assert len(actual_propagation_credentials) == 2
|
||||
|
||||
del actual_propagation_credentials[0]["monkey_guid"]
|
||||
assert actual_propagation_credentials[0] == PROPAGATION_CREDENTIALS_1
|
||||
del actual_propagation_credentials[1]["monkey_guid"]
|
||||
assert actual_propagation_credentials[1] == PROPAGATION_CREDENTIALS_2
|
||||
|
|
Loading…
Reference in New Issue