Improve test profile script

This commit is contained in:
thePR0M3TH3AN
2025-07-06 17:46:42 -04:00
parent efdefd1563
commit f85968afa9
2 changed files with 28 additions and 16 deletions

View File

@@ -360,14 +360,13 @@ pytest -vv -s -n 0 src/tests/test_nostr_index_size.py --desktop --max-entries=10
Use the helper script below to populate a profile with sample entries for testing:
```bash
python scripts/generate_test_profile.py --profile my_profile --count 100
python scripts/generate_test_profile.py --profile demo_profile --count 100
```
This command creates `~/.seedpass/my_profile` if needed and adds 100 example entries.
After populating the vault, the script prints the derived **fingerprint** and
automatically publishes the encrypted index to Nostr under that fingerprint.
Use the same seed phrase when loading SeedPass so it can retrieve the data from
Nostr.
The script now determines the fingerprint from the generated seed and stores the
vault under `~/.seedpass/<fingerprint>`. It also prints the fingerprint after
creation and publishes the encrypted index to Nostr. Use that same seed phrase
to load SeedPass so it can automatically retrieve the data from Nostr.
### Automatically Updating the Script Checksum

View File

@@ -37,15 +37,15 @@ import gzip
DEFAULT_PASSWORD = "testpassword"
def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path]:
"""Create or load a profile and return the seed phrase and manager."""
profile_dir = APP_DIR / profile_name
profile_dir.mkdir(parents=True, exist_ok=True)
def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path, str]:
"""Create or load a profile and return the seed phrase, manager, directory and fingerprint."""
temp_dir = APP_DIR / profile_name
temp_dir.mkdir(parents=True, exist_ok=True)
seed_key = derive_key_from_password(DEFAULT_PASSWORD)
seed_mgr = EncryptionManager(seed_key, profile_dir)
seed_file = profile_dir / "parent_seed.enc"
clear_path = profile_dir / "seed_phrase.txt"
seed_mgr = EncryptionManager(seed_key, temp_dir)
seed_file = temp_dir / "parent_seed.enc"
clear_path = temp_dir / "seed_phrase.txt"
if seed_file.exists():
seed_phrase = seed_mgr.decrypt_parent_seed()
@@ -65,13 +65,27 @@ def initialize_profile(profile_name: str) -> tuple[str, EntryManager, Path]:
clear_path.write_text(seed_phrase)
clear_path.chmod(0o600)
fingerprint = generate_fingerprint(seed_phrase) or profile_name
profile_dir = APP_DIR / fingerprint
if profile_dir != temp_dir:
profile_dir.mkdir(parents=True, exist_ok=True)
for p in temp_dir.iterdir():
target = profile_dir / p.name
if not target.exists():
p.rename(target)
try:
temp_dir.rmdir()
except OSError:
pass
seed_mgr.fingerprint_dir = profile_dir
index_key = derive_index_key(seed_phrase)
enc_mgr = EncryptionManager(index_key, profile_dir)
vault = Vault(enc_mgr, profile_dir)
cfg_mgr = ConfigManager(vault, profile_dir)
backup_mgr = BackupManager(profile_dir, cfg_mgr)
entry_mgr = EntryManager(vault, backup_mgr)
return seed_phrase, entry_mgr, profile_dir
return seed_phrase, entry_mgr, profile_dir, fingerprint
def random_secret(length: int = 16) -> str:
@@ -132,8 +146,7 @@ def main() -> None:
)
args = parser.parse_args()
seed, entry_mgr, dir_path = initialize_profile(args.profile)
fingerprint = generate_fingerprint(seed)
seed, entry_mgr, dir_path, fingerprint = initialize_profile(args.profile)
print(f"Using profile directory: {dir_path}")
print(f"Parent seed: {seed}")
if fingerprint: