Refactor is_valid and api_required to have more straightforward logic, utilize function extraction where possible, and replace magic numbers and magic strings with reusable constants and functions.
Add tests for both in middleware\test_security.py, providing 100% coverage.
Testing
`middleware\test_security.py
Performance
Additional test overhead -- 5 seconds on my computer
Fixes
Description
is_valid
andapi_required
to have more straightforward logic, utilize function extraction where possible, and replace magic numbers and magic strings with reusable constants and functions.middleware\test_security.py
, providing 100% coverage.Testing
`middleware\test_security.py
Performance
Docs