Improve archive toggle logic on retrieval

This commit is contained in:
thePR0M3TH3AN
2025-07-07 19:24:42 -04:00
parent ce321ddaaf
commit 0ee4b5cfb0
2 changed files with 56 additions and 35 deletions

View File

@@ -46,3 +46,35 @@ def test_archive_entry_from_retrieve(monkeypatch):
pm.handle_retrieve_entry()
assert entry_mgr.retrieve_entry(index)["archived"] is True
def test_restore_entry_from_retrieve(monkeypatch):
"""Archived entries should restore when retrieved and confirmed."""
with TemporaryDirectory() as tmpdir:
tmp_path = Path(tmpdir)
vault, enc_mgr = create_vault(tmp_path, TEST_SEED, TEST_PASSWORD)
cfg_mgr = ConfigManager(vault, tmp_path)
backup_mgr = BackupManager(tmp_path, cfg_mgr)
entry_mgr = EntryManager(vault, backup_mgr)
pm = PasswordManager.__new__(PasswordManager)
pm.encryption_mode = EncryptionMode.SEED_ONLY
pm.encryption_manager = enc_mgr
pm.vault = vault
pm.entry_manager = entry_mgr
pm.backup_manager = backup_mgr
pm.password_generator = FakePasswordGenerator()
pm.parent_seed = TEST_SEED
pm.nostr_client = SimpleNamespace()
pm.fingerprint_dir = tmp_path
pm.secret_mode_enabled = False
index = entry_mgr.add_entry("example.com", 8)
entry_mgr.archive_entry(index)
inputs = iter([str(index), "y"])
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
pm.handle_retrieve_entry()
assert entry_mgr.retrieve_entry(index)["archived"] is False