mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Validate entry type fields
This commit is contained in:
@@ -93,6 +93,19 @@ def test_create_and_modify_ssh_entry(client):
|
||||
assert calls["modify"][1]["notes"] == "x"
|
||||
|
||||
|
||||
def test_update_entry_error(client):
|
||||
cl, token = client
|
||||
|
||||
def modify(*a, **k):
|
||||
raise ValueError("nope")
|
||||
|
||||
api._pm.entry_manager.modify_entry = modify
|
||||
headers = {"Authorization": f"Bearer {token}"}
|
||||
res = cl.put("/api/v1/entry/1", json={"username": "x"}, headers=headers)
|
||||
assert res.status_code == 400
|
||||
assert res.json() == {"detail": "nope"}
|
||||
|
||||
|
||||
def test_update_config_secret_mode(client):
|
||||
cl, token = client
|
||||
called = {}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
from helpers import create_vault, TEST_SEED, TEST_PASSWORD
|
||||
import pytest
|
||||
|
||||
from password_manager.entry_management import EntryManager
|
||||
from password_manager.backup import BackupManager
|
||||
@@ -18,3 +19,14 @@ def test_modify_totp_entry_period_digits_and_archive(tmp_path):
|
||||
assert entry["period"] == 60
|
||||
assert entry["digits"] == 8
|
||||
assert entry["archived"] is True
|
||||
|
||||
|
||||
def test_modify_totp_entry_invalid_field(tmp_path):
|
||||
vault, _ = create_vault(tmp_path, TEST_SEED, TEST_PASSWORD)
|
||||
cfg_mgr = ConfigManager(vault, tmp_path)
|
||||
backup_mgr = BackupManager(tmp_path, cfg_mgr)
|
||||
em = EntryManager(vault, backup_mgr)
|
||||
|
||||
em.add_totp("Example", TEST_SEED)
|
||||
with pytest.raises(ValueError):
|
||||
em.modify_entry(0, username="alice")
|
||||
|
@@ -396,6 +396,21 @@ def test_entry_modify(monkeypatch):
|
||||
assert called["args"][:5] == (1, "alice", None, None, None)
|
||||
|
||||
|
||||
def test_entry_modify_invalid(monkeypatch):
|
||||
def modify_entry(*a, **k):
|
||||
raise ValueError("bad")
|
||||
|
||||
pm = SimpleNamespace(
|
||||
entry_manager=SimpleNamespace(modify_entry=modify_entry),
|
||||
select_fingerprint=lambda fp: None,
|
||||
sync_vault=lambda: None,
|
||||
)
|
||||
monkeypatch.setattr(cli, "PasswordManager", lambda: pm)
|
||||
result = runner.invoke(app, ["entry", "modify", "1", "--username", "alice"])
|
||||
assert result.exit_code == 1
|
||||
assert "bad" in result.stdout
|
||||
|
||||
|
||||
def test_entry_archive(monkeypatch):
|
||||
called = {}
|
||||
|
||||
|
Reference in New Issue
Block a user