Repository navigation
TML-2501: migrate RLS acceptance test onto dbInit-applied PSL policies - #956
Conversation
The rls-role-binding acceptance test hand-applied ENABLE ROW LEVEL SECURITY and two CREATE POLICY statements on top of the policies dbInit already applies from contract.prisma, so it passed on the union of both permissive sets. Delete the hand-authored set: the fixture keeps only grants (renamed applyGrantsFixture), and a new assertion proves profile_owner_write WITH CHECK rejects reassigning a profile to another owner. Slice B of extension-supabase is closed out in the plan. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
|
Warning Review limit reached
Next review available in: 16 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✨ 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 |
size-limit report 📦
|
Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
Linked issue
Refs TML-2501. Closes out Slice B of
projects/extension-supabase/plan.md— the remainder after the postgres-rls slices landed the authoring surface.At a glance
The ADR-230 role-binding acceptance test now proves the policies that
dbInitapplies from the PSL, ending with a WITH CHECK case the hand-written policies never had:Before this PR the test's fixture also ran its own
ALTER TABLE … ENABLE ROW LEVEL SECURITYplus two hand-writtenCREATE POLICYstatements on top of the PSL-authored set, so the test passed on the union of both permissive policy sets.Decision
Delete the hand-authored RLS SQL from
rls-role-binding.integration.test.tsand make the test exercise only the three policies authored inexamples/supabase/src/contract.prisma(profile_owner_read,profile_public_read,profile_owner_write) and applied bydbInit. The fixture keeps only grants and is renamedapplyGrantsFixture; the framework plans no GRANT statements, so grants remain test-fixture territory.Reviewer notes
current_setting('request.jwt.claims', true)::json->>'sub'directly, the PSL ones callauth.uid()— equivalent through the test shim'sauth.uid()definition (supabase-bootstrap.ts). Every existing assertion passed unchanged on the PSL-only set.profile_owner_writedoes. The new assertion covers the delta: reassigning your own profile to another owner is rejected with Postgres's row-level-security error, not a 0-row count.skeleton.integration.test.tsstill mentionsCREATE POLICY/ENABLE RLSin a comment and an assertion message — those assert the framework's generated plan contains the ops (rlsPolicy.*/rowLevelSecurity.*op ids), not raw SQL.applyGrantsFixtureoverlap with the shim'sALTER DEFAULT PRIVILEGES; kept as-is since grants are out of scope for this slice.Behavior changes & evidence
CREATE POLICY/ENABLE ROW LEVEL SECURITYremains anywhere underexamples/supabase/— the acceptance test's RLS surface is entirelydbInit-applied. Evidence: rls-role-binding.integration.test.ts (fixture now grants-only; header documents the PSL policy names).itblock in the same file.Testing performed
pnpm --filter @prisma-next/example-supabase test— 4 files, 17/17 passed (rls-role-binding, skeleton, explicit-namespace-query, native-enum-session)pnpm build+pnpm typecheck— greenpnpm test:integration— 196 files, 1136 passed, no type errorspnpm lint:deps,pnpm lint:casts(no branch delta),pnpm fixtures:check— cleanSkill update
n/a — internal only (test + project-plan change; no user-facing surface).
Alternatives considered
bootstrapSupabaseShim— not needed; only this test uses them, and the shim'sALTER DEFAULT PRIVILEGESalready covers the common cases. A slimmed, renamed fixture keeps the residual grants visible next to the test that needs them.Checklist
git commit -s) per the DCO. The DCO status check will block merge if any commit is missing aSigned-off-by:trailer.n/aif the change is doc-only / refactor with no behavioural delta).TML-NNNN: <sentence-case title>form (Linear ticket prefix + concise title naming the concrete deliverable). See.claude/skills/create-pr/SKILL.mdfor the full convention.n/a — internal only).