From c7ea308c1966b517179ce71d6a8c2a5767e32bb4 Mon Sep 17 00:00:00 2001 From: Lucas Vivo Date: Fri, 20 Nov 2026 13:16:25 +0100 Subject: [PATCH] test(wallpaper_manager): test encryption and config --- .../python/tests/unit/test_config.py | 2 +- .../python/tests/unit/test_encryption_manager.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/wallpaper_changer/python/tests/unit/test_config.py b/wallpaper_changer/python/tests/unit/test_config.py index 937cd20..b16aa12 100644 --- a/wallpaper_changer/python/tests/unit/test_config.py +++ b/wallpaper_changer/python/tests/unit/test_config.py @@ -111,7 +111,7 @@ class ConfigTests(unittest.TestCase): config = Config.load(args) - self.assertEqual(config.private_key, Path(args.conf_dir).expanduser().resolve() / "IMG_privateKey.pem") + self.assertEqual(config.private_key, Path(args.conf_dir).expanduser().resolve() / "private_key.pem") self.assertEqual(config.wallpaper_dir, Path(args.conf_dir).expanduser().resolve() / "wallpaper") diff --git a/wallpaper_changer/python/tests/unit/test_encryption_manager.py b/wallpaper_changer/python/tests/unit/test_encryption_manager.py index ad3dc67..684c26d 100644 --- a/wallpaper_changer/python/tests/unit/test_encryption_manager.py +++ b/wallpaper_changer/python/tests/unit/test_encryption_manager.py @@ -109,6 +109,22 @@ class EncryptionManagerTests(unittest.TestCase): decrypted, _ = manager.decrypt(encrypted_file, None, passphrase) self.assertEqual(decrypted, plaintext) + def test_pem_private_key_uses_complete_file_contents(self) -> None: + """Verify PEM keys are not reduced to their generic header line.""" + with TemporaryDirectory() as temporary_directory: + private_key_file = Path(temporary_directory) / "private_key.pem" + pem_contents = ( + b"-----BEGIN RSA PRIVATE KEY-----\n" + b"private-key-bytes\n" + b"-----END RSA PRIVATE KEY-----\n" + ) + private_key_file.write_bytes(pem_contents) + + self.assertEqual( + EncryptionManager._read_passphrase(private_key_file), + pem_contents, + ) + def test_naming_table_round_trip_and_malformed_lines(self) -> None: """Verify naming-table entries round-trip and malformed lines are handled.""" with TemporaryDirectory() as temporary_directory: