test(scope-requests): add grant-enforcement E2E, tighten approve tolerance, add deny negative test#2108
test(scope-requests): add grant-enforcement E2E, tighten approve tolerance, add deny negative test#2108hognek wants to merge 1 commit into
Conversation
…rance, add deny negative test Three test gaps filled following PR jaylfc#1921 merge: 1. E2E grant-enforcement test (test_approved_scope_grant_unlocks_route_e2e): agent self-requests decisions_write → admin approves → agent uses token on POST /api/decisions → assert 200. Proves the full grant-enforcement chain is wired end to end. Regression guard for issue jaylfc#2095. 2. Tighten test_agent_cannot_approve_its_own_request: replace (401, 403) tolerance with exact 401. The middleware does not pass a registry JWT through to the approve handler (only the create path is allowlisted), so it falls to the session gate → 401 exactly. 3. Deny negative test (test_agent_cannot_deny_its_own_request): same auth model as approve — middleware does not allowlist the deny endpoint for registry JWTs, so an agent token on the deny endpoint falls through to the session gate → 401.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
📝 WalkthroughWalkthroughThe scope-request tests now require registry tokens to receive ChangesScope request authorization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
Follow-up to PR #1921. Three test gaps filled:
E2E grant-enforcement test — proves an approved scope grant actually unlocks a route. Full flow: agent requests
decisions_write→ admin approves → agent uses the token onPOST /api/decisions→ 200. Would have caught Project routes ignore agent grants: an approved project_tasks scope grants nothing #2095 before it shipped.Tighten
test_agent_cannot_approve_its_own_request— replacedassert resp.status_code in (401, 403)with exact 401. The middleware does not pass a registry JWT through to /approve (only the create path is allowlisted), so it falls to the session gate → 401, never 403.Deny negative test — new
test_agent_cannot_deny_its_own_requestasserting an agent's own registry token cannot reach the deny endpoint. Same auth model as approve.All 3 new tests pass. 18/18 total in test_agent_scope_requests.py.
Summary by CodeRabbit