From f6b13309827533559f8ec00b3b4bd0a622fa7f8a Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 5 Oct 2021 12:05:49 +0530 Subject: [PATCH] tests: Add test cases for KeyBasedEncryptor's tests --- .../encryption/test_key_based_encryptor.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_key_based_encryptor.py b/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_key_based_encryptor.py index 391002417..10803cff9 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_key_based_encryptor.py +++ b/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_key_based_encryptor.py @@ -1,7 +1,9 @@ from monkey_island.cc.server_utils.encryption import KeyBasedEncryptor PLAINTEXT = "password" -PLAINTEXT_UTF8 = "slaptažodis" # "password" in Lithuanian +PLAINTEXT_UTF8_1 = "slaptažodis" # "password" in Lithuanian +PLAINTEXT_UTF8_2 = "弟" # Japanese +PLAINTEXT_UTF8_3 = "ж" # Ukranian KEY = b"\x84\xd4qA\xb5\xd4Y\x9bH.\x14\xab\xd8\xc7+g\x12\xfa\x80'%\xfd#\xf8c\x94\xb9\x96_\xf4\xc51" kb_encryptor = KeyBasedEncryptor(KEY) @@ -13,7 +15,19 @@ def test_encrypt_decrypt_string_with_key(): assert decrypted == PLAINTEXT -def test_encrypt_decrypt_string_utf8_with_key(): - encrypted = kb_encryptor.encrypt(PLAINTEXT_UTF8) +def test_encrypt_decrypt_string_utf8_with_key_1(): + encrypted = kb_encryptor.encrypt(PLAINTEXT_UTF8_1) decrypted = kb_encryptor.decrypt(encrypted) - assert decrypted == PLAINTEXT_UTF8 + assert decrypted == PLAINTEXT_UTF8_1 + + +def test_encrypt_decrypt_string_utf8_with_key_2(): + encrypted = kb_encryptor.encrypt(PLAINTEXT_UTF8_2) + decrypted = kb_encryptor.decrypt(encrypted) + assert decrypted == PLAINTEXT_UTF8_2 + + +def test_encrypt_decrypt_string_utf8_with_key_3(): + encrypted = kb_encryptor.encrypt(PLAINTEXT_UTF8_3) + decrypted = kb_encryptor.decrypt(encrypted) + assert decrypted == PLAINTEXT_UTF8_3