mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 07:48:57 +00:00
Add unit tests and update docs
This commit is contained in:
@@ -159,6 +159,15 @@ SeedPass allows you to manage multiple seed profiles (previously referred to as
|
|||||||
|
|
||||||
**Note:** The term "seed profile" is used to represent different sets of seeds you can manage within SeedPass. This provides an intuitive way to handle multiple identities or sets of passwords.
|
**Note:** The term "seed profile" is used to represent different sets of seeds you can manage within SeedPass. This provides an intuitive way to handle multiple identities or sets of passwords.
|
||||||
|
|
||||||
|
## Running Tests
|
||||||
|
|
||||||
|
SeedPass includes a small suite of unit tests. After activating your virtual environment and installing dependencies, run the tests with **pytest**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pytest
|
||||||
|
```
|
||||||
|
|
||||||
## Security Considerations
|
## Security Considerations
|
||||||
|
|
||||||
**Important:** The password you use to encrypt your parent seed is also required to decrypt the seed index data retrieved from Nostr. **It is imperative to remember this password** and be sure to use it with the same seed, as losing it means you won't be able to access your stored index. Secure your 12-word seed **and** your master password.
|
**Important:** The password you use to encrypt your parent seed is also required to decrypt the seed index data retrieved from Nostr. **It is imperative to remember this password** and be sure to use it with the same seed, as losing it means you won't be able to access your stored index. Secure your 12-word seed **and** your master password.
|
||||||
|
@@ -8,3 +8,5 @@ mnemonic
|
|||||||
aiohttp
|
aiohttp
|
||||||
bcrypt
|
bcrypt
|
||||||
bip85
|
bip85
|
||||||
|
pytest>=7.0
|
||||||
|
|
||||||
|
38
src/tests/test_fingerprint_encryption.py
Normal file
38
src/tests/test_fingerprint_encryption.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import hashlib
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from tempfile import TemporaryDirectory
|
||||||
|
|
||||||
|
from cryptography.fernet import Fernet
|
||||||
|
|
||||||
|
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||||
|
|
||||||
|
from utils.fingerprint import generate_fingerprint
|
||||||
|
from password_manager.encryption import EncryptionManager
|
||||||
|
|
||||||
|
|
||||||
|
def test_generate_fingerprint_deterministic():
|
||||||
|
seed = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
|
||||||
|
expected = (
|
||||||
|
hashlib.sha256(seed.strip().lower().encode("utf-8")).hexdigest()[:16].upper()
|
||||||
|
)
|
||||||
|
fp1 = generate_fingerprint(seed)
|
||||||
|
fp2 = generate_fingerprint(seed.upper())
|
||||||
|
assert fp1 == expected
|
||||||
|
assert fp1 == fp2
|
||||||
|
|
||||||
|
|
||||||
|
def test_encryption_round_trip():
|
||||||
|
with TemporaryDirectory() as tmpdir:
|
||||||
|
key = Fernet.generate_key()
|
||||||
|
manager = EncryptionManager(key, Path(tmpdir))
|
||||||
|
data = b"secret data"
|
||||||
|
rel_path = Path("testfile.enc")
|
||||||
|
manager.encrypt_and_save_file(data, rel_path)
|
||||||
|
decrypted = manager.decrypt_file(rel_path)
|
||||||
|
assert decrypted == data
|
||||||
|
|
||||||
|
# parent seed round trip
|
||||||
|
seed = "correct horse battery staple"
|
||||||
|
manager.encrypt_parent_seed(seed)
|
||||||
|
assert manager.decrypt_parent_seed() == seed
|
Reference in New Issue
Block a user