From 52f5e708124d8a1d8e05aff75f6b637c1834eea4 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Fri, 15 Jul 2022 07:52:36 -0400 Subject: [PATCH] Island: Add new locking test for RepositoryEncryptor --- .../encryption/test_repository_encryptor.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_repository_encryptor.py b/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_repository_encryptor.py index 2555d733a..597fbc85c 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_repository_encryptor.py +++ b/monkey/tests/unit_tests/monkey_island/cc/server_utils/encryption/test_repository_encryptor.py @@ -59,6 +59,20 @@ def test_existing_key_reused(encryptor, key_file): assert key_file_hash_1 == key_file_hash_2 +def test_existing_key_reused__lock(encryptor, key_file): + assert not key_file.is_file() + + encryptor.unlock(SECRET) + key_file_hash_1 = get_file_sha256_hash(key_file) + + encryptor.lock() + + encryptor.unlock(SECRET) + key_file_hash_2 = get_file_sha256_hash(key_file) + + assert key_file_hash_1 == key_file_hash_2 + + def test_unlock_os_error(encryptor, key_file): key_file.mkdir()