Add test for legacy Fernet data with V2 prefix

This commit is contained in:
thePR0M3TH3AN
2025-07-13 20:07:56 -04:00
parent 3038646fcb
commit a3fd02f0c9
2 changed files with 46 additions and 54 deletions

View File

@@ -0,0 +1,21 @@
import logging
from pathlib import Path
from helpers import TEST_SEED
from utils.key_derivation import derive_index_key
from password_manager.encryption import EncryptionManager
def test_v2_prefix_fernet_fallback(tmp_path: Path, caplog) -> None:
key = derive_index_key(TEST_SEED)
manager = EncryptionManager(key, tmp_path)
original = b"legacy data"
token = manager.fernet.encrypt(original)
payload = b"V2:" + token
caplog.set_level(logging.WARNING, logger="password_manager.encryption")
decrypted = manager.decrypt_data(payload)
assert decrypted == original
assert "incorrect 'V2:' header" in caplog.text