This document describes how to run the test suite for the password manager.
The password manager uses PBKDF2 for key derivation (100,000 iterations with unique salt) and AES-256-GCM for authenticated encryption.
Insecure or unnecessary modes (ECB, CBC, CFB, OFB, CTR) have been removed to maintain security best practices. All datastores use GCM mode for authenticated encryption with tamper detection.
The test suite comprehensively covers all cryptographic operations, datastore operations, and edge cases.
Install the test dependencies:
pip install -r requirements-test.txtOr install pytest directly:
pip install pytest pycryptodomeRun all tests:
pytestRun with verbose output:
pytest -vRun specific test file:
pytest tests/test_crypto.py
pytest tests/test_datastore.py
pytest tests/test_pwmanager.pyOr from the root directory:
python3 -m pytest tests/test_crypto.pyRun specific test class:
pytest tests/test_crypto.py::TestGetAESMode
pytest tests/test_datastore.py::TestValidateStorePathRun specific test:
pytest tests/test_crypto.py::TestGetAESMode::test_valid_modes
pytest tests/test_datastore.py::TestValidateStorePath::test_valid_pathsThe test suite covers:
-
Cryptographic Operations (
test_crypto.py)get_aes_mode()- Cipher mode conversionderive_key()- Key derivation from passphrasederive_challenge()- Challenge generationgenerate_random_password()- Random password generation- GCM mode encryption/decryption
- Authentication tag handling for GCM
- Constants validation
-
Datastore Operations (
test_datastore.py)validate_store_path()- Path validationload_datastore()/save_datastore()- File operationscreate_backup_file()- Backup creationverify_passphrase()- Passphrase verificationinitialize_datastore()- New datastore creationencrypt_entry()/decrypt_entry()- Entry encryption/decryption
-
Integration Tests (
test_pwmanager.py)- Path validation (integration)
- Application-level functionality
- Python >= 3.8
- pytest >= 7.0.0
- pycryptodome >= 3.15.0
Tests are organized by module, matching the codebase structure:
TestGetAESMode- Cipher mode conversionTestKeyDerivation- Key and challenge derivationTestRandomPassword- Random password generationTestGCMEncryptionDecryption- GCM mode operationsTestConstants- Cryptographic constants
TestValidateStorePath- Path validationTestDatastoreFileOperations- File save/load/backupTestVerifyPassphrase- Passphrase verificationTestInitializeDatastore- Datastore initializationTestEntryEncryptionDecryption- Entry encryption/decryption
TestValidateStorePath- Path validation (integration)
Shared fixtures are available in tests/conftest.py.
To check test coverage (requires pytest-cov):
pip install pytest-cov
pytest --cov=pwmanager --cov-report=htmlThis will generate an HTML coverage report in the htmlcov/ directory.