mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 07:18:47 +00:00
Test avoiding decryption when selecting active profile
This commit is contained in:
@@ -191,6 +191,13 @@ def handle_switch_fingerprint(password_manager: PasswordManager):
|
||||
return
|
||||
|
||||
selected_fingerprint = fingerprints[int(choice) - 1]
|
||||
if selected_fingerprint == password_manager.current_fingerprint:
|
||||
print(
|
||||
colored(
|
||||
f"Seed profile {selected_fingerprint} is already active.", "yellow"
|
||||
)
|
||||
)
|
||||
return
|
||||
if password_manager.select_fingerprint(selected_fingerprint):
|
||||
print(colored(f"Switched to seed profile {selected_fingerprint}.", "green"))
|
||||
else:
|
||||
|
32
src/tests/test_handle_switch_fingerprint.py
Normal file
32
src/tests/test_handle_switch_fingerprint.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from main import handle_switch_fingerprint
|
||||
|
||||
|
||||
def test_handle_switch_fingerprint_active_profile(monkeypatch, capsys):
|
||||
class DummyFingerprintManager:
|
||||
def __init__(self):
|
||||
self.fingerprints = ["fp1", "fp2"]
|
||||
|
||||
def list_fingerprints(self):
|
||||
return self.fingerprints
|
||||
|
||||
def display_name(self, fp):
|
||||
return fp
|
||||
|
||||
class DummyPM:
|
||||
def __init__(self):
|
||||
self.fingerprint_manager = DummyFingerprintManager()
|
||||
self.current_fingerprint = "fp1"
|
||||
self.decrypted = False
|
||||
|
||||
def select_fingerprint(self, fingerprint):
|
||||
self.decrypted = True
|
||||
return True
|
||||
|
||||
pm = DummyPM()
|
||||
monkeypatch.setattr("builtins.input", lambda _: "1")
|
||||
|
||||
handle_switch_fingerprint(pm)
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert "already active" in captured.out.lower()
|
||||
assert pm.decrypted is False
|
Reference in New Issue
Block a user