mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-10 00:09:04 +00:00
Add custom field support
This commit is contained in:
@@ -21,7 +21,12 @@ def test_add_and_retrieve_entry():
|
||||
backup_mgr = BackupManager(Path(tmpdir), cfg_mgr)
|
||||
entry_mgr = EntryManager(vault, backup_mgr)
|
||||
|
||||
index = entry_mgr.add_entry("example.com", 12, "user")
|
||||
custom = [
|
||||
{"label": "api", "value": "123", "is_hidden": True},
|
||||
{"label": "note", "value": "hello", "is_hidden": False},
|
||||
]
|
||||
|
||||
index = entry_mgr.add_entry("example.com", 12, "user", custom_fields=custom)
|
||||
entry = entry_mgr.retrieve_entry(index)
|
||||
|
||||
assert entry == {
|
||||
@@ -33,6 +38,7 @@ def test_add_and_retrieve_entry():
|
||||
"type": "password",
|
||||
"kind": "password",
|
||||
"notes": "",
|
||||
"custom_fields": custom,
|
||||
}
|
||||
|
||||
data = enc_mgr.load_json_data(entry_mgr.index_file)
|
||||
|
@@ -52,14 +52,16 @@ def test_manager_workflow(monkeypatch):
|
||||
"example.com",
|
||||
"", # username
|
||||
"", # url
|
||||
"", # length (default)
|
||||
"", # notes
|
||||
"n", # add custom field
|
||||
"", # length (default)
|
||||
"0", # retrieve index
|
||||
"0", # modify index
|
||||
"user", # new username
|
||||
"", # new url
|
||||
"", # blacklist status
|
||||
"", # new notes
|
||||
"n", # edit custom fields
|
||||
]
|
||||
)
|
||||
monkeypatch.setattr("builtins.input", lambda *args, **kwargs: next(inputs))
|
||||
|
@@ -71,6 +71,21 @@ def test_search_by_notes_and_totp():
|
||||
assert res_totp == [(idx_totp, "GH", None, None, False)]
|
||||
|
||||
|
||||
def test_search_by_custom_field():
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
tmp_path = Path(tmpdir)
|
||||
entry_mgr = setup_entry_manager(tmp_path)
|
||||
|
||||
custom = [
|
||||
{"label": "api", "value": "secret123", "is_hidden": True},
|
||||
{"label": "note", "value": "visible", "is_hidden": False},
|
||||
]
|
||||
idx = entry_mgr.add_entry("Example", 8, custom_fields=custom)
|
||||
|
||||
result = entry_mgr.search_entries("secret123")
|
||||
assert result == [(idx, "Example", "", "", False)]
|
||||
|
||||
|
||||
def test_search_no_results():
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
tmp_path = Path(tmpdir)
|
||||
|
Reference in New Issue
Block a user