mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-02 02:42:04 +00:00
tui2: default profiles online and add phase4 inspector boards
This commit is contained in:
1 parent
d4cbd04242
commit
93cf78b2c8
7 files changed
+447
-23
No files matched your search
@@ -5,10 +5,10 @@ from seedpass.core.config_manager import ConfigManager
|
||||
from helpers import create_vault, TEST_SEED, TEST_PASSWORD
|
||||
|
||||
|
||||
def test_offline_mode_default_enabled():
|
||||
def test_offline_mode_default_disabled():
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
tmp_path = Path(tmpdir)
|
||||
vault, enc_mgr = create_vault(tmp_path, TEST_SEED, TEST_PASSWORD)
|
||||
cfg_mgr = ConfigManager(vault, tmp_path)
|
||||
config = cfg_mgr.load_config(require_pin=False)
|
||||
assert config["offline_mode"] is True
|
||||
assert config["offline_mode"] is False
|
||||
@@ -0,0 +1,74 @@
|
||||
import queue
|
||||
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from seedpass.core.manager import PasswordManager
|
||||
|
||||
|
||||
class _DummyConfigManager:
|
||||
def __init__(self, cfg: dict) -> None:
|
||||
self.cfg = dict(cfg)
|
||||
self.saved: list[dict] = []
|
||||
|
||||
def load_config(self) -> dict:
|
||||
return dict(self.cfg)
|
||||
|
||||
def save_config(self, cfg: dict) -> None:
|
||||
snapshot = dict(cfg)
|
||||
self.cfg = snapshot
|
||||
self.saved.append(snapshot)
|
||||
|
||||
|
||||
class _DummyNostrClient:
|
||||
def __init__(self, **kwargs) -> None:
|
||||
self.kwargs = kwargs
|
||||
self.current_manifest_id = None
|
||||
self.current_manifest = None
|
||||
|
||||
|
||||
def _make_pm(cfg: dict) -> PasswordManager:
|
||||
pm = PasswordManager.__new__(PasswordManager)
|
||||
pm.config_manager = _DummyConfigManager(cfg)
|
||||
pm.state_manager = None
|
||||
pm.encryption_manager = object()
|
||||
pm.current_fingerprint = "fp-test"
|
||||
pm.parent_seed = "seed"
|
||||
pm.KEY_INDEX = b"index-key"
|
||||
pm.notifications = queue.Queue()
|
||||
pm._current_notification = None
|
||||
pm._notification_expiry = 0.0
|
||||
return pm
|
||||
|
||||
|
||||
def test_first_online_login_emits_notice_and_persists_seen(monkeypatch):
|
||||
pm = _make_pm({"offline_mode": False, "relays": ["wss://relay.example"]})
|
||||
monkeypatch.setattr("seedpass.core.manager.NostrClient", _DummyNostrClient)
|
||||
monkeypatch.setattr("builtins.print", lambda *a, **k: None)
|
||||
|
||||
pm._initialize_nostr_client()
|
||||
|
||||
note = pm.get_current_notification()
|
||||
assert note is not None
|
||||
assert "ONLINE by default" in note.message
|
||||
assert pm.config_manager.cfg.get("online_mode_notice_seen") is True
|
||||
assert len(pm.config_manager.saved) == 1
|
||||
|
||||
|
||||
def test_online_notice_not_repeated_when_seen(monkeypatch):
|
||||
pm = _make_pm(
|
||||
{
|
||||
"offline_mode": False,
|
||||
"online_mode_notice_seen": True,
|
||||
"relays": ["wss://relay.example"],
|
||||
}
|
||||
)
|
||||
monkeypatch.setattr("seedpass.core.manager.NostrClient", _DummyNostrClient)
|
||||
monkeypatch.setattr("builtins.print", lambda *a, **k: None)
|
||||
|
||||
pm._initialize_nostr_client()
|
||||
|
||||
assert pm.get_current_notification() is None
|
||||
assert pm.config_manager.saved == []
|
||||
Reference in new issue
Block a user