diff --git a/tests/test_encryption_utils.py b/tests/test_encryption_utils.py new file mode 100644 index 0000000..6f8cdc4 --- /dev/null +++ b/tests/test_encryption_utils.py @@ -0,0 +1,36 @@ +import string +import pytest + +import puzzle_generator.simple_encryption_utils as seu + + +_STRS = [ + "", + "some_str", + "other_strstr!?#", + string.printable, + string.ascii_uppercase, + string.whitespace, + "ąęćśłń󿟥ĘĆŚŁŃÓŻŹ", + "some_msg_with 🔨 and 🛷!", + "a🎄b", + "🎮🎈🥅🐾", + "🏀", +] + + +@pytest.mark.parametrize("in_str", _STRS) +@pytest.mark.parametrize("in_pass", _STRS) +@pytest.mark.parametrize( + ("in_encrypt_str", "in_decrypt_str"), [(seu.encrypt_str, seu.decrypt_str)] +) +def test_seu(in_str, in_pass, in_encrypt_str, in_decrypt_str): + encrypted, reshash = in_encrypt_str(in_str, in_pass) + if in_str: + assert encrypted != in_str + else: + assert not encrypted + decrypted = in_decrypt_str(encrypted, in_pass, reshash) + assert decrypted == in_str + if in_str: + assert in_decrypt_str(encrypted, in_pass + "?", reshash) is None diff --git a/tests/test_simple_encryption_utils.py b/tests/test_simple_encryption_utils.py deleted file mode 100644 index 2a7c0a1..0000000 --- a/tests/test_simple_encryption_utils.py +++ /dev/null @@ -1,29 +0,0 @@ -import pytest - -import puzzle_generator.simple_encryption_utils as seu - - -@pytest.mark.parametrize( - ("in_str", "in_pass"), - [ - ("some_msg", "some_pass"), - ("Ą", "other_pass!?#"), - ("some_very_very_very_loooong_str", "ę"), - ("ŁÓ", ""), - ("", "a"), - ("", ""), - ("some_msg_with 🔨 and 🛷!", "?"), - ("other message!@#$?", "a🎄b"), - ("🎮🎈🥅🐾", "🏀"), - ], -) -def test_seu(in_str, in_pass): - encrypted, reshash = seu.encrypt_str(in_str, in_pass) - if in_str: - assert encrypted != in_str - else: - assert not encrypted - decrypted = seu.decrypt_str(encrypted, in_pass, reshash) - assert decrypted == in_str - if in_str: - assert seu.decrypt_str(encrypted, in_pass + "?", reshash) is None