-
-
Notifications
You must be signed in to change notification settings - Fork 31
🐛 destructive operations gates #184
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
Conversation
WalkthroughThe changes separate authorization checks from mutation operations (destroy, restore, force delete) in batch model operations, ensuring all models are authorized before any mutation occurs. New tests verify that if any model in a batch is unauthorized, the operation is denied for all. A custom policy class is introduced to facilitate fine-grained authorization testing. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Controller
participant Authorization
participant Model
Client->>Controller: Batch mutation request (delete/restore/forceDelete)
Controller->>Authorization: Check authorization for all models
Authorization-->>Controller: Authorization result (all or any unauthorized)
alt All authorized
Controller->>Model: Perform mutation on all models
Model-->>Controller: Mutation results
Controller-->>Client: Success response
else Any unauthorized
Controller-->>Client: 403 Forbidden, no mutations performed
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Assessment against linked issues
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (5)
🧰 Additional context used🧠 Learnings (1)📚 Learning: in laravel rest api controller generation tests, the resource class assertions are expected to be di...Applied to files:
🧬 Code Graph Analysis (1)tests/Feature/Controllers/DeleteOperationsTest.php (2)
🪛 PHPMD (2.15.0)tests/Support/Policies/RedPolicyButForModel.php26-26: Avoid unused parameters such as '$user'. (Unused Code Rules) (UnusedFormalParameter) 39-39: Avoid unused parameters such as '$user'. (Unused Code Rules) (UnusedFormalParameter) 51-51: Avoid unused parameters such as '$user'. (Unused Code Rules) (UnusedFormalParameter) 64-64: Avoid unused parameters such as '$user'. (Unused Code Rules) (UnusedFormalParameter) 77-77: Avoid unused parameters such as '$user'. (Unused Code Rules) (UnusedFormalParameter) 90-90: Avoid unused parameters such as '$user'. (Unused Code Rules) (UnusedFormalParameter) 103-103: Avoid unused parameters such as '$user'. (Unused Code Rules) (UnusedFormalParameter) 🔇 Additional comments (10)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
closes #181
Summary by CodeRabbit
Tests
Refactor