forked from p34709852/monkey
tests: Use pytest's parametrize for KeyBasedEncryptor's unit tests
This commit is contained in:
parent
f6b1330982
commit
f1b9683617
|
@ -1,3 +1,5 @@
|
||||||
|
import pytest
|
||||||
|
|
||||||
from monkey_island.cc.server_utils.encryption import KeyBasedEncryptor
|
from monkey_island.cc.server_utils.encryption import KeyBasedEncryptor
|
||||||
|
|
||||||
PLAINTEXT = "password"
|
PLAINTEXT = "password"
|
||||||
|
@ -15,19 +17,8 @@ def test_encrypt_decrypt_string_with_key():
|
||||||
assert decrypted == PLAINTEXT
|
assert decrypted == PLAINTEXT
|
||||||
|
|
||||||
|
|
||||||
def test_encrypt_decrypt_string_utf8_with_key_1():
|
@pytest.mark.parametrize("plaintext", [PLAINTEXT_UTF8_1, PLAINTEXT_UTF8_2, PLAINTEXT_UTF8_3])
|
||||||
encrypted = kb_encryptor.encrypt(PLAINTEXT_UTF8_1)
|
def test_encrypt_decrypt_string_utf8_with_key(plaintext):
|
||||||
|
encrypted = kb_encryptor.encrypt(plaintext)
|
||||||
decrypted = kb_encryptor.decrypt(encrypted)
|
decrypted = kb_encryptor.decrypt(encrypted)
|
||||||
assert decrypted == PLAINTEXT_UTF8_1
|
assert decrypted == plaintext
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
Loading…
Reference in New Issue