mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Add navigation and indexing to TOTP display
This commit is contained in:
@@ -21,7 +21,7 @@ class FakeNostrClient:
|
||||
return None, "abcd"
|
||||
|
||||
|
||||
def test_handle_add_totp(monkeypatch):
|
||||
def test_handle_add_totp(monkeypatch, capsys):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
tmp_path = Path(tmpdir)
|
||||
vault, enc_mgr = create_vault(tmp_path, TEST_SEED, TEST_PASSWORD)
|
||||
@@ -51,6 +51,7 @@ def test_handle_add_totp(monkeypatch):
|
||||
monkeypatch.setattr(pm, "sync_vault", lambda: None)
|
||||
|
||||
pm.handle_add_totp()
|
||||
out = capsys.readouterr().out
|
||||
|
||||
entry = entry_mgr.retrieve_entry(0)
|
||||
assert entry == {
|
||||
@@ -60,3 +61,4 @@ def test_handle_add_totp(monkeypatch):
|
||||
"period": 30,
|
||||
"digits": 6,
|
||||
}
|
||||
assert "ID 0" in out
|
||||
|
@@ -45,12 +45,14 @@ def test_handle_display_totp_codes(monkeypatch, capsys):
|
||||
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 30
|
||||
)
|
||||
|
||||
def interrupt(_):
|
||||
raise KeyboardInterrupt()
|
||||
|
||||
monkeypatch.setattr("password_manager.manager.time.sleep", interrupt)
|
||||
# interrupt the loop after first iteration
|
||||
monkeypatch.setattr(
|
||||
"password_manager.manager.select.select",
|
||||
lambda *a, **k: (_ for _ in ()).throw(KeyboardInterrupt()),
|
||||
)
|
||||
|
||||
pm.handle_display_totp_codes()
|
||||
out = capsys.readouterr().out
|
||||
assert "Example" in out
|
||||
assert "Generated 2FA Codes" in out
|
||||
assert "[0] Example" in out
|
||||
assert "123456" in out
|
||||
|
Reference in New Issue
Block a user