Tighten checks for project leaders on creating a Program#4695
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughThe PR centralizes leader membership lookup on the GitHub user model, updates ProjectQuery.is_project_leader to return GithubUser.is_project_leader, and adds a project-leader authorization check to ProgramMutation.create_program; tests updated/added accordingly. ChangesLeader Detection Refactor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4695 +/- ##
=======================================
Coverage 98.88% 98.88%
=======================================
Files 538 538
Lines 17143 17152 +9
Branches 2457 2406 -51
=======================================
+ Hits 16951 16960 +9
Misses 103 103
Partials 89 89
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
289eb2b
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@backend/tests/unit/apps/mentorship/api/internal/mutations/program_mutation_test.py`:
- Around line 216-226: The tests that exercise the allow/validation path for
create_program currently don't set the authorization precondition; explicitly
set user.github_user.is_project_leader = True in those success/validation-path
tests (the ones that build input_data and call the create_program mutation
without expecting PermissionDenied) so they mirror the denial-path's explicit
leader flag and encode the required precondition; update the relevant test
functions that call create_program (and any helpers like _make_info if used
there) to ensure the user is a project leader before invoking the mutation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: f94704a7-e91b-4ee1-be46-fbc006771dd7
📒 Files selected for processing (6)
backend/apps/github/models/user.pybackend/apps/mentorship/api/internal/mutations/program.pybackend/apps/owasp/api/internal/queries/project.pybackend/tests/unit/apps/github/models/user_is_project_leader_test.pybackend/tests/unit/apps/mentorship/api/internal/mutations/program_mutation_test.pybackend/tests/unit/apps/owasp/api/internal/queries/project_test.py
|



Tighten a check for project leader on creating a Program in Mentorship portal.
Resolves #4283 and other issues where Chapter leaders seemed to be able to create a program.
Checklist
make check-testlocally: all warnings addressed, tests passed