mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Trigger vault sync after imports
This commit is contained in:
@@ -218,6 +218,7 @@ def test_vault_import_via_path(client, tmp_path):
|
||||
called["path"] = path
|
||||
|
||||
api._pm.handle_import_database = import_db
|
||||
api._pm.sync_vault = lambda: called.setdefault("sync", True)
|
||||
file_path = tmp_path / "b.json"
|
||||
file_path.write_text("{}")
|
||||
|
||||
@@ -230,6 +231,7 @@ def test_vault_import_via_path(client, tmp_path):
|
||||
assert res.status_code == 200
|
||||
assert res.json() == {"status": "ok"}
|
||||
assert called["path"] == file_path
|
||||
assert called.get("sync") is True
|
||||
|
||||
|
||||
def test_vault_import_via_upload(client, tmp_path):
|
||||
@@ -240,6 +242,7 @@ def test_vault_import_via_upload(client, tmp_path):
|
||||
called["path"] = path
|
||||
|
||||
api._pm.handle_import_database = import_db
|
||||
api._pm.sync_vault = lambda: called.setdefault("sync", True)
|
||||
file_path = tmp_path / "c.json"
|
||||
file_path.write_text("{}")
|
||||
|
||||
@@ -253,6 +256,7 @@ def test_vault_import_via_upload(client, tmp_path):
|
||||
assert res.status_code == 200
|
||||
assert res.json() == {"status": "ok"}
|
||||
assert isinstance(called.get("path"), Path)
|
||||
assert called.get("sync") is True
|
||||
|
||||
|
||||
def test_vault_lock_endpoint(client):
|
||||
|
@@ -88,7 +88,9 @@ def test_vault_import(monkeypatch, tmp_path):
|
||||
called["path"] = path
|
||||
|
||||
pm = SimpleNamespace(
|
||||
handle_import_database=import_db, select_fingerprint=lambda fp: None
|
||||
handle_import_database=import_db,
|
||||
select_fingerprint=lambda fp: None,
|
||||
sync_vault=lambda: None,
|
||||
)
|
||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||
in_path = tmp_path / "in.json"
|
||||
@@ -98,6 +100,29 @@ def test_vault_import(monkeypatch, tmp_path):
|
||||
assert called["path"] == in_path
|
||||
|
||||
|
||||
def test_vault_import_triggers_sync(monkeypatch, tmp_path):
|
||||
called = {}
|
||||
|
||||
def import_db(path):
|
||||
called["path"] = path
|
||||
|
||||
def sync():
|
||||
called["sync"] = True
|
||||
|
||||
pm = SimpleNamespace(
|
||||
handle_import_database=import_db,
|
||||
sync_vault=sync,
|
||||
select_fingerprint=lambda fp: None,
|
||||
)
|
||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||
in_path = tmp_path / "in.json"
|
||||
in_path.write_text("{}")
|
||||
result = runner.invoke(app, ["vault", "import", "--file", str(in_path)])
|
||||
assert result.exit_code == 0
|
||||
assert called["path"] == in_path
|
||||
assert called.get("sync") is True
|
||||
|
||||
|
||||
def test_vault_change_password(monkeypatch):
|
||||
called = {}
|
||||
|
||||
|
Reference in New Issue
Block a user