forked from p15670423/monkey
Tests: Mark encryption tests as slow
This commit is contained in:
parent
e7fcf933b7
commit
bf082d36ef
|
@ -51,6 +51,7 @@ def fake_mongo(monkeypatch):
|
|||
monkeypatch.setattr("monkey_island.cc.models.telemetries.telemetry_dal.mongo", mongo)
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.usefixtures("uses_database", "uses_encryptor")
|
||||
def test_telemetry_encryption():
|
||||
secret_keys = ["password", "lm_hash", "ntlm_hash"]
|
||||
|
@ -62,20 +63,17 @@ def test_telemetry_encryption():
|
|||
assert encrypted_telemetry["data"]["credentials"][user]["username"] == user
|
||||
|
||||
for s in secret_keys:
|
||||
assert (
|
||||
encrypted_telemetry["data"]["credentials"][user][s] != MOCK_CREDENTIALS[user][s]
|
||||
)
|
||||
assert encrypted_telemetry["data"]["credentials"][user][s] != MOCK_CREDENTIALS[user][s]
|
||||
|
||||
decrypted_telemetry = get_telemetry_by_query({})[0]
|
||||
for user in MOCK_CREDENTIALS.keys():
|
||||
assert decrypted_telemetry["data"]["credentials"][user]["username"] == user
|
||||
|
||||
for s in secret_keys:
|
||||
assert (
|
||||
decrypted_telemetry["data"]["credentials"][user][s] == MOCK_CREDENTIALS[user][s]
|
||||
)
|
||||
assert decrypted_telemetry["data"]["credentials"][user][s] == MOCK_CREDENTIALS[user][s]
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.usefixtures("uses_database", "uses_encryptor")
|
||||
def test_no_encryption_needed():
|
||||
# Make sure telemetry save doesn't break when telemetry doesn't need encryption
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import pytest
|
||||
|
||||
from monkey_island.cc.server_utils.encryption.dict_encryption.field_encryptors import (
|
||||
StringListEncryptor,
|
||||
)
|
||||
|
@ -6,6 +8,7 @@ MOCK_STRING_LIST = ["test_1", "test_2"]
|
|||
EMPTY_LIST = []
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_encryption_and_decryption(uses_encryptor):
|
||||
encrypted_list = StringListEncryptor.encrypt(MOCK_STRING_LIST)
|
||||
assert not encrypted_list == MOCK_STRING_LIST
|
||||
|
@ -13,6 +16,7 @@ def test_encryption_and_decryption(uses_encryptor):
|
|||
assert decrypted_list == MOCK_STRING_LIST
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_empty_list(uses_encryptor):
|
||||
# Tests that no errors are raised
|
||||
encrypted_list = StringListEncryptor.encrypt(EMPTY_LIST)
|
||||
|
|
|
@ -11,6 +11,7 @@ PLAINTEXT = "Hello, Monkey!"
|
|||
MOCK_SECRET = "53CR31"
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.usefixtures("uses_encryptor")
|
||||
def test_encryption(data_for_tests_dir):
|
||||
encrypted_data = get_datastore_encryptor().encrypt(PLAINTEXT)
|
||||
|
@ -33,10 +34,12 @@ def initialized_encryptor_dir(tmpdir):
|
|||
return tmpdir
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_key_creation(initialized_encryptor_dir):
|
||||
assert (initialized_encryptor_dir / data_store_encryptor._KEY_FILENAME).isfile()
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
def test_key_removal(initialized_encryptor_dir):
|
||||
remove_old_datastore_key(initialized_encryptor_dir)
|
||||
assert not (initialized_encryptor_dir / data_store_encryptor._KEY_FILENAME).isfile()
|
||||
|
@ -49,6 +52,7 @@ def test_key_removal__no_key(tmpdir):
|
|||
data_store_encryptor._factory = None
|
||||
|
||||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.usefixtures("cleanup_encryptor")
|
||||
def test_key_file_encryption(tmpdir, monkeypatch):
|
||||
monkeypatch.setattr(data_store_encryptor, "_get_random_bytes", lambda: PLAINTEXT.encode())
|
||||
|
|
Loading…
Reference in New Issue