mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Track migrations and trigger sync
This commit is contained in:
@@ -159,3 +159,38 @@ def test_legacy_nostr_payload_triggers_sync(monkeypatch, tmp_path: Path):
|
||||
asyncio.run(pm.sync_index_from_nostr_async())
|
||||
assert calls["sync"] == 1
|
||||
assert pm.vault.load_index() == data
|
||||
|
||||
|
||||
def test_legacy_index_reinit_triggers_sync_once(monkeypatch, tmp_path: Path):
|
||||
vault, enc_mgr = create_vault(tmp_path, TEST_SEED, TEST_PASSWORD)
|
||||
|
||||
key = derive_index_key(TEST_SEED)
|
||||
data = {"schema_version": 4, "entries": {}}
|
||||
enc = Fernet(key).encrypt(json.dumps(data).encode())
|
||||
legacy_file = tmp_path / "seedpass_passwords_db.json.enc"
|
||||
legacy_file.write_bytes(enc)
|
||||
|
||||
monkeypatch.setattr("builtins.input", lambda *_a, **_k: "y")
|
||||
|
||||
pm = PasswordManager.__new__(PasswordManager)
|
||||
pm.encryption_mode = EncryptionMode.SEED_ONLY
|
||||
pm.encryption_manager = enc_mgr
|
||||
pm.vault = Vault(enc_mgr, tmp_path)
|
||||
pm.parent_seed = TEST_SEED
|
||||
pm.fingerprint_dir = tmp_path
|
||||
pm.current_fingerprint = tmp_path.name
|
||||
pm.bip85 = SimpleNamespace()
|
||||
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.manager.NostrClient", lambda *a, **k: SimpleNamespace()
|
||||
)
|
||||
|
||||
calls = {"sync": 0}
|
||||
pm.start_background_vault_sync = lambda *a, **k: calls.__setitem__(
|
||||
"sync", calls["sync"] + 1
|
||||
)
|
||||
|
||||
pm.initialize_managers()
|
||||
pm.initialize_managers()
|
||||
|
||||
assert calls["sync"] == 1
|
||||
|
Reference in New Issue
Block a user