From 88f3a2b9ca9f14c1ca9a9286df0ff98e778aa131 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Wed, 22 Sep 2021 10:23:41 +0300 Subject: [PATCH] Add unit tests for string list encryptor --- .../test_string_list_encryptor.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py diff --git a/monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py b/monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py new file mode 100644 index 000000000..1417d0cbe --- /dev/null +++ b/monkey/tests/unit_tests/monkey_island/cc/models/utils/field_encryptors/test_string_list_encryptor.py @@ -0,0 +1,24 @@ +import pytest + +from monkey_island.cc.models.utils.field_encryptors.string_list_encryptor import StringListEncryptor +from monkey_island.cc.server_utils.encryptor import initialize_encryptor + +MOCK_STRING_LIST = ["test_1", "test_2"] +EMPTY_LIST = [] + + +@pytest.fixture +def uses_encryptor(data_for_tests_dir): + initialize_encryptor(data_for_tests_dir) + + +def test_string_list_encryptor(uses_encryptor): + encrypted_list = StringListEncryptor.encrypt(MOCK_STRING_LIST) + assert not encrypted_list == MOCK_STRING_LIST + decrypted_list = StringListEncryptor.decrypt(encrypted_list) + assert decrypted_list == MOCK_STRING_LIST + + +def test_string_list_encryptor__empty_list(uses_encryptor): + encrypted_list = StringListEncryptor.encrypt(EMPTY_LIST) + StringListEncryptor.decrypt(encrypted_list)