mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 15:58:48 +00:00
Merge pull request #354 from PR0M3TH3AN/codex/prompt-user-before-pausing-entry-retrieval
Add archive prompt when retrieving entries
This commit is contained in:
@@ -1387,6 +1387,11 @@ class PasswordManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error generating TOTP code: {e}", exc_info=True)
|
logging.error(f"Error generating TOTP code: {e}", exc_info=True)
|
||||||
print(colored(f"Error: Failed to generate TOTP code: {e}", "red"))
|
print(colored(f"Error: Failed to generate TOTP code: {e}", "red"))
|
||||||
|
choice = input("Archive this entry? (y/N): ").strip().lower()
|
||||||
|
if choice == "y":
|
||||||
|
self.entry_manager.archive_entry(index)
|
||||||
|
self.is_dirty = True
|
||||||
|
self.last_update = time.time()
|
||||||
pause()
|
pause()
|
||||||
return
|
return
|
||||||
if entry_type == EntryType.SSH.value:
|
if entry_type == EntryType.SSH.value:
|
||||||
@@ -1422,6 +1427,11 @@ class PasswordManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error deriving SSH key pair: {e}", exc_info=True)
|
logging.error(f"Error deriving SSH key pair: {e}", exc_info=True)
|
||||||
print(colored(f"Error: Failed to derive SSH keys: {e}", "red"))
|
print(colored(f"Error: Failed to derive SSH keys: {e}", "red"))
|
||||||
|
choice = input("Archive this entry? (y/N): ").strip().lower()
|
||||||
|
if choice == "y":
|
||||||
|
self.entry_manager.archive_entry(index)
|
||||||
|
self.is_dirty = True
|
||||||
|
self.last_update = time.time()
|
||||||
pause()
|
pause()
|
||||||
return
|
return
|
||||||
if entry_type == EntryType.SEED.value:
|
if entry_type == EntryType.SEED.value:
|
||||||
@@ -1472,6 +1482,11 @@ class PasswordManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error deriving seed phrase: {e}", exc_info=True)
|
logging.error(f"Error deriving seed phrase: {e}", exc_info=True)
|
||||||
print(colored(f"Error: Failed to derive seed phrase: {e}", "red"))
|
print(colored(f"Error: Failed to derive seed phrase: {e}", "red"))
|
||||||
|
choice = input("Archive this entry? (y/N): ").strip().lower()
|
||||||
|
if choice == "y":
|
||||||
|
self.entry_manager.archive_entry(index)
|
||||||
|
self.is_dirty = True
|
||||||
|
self.last_update = time.time()
|
||||||
pause()
|
pause()
|
||||||
return
|
return
|
||||||
if entry_type == EntryType.PGP.value:
|
if entry_type == EntryType.PGP.value:
|
||||||
@@ -1505,6 +1520,11 @@ class PasswordManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error deriving PGP key: {e}", exc_info=True)
|
logging.error(f"Error deriving PGP key: {e}", exc_info=True)
|
||||||
print(colored(f"Error: Failed to derive PGP key: {e}", "red"))
|
print(colored(f"Error: Failed to derive PGP key: {e}", "red"))
|
||||||
|
choice = input("Archive this entry? (y/N): ").strip().lower()
|
||||||
|
if choice == "y":
|
||||||
|
self.entry_manager.archive_entry(index)
|
||||||
|
self.is_dirty = True
|
||||||
|
self.last_update = time.time()
|
||||||
pause()
|
pause()
|
||||||
return
|
return
|
||||||
if entry_type == EntryType.NOSTR.value:
|
if entry_type == EntryType.NOSTR.value:
|
||||||
@@ -1538,6 +1558,11 @@ class PasswordManager:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error deriving Nostr keys: {e}", exc_info=True)
|
logging.error(f"Error deriving Nostr keys: {e}", exc_info=True)
|
||||||
print(colored(f"Error: Failed to derive Nostr keys: {e}", "red"))
|
print(colored(f"Error: Failed to derive Nostr keys: {e}", "red"))
|
||||||
|
choice = input("Archive this entry? (y/N): ").strip().lower()
|
||||||
|
if choice == "y":
|
||||||
|
self.entry_manager.archive_entry(index)
|
||||||
|
self.is_dirty = True
|
||||||
|
self.last_update = time.time()
|
||||||
pause()
|
pause()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1625,6 +1650,11 @@ class PasswordManager:
|
|||||||
print(colored(f" {label}: {value}", "cyan"))
|
print(colored(f" {label}: {value}", "cyan"))
|
||||||
else:
|
else:
|
||||||
print(colored("Error: Failed to retrieve the password.", "red"))
|
print(colored("Error: Failed to retrieve the password.", "red"))
|
||||||
|
choice = input("Archive this entry? (y/N): ").strip().lower()
|
||||||
|
if choice == "y":
|
||||||
|
self.entry_manager.archive_entry(index)
|
||||||
|
self.is_dirty = True
|
||||||
|
self.last_update = time.time()
|
||||||
pause()
|
pause()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error during password retrieval: {e}", exc_info=True)
|
logging.error(f"Error during password retrieval: {e}", exc_info=True)
|
||||||
|
@@ -42,7 +42,7 @@ def test_retrieve_entry_shows_custom_fields(monkeypatch, capsys):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
inputs = iter(["0", "y"])
|
inputs = iter(["0", "y", "n"])
|
||||||
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
||||||
|
|
||||||
pm.handle_retrieve_entry()
|
pm.handle_retrieve_entry()
|
||||||
|
@@ -43,7 +43,8 @@ def test_handle_retrieve_totp_entry(monkeypatch, capsys):
|
|||||||
|
|
||||||
entry_mgr.add_totp("Example", TEST_SEED)
|
entry_mgr.add_totp("Example", TEST_SEED)
|
||||||
|
|
||||||
monkeypatch.setattr("builtins.input", lambda *a, **k: "0")
|
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(pm.entry_manager, "get_totp_code", lambda *a, **k: "123456")
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 1
|
pm.entry_manager, "get_totp_time_remaining", lambda *a, **k: 1
|
||||||
|
@@ -46,6 +46,7 @@ def test_manager_workflow(monkeypatch):
|
|||||||
pm.nostr_client = FakeNostrClient()
|
pm.nostr_client = FakeNostrClient()
|
||||||
pm.fingerprint_dir = tmp_path
|
pm.fingerprint_dir = tmp_path
|
||||||
pm.is_dirty = False
|
pm.is_dirty = False
|
||||||
|
pm.secret_mode_enabled = False
|
||||||
|
|
||||||
inputs = iter(
|
inputs = iter(
|
||||||
[
|
[
|
||||||
@@ -56,6 +57,7 @@ def test_manager_workflow(monkeypatch):
|
|||||||
"n", # add custom field
|
"n", # add custom field
|
||||||
"", # length (default)
|
"", # length (default)
|
||||||
"0", # retrieve index
|
"0", # retrieve index
|
||||||
|
"n", # archive entry prompt
|
||||||
"0", # modify index
|
"0", # modify index
|
||||||
"", # new label
|
"", # new label
|
||||||
"user", # new username
|
"user", # new username
|
||||||
|
@@ -44,7 +44,8 @@ def test_show_qr_for_nostr_keys(monkeypatch):
|
|||||||
idx = entry_mgr.add_nostr_key("main")
|
idx = entry_mgr.add_nostr_key("main")
|
||||||
npub, _ = entry_mgr.get_nostr_key_pair(idx, TEST_SEED)
|
npub, _ = entry_mgr.get_nostr_key_pair(idx, TEST_SEED)
|
||||||
|
|
||||||
monkeypatch.setattr("builtins.input", lambda *a, **k: str(idx))
|
inputs = iter([str(idx), "n"])
|
||||||
|
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
||||||
responses = iter([True, False])
|
responses = iter([True, False])
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
"password_manager.manager.confirm_action",
|
"password_manager.manager.confirm_action",
|
||||||
|
@@ -41,7 +41,8 @@ def test_password_retrieve_secret_mode(monkeypatch, capsys):
|
|||||||
pm, entry_mgr = setup_pm(tmp)
|
pm, entry_mgr = setup_pm(tmp)
|
||||||
entry_mgr.add_entry("example", 8)
|
entry_mgr.add_entry("example", 8)
|
||||||
|
|
||||||
monkeypatch.setattr("builtins.input", lambda *a, **k: "0")
|
inputs = iter(["0", "n"])
|
||||||
|
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
||||||
called = []
|
called = []
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
"password_manager.manager.copy_to_clipboard",
|
"password_manager.manager.copy_to_clipboard",
|
||||||
@@ -89,7 +90,8 @@ def test_password_retrieve_no_secret_mode(monkeypatch, capsys):
|
|||||||
pm.secret_mode_enabled = False
|
pm.secret_mode_enabled = False
|
||||||
entry_mgr.add_entry("example", 8)
|
entry_mgr.add_entry("example", 8)
|
||||||
|
|
||||||
monkeypatch.setattr("builtins.input", lambda *a, **k: "0")
|
inputs = iter(["0", "n"])
|
||||||
|
monkeypatch.setattr("builtins.input", lambda *a, **k: next(inputs))
|
||||||
called = []
|
called = []
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
"password_manager.manager.copy_to_clipboard",
|
"password_manager.manager.copy_to_clipboard",
|
||||||
|
Reference in New Issue
Block a user