mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-02 02:42:04 +00:00
perf: Cache derived TOTP secrets in display loops
Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
8cdf1c523d
commit
b0c3a97ce3
7 files changed
+67
-15
No files matched your search
@@ -21,7 +21,10 @@ def test_handle_display_totp_codes(monkeypatch, capsys, password_manager):
|
||||
|
||||
pm.entry_manager.add_totp("Example", TEST_SEED)
|
||||
|
||||
monkeypatch.setattr(pm.entry_manager, "get_totp_code", lambda *a, **k: "123456")
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.totp.TotpManager.current_code_from_secret",
|
||||
lambda *a, **k: "123456",
|
||||
)
|
||||
monkeypatch.setattr(pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 30)
|
||||
|
||||
# interrupt the loop after first iteration
|
||||
@@ -45,7 +48,10 @@ def test_display_totp_codes_excludes_archived(monkeypatch, capsys, password_mana
|
||||
pm.entry_manager.add_totp("Hidden", TEST_SEED)
|
||||
pm.entry_manager.modify_entry(1, archived=True)
|
||||
|
||||
monkeypatch.setattr(pm.entry_manager, "get_totp_code", lambda *a, **k: "123456")
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.totp.TotpManager.current_code_from_secret",
|
||||
lambda *a, **k: "123456",
|
||||
)
|
||||
monkeypatch.setattr(pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 30)
|
||||
|
||||
monkeypatch.setattr(
|
||||
|
||||
@@ -346,7 +346,8 @@ def test_show_entry_details_sensitive(monkeypatch, capsys, entry_type):
|
||||
entry_mgr.add_totp("Example", TEST_SEED)
|
||||
idx = 0
|
||||
monkeypatch.setattr(
|
||||
pm.entry_manager, "get_totp_code", lambda *a, **k: "123456"
|
||||
"seedpass.core.manager.TotpManager.current_code_from_secret",
|
||||
lambda *a, **k: "123456",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 1
|
||||
@@ -383,7 +384,8 @@ def test_show_entry_details_with_enum_type(monkeypatch, capsys, entry_type):
|
||||
entry_mgr.add_totp("Example", TEST_SEED)
|
||||
idx = 0
|
||||
monkeypatch.setattr(
|
||||
pm.entry_manager, "get_totp_code", lambda *a, **k: "123456"
|
||||
"seedpass.core.manager.TotpManager.current_code_from_secret",
|
||||
lambda *a, **k: "123456",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 1
|
||||
|
||||
@@ -45,7 +45,10 @@ def test_handle_retrieve_totp_entry(monkeypatch, capsys):
|
||||
|
||||
inputs = iter(["0", "n", ""])
|
||||
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
||||
monkeypatch.setattr(pm.entry_manager, "get_totp_code", lambda *a, **k: "123456")
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.manager.TotpManager.current_code_from_secret",
|
||||
lambda *a, **k: "123456",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 1
|
||||
)
|
||||
|
||||
@@ -62,7 +62,10 @@ def test_totp_display_secret_mode(monkeypatch, capsys):
|
||||
pm, entry_mgr = setup_pm(tmp)
|
||||
entry_mgr.add_totp("Example", TEST_SEED)
|
||||
|
||||
monkeypatch.setattr(pm.entry_manager, "get_totp_code", lambda *a, **k: "123456")
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.totp.TotpManager.current_code_from_secret",
|
||||
lambda *a, **k: "123456",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 30
|
||||
)
|
||||
@@ -112,7 +115,10 @@ def test_totp_display_no_secret_mode(monkeypatch, capsys):
|
||||
pm.secret_mode_enabled = False
|
||||
entry_mgr.add_totp("Example", TEST_SEED)
|
||||
|
||||
monkeypatch.setattr(pm.entry_manager, "get_totp_code", lambda *a, **k: "123456")
|
||||
monkeypatch.setattr(
|
||||
"seedpass.core.totp.TotpManager.current_code_from_secret",
|
||||
lambda *a, **k: "123456",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 30
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user