feat: validate Supabase RLS policies with pgTAP and JS tests (#546)#741
Open
Sammy-Samy wants to merge 1 commit into
Open
feat: validate Supabase RLS policies with pgTAP and JS tests (#546)#741Sammy-Samy wants to merge 1 commit into
Sammy-Samy wants to merge 1 commit into
Conversation
…Joe#546) - Replace migration 004 with a full pgTAP suite (28 SQL tests) covering: own-data access, cross-operator SELECT/INSERT/UPDATE/DELETE isolation on cooperatives / meters / readings / certificates, admin bypass, unauthenticated denial, readings-via-meter-join scoping, and certificate retirement visibility. - Add supabase/tests/rls_policies.sql — standalone pgTAP file (28 tests) wrapped in a BEGIN/ROLLBACK transaction so it is safe to run on any database independently of the migration process. - Add apps/web/src/__tests__/rls.test.ts — JS/TS integration harness (32 tests across 7 describe blocks) using a mocked Supabase client; runs in CI without a live database. - Update supabase/migrations/rollbacks/20240101000004_rls_tests.down.sql to delete all pgTAP fixture rows in dependency order. - Update .github/workflows/supabase.yml to run `supabase db test` after `supabase db reset`, so pgTAP failures block CI. Closes AnnabelJoe#546
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #546 — Validate Supabase row-level security rules with tests.
What changed
supabase/migrations/20240101000004_rls_tests.sqlsupabase/tests/rls_policies.sqlsupabase db testorpsqlapps/web/src/__tests__/rls.test.tssupabase/migrations/rollbacks/20240101000004_rls_tests.down.sql.github/workflows/supabase.ymlsupabase db teststep aftersupabase db resetTest coverage (7 categories, 60 total tests)
How to test locally
Checklist