tests: Modify/add tests for ransomware payload as per ransomware config schema changes

This commit is contained in:
Shreya 2021-06-29 16:39:27 +05:30 committed by Mike Salvatore
parent a1efd915b1
commit 392ece29a0
1 changed files with 19 additions and 1 deletions

View File

@ -32,7 +32,13 @@ def with_extension(filename):
@pytest.fixture
def ransomware_payload_config(ransomware_target):
return {
"directories": {"linux_dir": str(ransomware_target), "windows_dir": str(ransomware_target)},
"encryption": {
"should_encrypt": True,
"directories": {
"linux_dir": str(ransomware_target),
"windows_dir": str(ransomware_target),
},
},
"other_behaviors": {"readme": False},
}
@ -127,6 +133,18 @@ def test_skip_already_encrypted_file(ransomware_target, ransomware_payload):
)
def test_encryption_skipped_if_configured_false(
ransomware_payload_config, ransomware_target, telemetry_messenger_spy
):
ransomware_payload_config["encryption"]["should_encrypt"] = False
ransomware_payload = RansomwarePayload(ransomware_payload_config, telemetry_messenger_spy)
ransomware_payload.run_payload()
assert hash_file(ransomware_target / ALL_ZEROS_PDF) == ALL_ZEROS_PDF_CLEARTEXT_SHA256
assert hash_file(ransomware_target / TEST_KEYBOARD_TXT) == TEST_KEYBOARD_TXT_CLEARTEXT_SHA256
def test_telemetry_success(ransomware_payload, telemetry_messenger_spy):
ransomware_payload.run_payload()