test(wallpaper_manager): test encryption and config

This commit is contained in:
Lucas Vivo committed 2026-11-20 15:58:06 +01:00
1 parent d6a828bb2e
commit c7ea308c19
2 files changed
+17 -1

No files matched your search

@@ -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")
@@ -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: