Skip to content

Commit f13a462

Browse files
committed
test: regress policies on auth tables
1 parent bf0f554 commit f13a462

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

nix/tests/expected/auth.out

+19-13
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,35 @@ where r.rolname = 'supabase_auth_admin';
4040
{search_path=auth,idle_in_transaction_session_timeout=60000,log_statement=none}
4141
(1 row)
4242

43-
-- auth schema tables with owners
43+
-- auth schema tables with owners and rls policies
4444
select
45-
n.nspname as schema_name,
45+
ns.nspname as schema_name,
4646
c.relname as table_name,
47-
r.rolname as owner
47+
r.rolname as owner,
48+
c.relrowsecurity as rls_enabled,
49+
string_agg(p.polname, ', ' order by p.polname) as rls_policies
4850
from
4951
pg_class c
5052
join
51-
pg_namespace n on c.relnamespace = n.oid
53+
pg_namespace ns on c.relnamespace = ns.oid
5254
join
5355
pg_roles r on c.relowner = r.oid
56+
left join
57+
pg_policy p on p.polrelid = c.oid
5458
where
55-
c.relkind in ('r') -- 'r' for regular tables
56-
and n.nspname = 'auth'
59+
ns.nspname = 'auth'
60+
and c.relkind = 'r'
61+
group by
62+
ns.nspname, c.relname, r.rolname, c.relrowsecurity
5763
order by
5864
c.relname;
59-
schema_name | table_name | owner
60-
-------------+-------------------+---------------------
61-
auth | audit_log_entries | supabase_auth_admin
62-
auth | instances | supabase_auth_admin
63-
auth | refresh_tokens | supabase_auth_admin
64-
auth | schema_migrations | supabase_auth_admin
65-
auth | users | supabase_auth_admin
65+
schema_name | table_name | owner | rls_enabled | rls_policies
66+
-------------+-------------------+---------------------+-------------+--------------
67+
auth | audit_log_entries | supabase_auth_admin | f |
68+
auth | instances | supabase_auth_admin | f |
69+
auth | refresh_tokens | supabase_auth_admin | f |
70+
auth | schema_migrations | supabase_auth_admin | f |
71+
auth | users | supabase_auth_admin | f |
6672
(5 rows)
6773

6874
-- auth indexes with owners

nix/tests/sql/auth.sql

+12-6
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,26 @@ select
2828
from pg_roles r
2929
where r.rolname = 'supabase_auth_admin';
3030

31-
-- auth schema tables with owners
31+
-- auth schema tables with owners and rls policies
3232
select
33-
n.nspname as schema_name,
33+
ns.nspname as schema_name,
3434
c.relname as table_name,
35-
r.rolname as owner
35+
r.rolname as owner,
36+
c.relrowsecurity as rls_enabled,
37+
string_agg(p.polname, ', ' order by p.polname) as rls_policies
3638
from
3739
pg_class c
3840
join
39-
pg_namespace n on c.relnamespace = n.oid
41+
pg_namespace ns on c.relnamespace = ns.oid
4042
join
4143
pg_roles r on c.relowner = r.oid
44+
left join
45+
pg_policy p on p.polrelid = c.oid
4246
where
43-
c.relkind in ('r') -- 'r' for regular tables
44-
and n.nspname = 'auth'
47+
ns.nspname = 'auth'
48+
and c.relkind = 'r'
49+
group by
50+
ns.nspname, c.relname, r.rolname, c.relrowsecurity
4551
order by
4652
c.relname;
4753

0 commit comments

Comments
 (0)