diff --git a/README.md b/README.md index 64d6dab..02edde9 100644 --- a/README.md +++ b/README.md @@ -181,11 +181,11 @@ You can manage the relay list or change the PIN through the **Settings** menu: ## Running Tests -SeedPass includes a small suite of unit tests. After activating your virtual environment and installing dependencies, run the tests with **pytest**: +SeedPass includes a small suite of unit tests. After activating your virtual environment and installing dependencies, run the tests with **pytest**. Use `-vv` to see INFO-level log messages from each passing test: ```bash pip install -r src/requirements.txt -pytest +pytest -vv ``` ## Security Considerations diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..11c72fa --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +log_cli = true +log_cli_level = INFO diff --git a/src/tests/test_key_derivation.py b/src/tests/test_key_derivation.py new file mode 100644 index 0000000..6eff174 --- /dev/null +++ b/src/tests/test_key_derivation.py @@ -0,0 +1,18 @@ +import logging +import pytest +from utils.key_derivation import derive_key_from_password + + +def test_derive_key_deterministic(): + password = "correct horse battery staple" + key1 = derive_key_from_password(password, iterations=1) + key2 = derive_key_from_password(password, iterations=1) + assert key1 == key2 + assert len(key1) == 44 + logging.info("Deterministic key derivation succeeded") + + +def test_derive_key_empty_password_error(): + with pytest.raises(ValueError): + derive_key_from_password("") + logging.info("Empty password correctly raised ValueError")