mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 08:19:23 +00:00
Add totp codes command and endpoint
This commit is contained in:
@@ -122,6 +122,22 @@ def test_totp_export_endpoint(client):
|
||||
assert res.json() == {"entries": ["x"]}
|
||||
|
||||
|
||||
def test_totp_codes_endpoint(client):
|
||||
cl, token = client
|
||||
api._pm.entry_manager.list_entries = lambda **kw: [(0, "Email", None, None, False)]
|
||||
api._pm.entry_manager.get_totp_code = lambda i, s: "123456"
|
||||
api._pm.entry_manager.get_totp_time_remaining = lambda i: 30
|
||||
api._pm.parent_seed = "seed"
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
res = cl.get("/api/v1/totp", headers=headers)
|
||||
assert res.status_code == 200
|
||||
assert res.json() == {
|
||||
"codes": [
|
||||
{"id": 0, "label": "Email", "code": "123456", "seconds_remaining": 30}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def test_fingerprint_endpoints(client):
|
||||
cl, token = client
|
||||
calls = {}
|
||||
|
@@ -373,6 +373,19 @@ def test_entry_export_totp(monkeypatch, tmp_path):
|
||||
assert called.get("called") is True
|
||||
|
||||
|
||||
def test_entry_totp_codes(monkeypatch):
|
||||
called = {}
|
||||
|
||||
pm = SimpleNamespace(
|
||||
handle_display_totp_codes=lambda: called.setdefault("called", True),
|
||||
select_fingerprint=lambda fp: None,
|
||||
)
|
||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||
result = runner.invoke(app, ["entry", "totp-codes"])
|
||||
assert result.exit_code == 0
|
||||
assert called.get("called") is True
|
||||
|
||||
|
||||
def test_verify_checksum_command(monkeypatch):
|
||||
called = {}
|
||||
|
||||
|
Reference in New Issue
Block a user