-
Notifications
You must be signed in to change notification settings - Fork 1
Add POST /books/{book_id}/reservations (JWT-protected) #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add POST /books/{book_id}/reservations (JWT-protected) #15
Conversation
The decorator unit tests were failing with a because they created a minimal Flask app without any configuration. This commit creates a local, file-specific fixture that configures the test app with the required . To ensure perfect isolation, the dummy route used by the tests is now defined directly within this new fixture.
Replaced the previous payload-based check with the auth_token fixture, which generates a proper JWT in the Authorization header. This ensures tests now align with the current auth flow and avoids reliance on outdated payload logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new JWT-protected POST endpoint for creating book reservations, implementing the /books/{book_id}/reservations route with authentication and duplicate prevention logic.
Key Changes:
- New JWT-protected reservation creation endpoint with duplicate prevention
- JWT configuration separation from general Flask SECRET_KEY
- Updated OpenAPI specification to reflect JWT protection requirements
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
app/routes/reservation_routes.py |
New route handler for POST /books/{book_id}/reservations with JWT protection and business logic |
app/utils/decorators.py |
Updated JWT decorator to use dedicated JWT_SECRET_KEY instead of general SECRET_KEY |
app/config.py |
Added JWT_SECRET_KEY configuration separate from Flask's SECRET_KEY |
app/__init__.py |
Registered new reservations blueprint with the Flask app |
app/routes/auth_routes.py |
Updated login route to use JWT_SECRET_KEY for token generation |
tests/test_reservations.py |
Comprehensive test suite for the new reservation endpoint |
tests/conftest.py |
Added JWT_SECRET_KEY to test configuration and improved user fixture |
tests/test_decorators.py |
Updated decorator tests to align with new JWT configuration |
tests/test_auth.py |
Updated auth tests to use JWT_SECRET_KEY |
openapi.yml |
Updated API specification to reflect JWT protection and new response schemas |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Description
Summary:
Adds POST /books/{book_id}/reservations to allow authenticated users to create reservations. The route is protected by require_jwt and prevents duplicate reservations by the same user.
Key Changes:
Follow-up:
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Checklist: