Update tests for entries schema

This commit is contained in:
thePR0M3TH3AN
2025-07-02 23:09:10 -04:00
parent a00d97b076
commit 609751bf66
13 changed files with 75 additions and 29 deletions

View File

@@ -1,6 +1,7 @@
import sys
from pathlib import Path
from tempfile import TemporaryDirectory
import pytest
from helpers import create_vault, TEST_SEED, TEST_PASSWORD
sys.path.append(str(Path(__file__).resolve().parents[1]))
@@ -30,3 +31,30 @@ def test_add_and_retrieve_entry():
data = enc_mgr.load_json_data(entry_mgr.index_file)
assert str(index) in data.get("entries", {})
assert data["entries"][str(index)] == entry
@pytest.mark.parametrize(
"method, expected_type",
[
("add_entry", "password"),
("add_totp", "totp"),
("add_ssh_key", "ssh"),
("add_seed", "seed"),
],
)
def test_round_trip_entry_types(method, expected_type):
with TemporaryDirectory() as tmpdir:
vault, enc_mgr = create_vault(Path(tmpdir), TEST_SEED, TEST_PASSWORD)
entry_mgr = EntryManager(vault, Path(tmpdir))
if method == "add_entry":
index = entry_mgr.add_entry("example.com", 8)
else:
with pytest.raises(NotImplementedError):
getattr(entry_mgr, method)()
index = 0
entry = entry_mgr.retrieve_entry(index)
assert entry["type"] == expected_type
data = enc_mgr.load_json_data(entry_mgr.index_file)
assert data["entries"][str(index)]["type"] == expected_type