- Enhance .gitignore with comprehensive Python patterns - Improve README with better setup and testing instructions - Add test infrastructure: * Test requirements file * Environment setup script * Test runner script * Comprehensive test suite * Coverage configuration
Testing
This directory contains tests for the OIDC validator application.
Setup
Using the setup script (recommended)
- Run the setup script:
./setup_test_env.sh
This will create a virtual environment and install all dependencies.
Manual setup
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate -
Install application dependencies:
pip install -r requirements.txt -
Install test dependencies:
pip install -r requirements-test.txt
Running Tests
Using the test runner script (recommended)
./run_tests.sh
This will automatically activate the virtual environment and run the tests.
Manual execution
-
Activate the virtual environment:
source venv/bin/activate -
Run tests:
# Run all tests pytest # Run tests with coverage (excluding tests directory) pytest --cov=. --cov-config=.coveragerc # Run tests with verbose output pytest -v -
Deactivate the virtual environment when done:
deactivate
Coverage Reports
The test suite generates coverage reports to help you understand how well the code is tested:
- Terminal coverage report is displayed after running tests
- HTML coverage report is generated in the
htmlcov/directory - The coverage configuration excludes the tests directory itself from coverage statistics
Test Structure
conftest.py: Contains pytest fixtures shared across teststest_main.py: Tests for the main FastAPI application endpointstest_token_validation.py: Tests for token validation and refresh logictest_utils.py: Tests for utility functions
Test Coverage
The tests cover:
- Health check endpoint
- Token validation endpoint
- Token refresh endpoint
- Client configuration endpoint
- Utility functions for OIDC operations
- Error handling for various failure scenarios
- Edge cases and invalid inputs