forked from p15670423/monkey
Common: Use SecretEncodingConfig in credentials_stolen_events.py
This commit is contained in:
parent
9577c5569e
commit
46f7390a05
|
@ -4,6 +4,7 @@ from pydantic import Field
|
|||
|
||||
from common.credentials import Credentials
|
||||
|
||||
from ..credentials.encoding import SecretEncodingConfig
|
||||
from . import AbstractAgentEvent
|
||||
|
||||
|
||||
|
@ -16,3 +17,6 @@ class CredentialsStolenEvent(AbstractAgentEvent):
|
|||
"""
|
||||
|
||||
stolen_credentials: Sequence[Credentials] = Field(default_factory=list)
|
||||
|
||||
class Config(SecretEncodingConfig):
|
||||
pass
|
||||
|
|
|
@ -16,8 +16,7 @@ from tests.data_for_tests.propagation_credentials import (
|
|||
)
|
||||
|
||||
from common.base_models import InfectionMonkeyBaseModel
|
||||
from common.credentials import Credentials
|
||||
from common.credentials.credentials import get_plaintext
|
||||
from common.credentials import Credentials, get_plaintext
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
from tests.data_for_tests.propagation_credentials import (
|
||||
CREDENTIALS,
|
||||
PLAINTEXT_LM_HASH,
|
||||
PLAINTEXT_NT_HASH,
|
||||
PLAINTEXT_PASSWORD,
|
||||
PLAINTEXT_PRIVATE_KEY,
|
||||
)
|
||||
from tests.unit_tests.monkey_island.cc.models.test_agent import AGENT_ID
|
||||
|
||||
from common.events import CredentialsStolenEvent
|
||||
|
||||
TEST_EVENT = CredentialsStolenEvent(stolen_credentials=CREDENTIALS, source=AGENT_ID)
|
||||
|
||||
|
||||
def test_credentials_stolen_event_serialization_json():
|
||||
serialized_event = TEST_EVENT.json()
|
||||
assert PLAINTEXT_PASSWORD in serialized_event
|
||||
assert PLAINTEXT_LM_HASH in serialized_event
|
||||
assert PLAINTEXT_NT_HASH in serialized_event
|
||||
assert PLAINTEXT_PRIVATE_KEY in serialized_event
|
||||
|
||||
|
||||
def test_credential_stolen_event_deserialization_json():
|
||||
serialized_event = TEST_EVENT.json()
|
||||
deserialized_event = CredentialsStolenEvent.parse_raw(serialized_event)
|
||||
assert deserialized_event == TEST_EVENT
|
Loading…
Reference in New Issue