Add TOTP export via CLI and API

This commit is contained in:
thePR0M3TH3AN
2025-07-09 17:09:27 -04:00
parent a54fc3658e
commit 4f810ccbc3
7 changed files with 82 additions and 0 deletions

View File

@@ -112,6 +112,16 @@ def test_update_config_secret_mode(client):
assert called["val"] is True
def test_totp_export_endpoint(client):
cl, token = client
api._pm.entry_manager.export_totp_entries = lambda seed: {"entries": ["x"]}
api._pm.parent_seed = "seed"
headers = {"Authorization": f"Bearer {token}"}
res = cl.get("/api/v1/totp/export", headers=headers)
assert res.status_code == 200
assert res.json() == {"entries": ["x"]}
def test_fingerprint_endpoints(client):
cl, token = client
calls = {}

View File

@@ -353,6 +353,26 @@ def test_entry_unarchive(monkeypatch):
assert called["id"] == 4
def test_entry_export_totp(monkeypatch, tmp_path):
called = {}
pm = SimpleNamespace(
entry_manager=SimpleNamespace(
export_totp_entries=lambda seed: called.setdefault("called", True)
or {"entries": []}
),
parent_seed="seed",
select_fingerprint=lambda fp: None,
)
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
out = tmp_path / "t.json"
result = runner.invoke(app, ["entry", "export-totp", "--file", str(out)])
assert result.exit_code == 0
assert out.exists()
assert called.get("called") is True
def test_verify_checksum_command(monkeypatch):
called = {}