From 0088211193cd1edc01484757a4b02d1aaad4b72d Mon Sep 17 00:00:00 2001 From: thePR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> Date: Sun, 29 Jun 2025 23:06:22 -0400 Subject: [PATCH] Add pytest config and key derivation tests --- README.md | 4 ++-- pytest.ini | 3 +++ src/tests/test_key_derivation.py | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 pytest.ini create mode 100644 src/tests/test_key_derivation.py 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")