Testing
The root-level test_api.py script has been updated to:
- Authenticate first using JWT credentials
- Cache the returned access token
- Send the token on protected requests
- Display color-coded output for better readability
- Track test results (e.g., "All tests passed! 4/4")
- Return boolean status for each test function
Run it from the repository root:
python test_api.py
✅ Green checkmarks for successful operations
❌ Red X marks for failures
🔵 Blue headers for test sections
🔄 Test counter showing passed/total tests
Requirements
To use the enhanced test script with color output, install colorama:
Relevant Files
src/main/java/com/example/gateway/controller/AuthController.javasrc/main/java/com/example/gateway/config/SecurityConfig.javasrc/main/java/com/example/gateway/security/JwtService.javasrc/main/java/com/example/gateway/security/JwtAuthenticationFilter.javasrc/main/resources/application.ymlsrc/main/resources/application-prod.ymlsrc/main/java/com/example/gateway/dto/LoginRequest.javasrc/main/java/com/example/gateway/dto/LoginResponse.javasrc/main/java/com/example/gateway/dto/ErrorResponse.javatest_api.py
Current Limitations
- Single configured user only
- No user database integration
- No role-based authorization
- No refresh tokens
- No logout endpoint because the system is stateless
If the project needs stronger access control later, the next logical step is to replace configured credentials with a persistent user store and add roles.