@pgpm/supabase 0.5.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +2 -1
  2. package/Makefile +2 -3
  3. package/README.md +45 -59
  4. package/deploy/roles/anon.sql +15 -0
  5. package/deploy/schemas/supabase_integration/procedures/pre_request.sql +26 -0
  6. package/deploy/schemas/supabase_integration/schema.sql +9 -0
  7. package/package.json +27 -12
  8. package/pgpm-supabase.control +7 -0
  9. package/pgpm.plan +6 -3
  10. package/revert/roles/anon.sql +7 -0
  11. package/revert/schemas/supabase_integration/procedures/pre_request.sql +7 -0
  12. package/revert/schemas/supabase_integration/schema.sql +7 -0
  13. package/sql/pgpm-supabase--1.0.0.bundle.tar.gz +0 -0
  14. package/sql/pgpm-supabase--1.0.0.sql +32 -0
  15. package/verify/roles/anon.sql +12 -0
  16. package/verify/schemas/supabase_integration/procedures/pre_request.sql +19 -0
  17. package/verify/schemas/supabase_integration/schema.sql +18 -0
  18. package/__tests__/_realtime/_realtime-extensions.test.ts +0 -129
  19. package/__tests__/_realtime/_realtime-schema-migrations.test.ts +0 -160
  20. package/__tests__/_realtime/_realtime-tenants.test.ts +0 -163
  21. package/__tests__/auth/auth.audit-log-entries.test.ts +0 -148
  22. package/__tests__/auth/auth.flow-state.test.ts +0 -114
  23. package/__tests__/auth/auth.identities.test.ts +0 -149
  24. package/__tests__/auth/auth.instances.test.ts +0 -134
  25. package/__tests__/auth/auth.mfa-amr-claims.test.ts +0 -142
  26. package/__tests__/auth/auth.mfa-challenges.test.ts +0 -117
  27. package/__tests__/auth/auth.mfa-factors.test.ts +0 -118
  28. package/__tests__/auth/auth.oauth-authorizations.test.ts +0 -123
  29. package/__tests__/auth/auth.oauth-clients.test.ts +0 -120
  30. package/__tests__/auth/auth.oauth-consents.test.ts +0 -122
  31. package/__tests__/auth/auth.one-time-tokens.test.ts +0 -194
  32. package/__tests__/auth/auth.refresh-tokens.test.ts +0 -134
  33. package/__tests__/auth/auth.saml-providers.test.ts +0 -154
  34. package/__tests__/auth/auth.saml-relay-states.test.ts +0 -145
  35. package/__tests__/auth/auth.schema-migrations.test.ts +0 -131
  36. package/__tests__/auth/auth.sessions.test.ts +0 -140
  37. package/__tests__/auth/auth.sso-domains.test.ts +0 -137
  38. package/__tests__/auth/auth.sso-providers.test.ts +0 -136
  39. package/__tests__/auth/auth.users.test.ts +0 -314
  40. package/__tests__/conditional.test.ts +0 -229
  41. package/__tests__/functions.test.ts +0 -252
  42. package/__tests__/jsonb.test.ts +0 -237
  43. package/__tests__/net/net.http-request-queue.test.ts +0 -159
  44. package/__tests__/net/net.http-response.test.ts +0 -163
  45. package/__tests__/realtime/realtime.messages-2025-10-31.test.ts +0 -168
  46. package/__tests__/realtime/realtime.messages.test.ts +0 -162
  47. package/__tests__/realtime/realtime.schema-migrations.test.ts +0 -139
  48. package/__tests__/realtime/realtime.subscription.test.ts +0 -159
  49. package/__tests__/storage/storage.buckets-analytics.test.ts +0 -134
  50. package/__tests__/storage/storage.buckets.test.ts +0 -146
  51. package/__tests__/storage/storage.iceberg-namespaces.test.ts +0 -132
  52. package/__tests__/storage/storage.iceberg-tables.test.ts +0 -142
  53. package/__tests__/storage/storage.migrations.test.ts +0 -133
  54. package/__tests__/storage/storage.objects.test.ts +0 -160
  55. package/__tests__/storage/storage.prefixes.test.ts +0 -138
  56. package/__tests__/storage/storage.s3-multipart-uploads-parts.test.ts +0 -133
  57. package/__tests__/storage/storage.s3-multipart-uploads.test.ts +0 -128
  58. package/__tests__/supabase-functions/supabase.functions-hooks.test.ts +0 -125
  59. package/__tests__/supabase-functions/supabase.functions-migrations.test.ts +0 -213
  60. package/__tests__/temporal.test.ts +0 -225
  61. package/__tests__/vault-secrets.test.ts +0 -145
  62. package/deploy/LICENSE +0 -9
  63. package/deploy/supabase.sql +0 -2271
  64. package/jest.config.js +0 -15
  65. package/revert/supabase.sql +0 -3
  66. package/sql/supabase--0.0.1.sql +0 -1368
  67. package/src/index.ts +0 -3
  68. package/supabase.control +0 -7
  69. package/verify/supabase.sql +0 -3
@@ -1,159 +0,0 @@
1
- import { getConnections, PgTestClient } from 'supabase-test';
2
-
3
- let pg: PgTestClient;
4
- let db: PgTestClient;
5
- let teardown: () => Promise<void>;
6
-
7
- let tableExists = false;
8
-
9
- beforeAll(async () => {
10
- ({ pg, db, teardown } = await getConnections());
11
-
12
- // verify realtime schema exists (optional schema)
13
- const realtimeSchemaExists = await pg.any(
14
- `SELECT EXISTS (
15
- SELECT FROM information_schema.schemata
16
- WHERE schema_name = 'realtime'
17
- ) as exists`
18
- );
19
-
20
- if (realtimeSchemaExists[0]?.exists === true) {
21
- // grant access to realtime schema for testing
22
- await pg.any(
23
- `GRANT USAGE ON SCHEMA realtime TO public;
24
- GRANT SELECT ON ALL TABLES IN SCHEMA realtime TO service_role;
25
- GRANT SELECT ON ALL TABLES IN SCHEMA realtime TO authenticated;
26
- GRANT SELECT ON ALL TABLES IN SCHEMA realtime TO anon;
27
- ALTER DEFAULT PRIVILEGES IN SCHEMA realtime GRANT SELECT ON TABLES TO service_role;
28
- ALTER DEFAULT PRIVILEGES IN SCHEMA realtime GRANT SELECT ON TABLES TO authenticated;
29
- ALTER DEFAULT PRIVILEGES IN SCHEMA realtime GRANT SELECT ON TABLES TO anon;`,
30
- []
31
- );
32
-
33
- // check if realtime.subscription table exists (using pg in beforeAll only)
34
- const exists = await pg.any(
35
- `SELECT EXISTS (
36
- SELECT FROM information_schema.tables
37
- WHERE table_schema = 'realtime' AND table_name = 'subscription'
38
- ) as exists`
39
- );
40
- tableExists = exists[0]?.exists === true;
41
- }
42
- });
43
-
44
- afterAll(async () => {
45
- await teardown();
46
- });
47
-
48
- beforeEach(async () => {
49
- await db.beforeEach();
50
- });
51
-
52
- afterEach(async () => {
53
- await db.afterEach();
54
- });
55
-
56
- describe('tutorial: realtime subscription table access', () => {
57
-
58
- it('should verify subscription table exists', async () => {
59
- db.setContext({ role: 'service_role' });
60
-
61
- // verify table exists in information schema
62
- const exists = await db.any(
63
- `SELECT EXISTS (
64
- SELECT FROM information_schema.tables
65
- WHERE table_schema = 'realtime' AND table_name = 'subscription'
66
- ) as exists`
67
- );
68
-
69
- expect(Array.isArray(exists)).toBe(true);
70
- if (exists[0]?.exists === false) {
71
- expect(exists[0].exists).toBe(false);
72
- return;
73
- }
74
- expect(exists[0].exists).toBe(true);
75
- });
76
-
77
- it('should verify service_role can query subscription', async () => {
78
- if (!tableExists) {
79
- return;
80
- }
81
-
82
- db.setContext({ role: 'service_role' });
83
-
84
- // service_role should be able to query subscription
85
- const subscriptions = await db.any(
86
- `SELECT id, entity, filters, created_at
87
- FROM realtime.subscription
88
- LIMIT 10`
89
- );
90
-
91
- expect(Array.isArray(subscriptions)).toBe(true);
92
- });
93
-
94
- it('should verify table structure via information_schema', async () => {
95
- if (!tableExists) {
96
- return;
97
- }
98
-
99
- db.setContext({ role: 'service_role' });
100
-
101
- // query table column structure
102
- const columns = await db.any(
103
- `SELECT column_name, data_type
104
- FROM information_schema.columns
105
- WHERE table_schema = 'realtime' AND table_name = 'subscription'
106
- ORDER BY ordinal_position`
107
- );
108
-
109
- expect(Array.isArray(columns)).toBe(true);
110
- });
111
-
112
- it('should prevent authenticated users from accessing subscription without proper permissions', async () => {
113
- if (!tableExists) {
114
- return;
115
- }
116
-
117
- // create a test user as admin using db with service_role context
118
- // using auth.users (real supabase table) instead of rls_test.user_profiles (fake test table)
119
- db.setContext({ role: 'service_role' });
120
- const user = await db.one(
121
- `INSERT INTO auth.users (id, email)
122
- VALUES (gen_random_uuid(), $1)
123
- RETURNING id`,
124
- ['realtime-subscription-test@example.com']
125
- );
126
-
127
- // set context to simulate authenticated user
128
- db.setContext({
129
- role: 'authenticated',
130
- 'request.jwt.claim.sub': user.id
131
- });
132
-
133
- // authenticated users should not be able to access subscription (rls blocks)
134
- const result = await db.any(
135
- `SELECT * FROM realtime.subscription LIMIT 1`
136
- );
137
-
138
- // rls should block access, result should be empty
139
- expect(result.length).toBe(0);
140
- });
141
-
142
- it('should prevent anon from accessing subscription', async () => {
143
- if (!tableExists) {
144
- return;
145
- }
146
-
147
- // clear context to anon role
148
- db.clearContext();
149
-
150
- // anon should not be able to access subscription (rls blocks)
151
- const result = await db.any(
152
- `SELECT * FROM realtime.subscription LIMIT 1`
153
- );
154
-
155
- // rls should block access, result should be empty
156
- expect(result.length).toBe(0);
157
- });
158
- });
159
-
@@ -1,134 +0,0 @@
1
- import { getConnections, PgTestClient } from 'supabase-test';
2
-
3
- let pg: PgTestClient;
4
- let db: PgTestClient;
5
- let teardown: () => Promise<void>;
6
- let testUserId: string | null = null;
7
-
8
- beforeAll(async () => {
9
- ({ pg, db, teardown } = await getConnections());
10
-
11
- // verify storage schema exists
12
- const storageSchemaExists = await pg.any(
13
- `SELECT EXISTS (
14
- SELECT FROM information_schema.schemata
15
- WHERE schema_name = 'storage'
16
- ) as exists`
17
- );
18
- expect(storageSchemaExists[0].exists).toBe(true);
19
-
20
- // grant access to storage schema for testing
21
- await pg.any(
22
- `GRANT USAGE ON SCHEMA storage TO public;
23
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO service_role;
24
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO authenticated;
25
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO anon;
26
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO service_role;
27
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO authenticated;
28
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO anon;`,
29
- []
30
- );
31
-
32
- // tests will assert table existence explicitly
33
-
34
- const u = await pg.one(
35
- `INSERT INTO auth.users (id, email)
36
- VALUES (gen_random_uuid(), $1)
37
- RETURNING id`,
38
- ['storage-analytics-test@example.com']
39
- );
40
- testUserId = u.id;
41
- });
42
-
43
- afterAll(async () => {
44
- await teardown();
45
- });
46
-
47
- beforeEach(async () => {
48
- await db.beforeEach();
49
- });
50
-
51
- afterEach(async () => {
52
- await db.afterEach();
53
- });
54
-
55
- describe('tutorial: storage buckets_analytics table access', () => {
56
-
57
- it('should verify buckets_analytics table exists', async () => {
58
- db.setContext({ role: 'service_role' });
59
-
60
- // verify table exists in information schema
61
- const exists = await db.any(
62
- `SELECT EXISTS (
63
- SELECT FROM information_schema.tables
64
- WHERE table_schema = 'storage' AND table_name = 'buckets_analytics'
65
- ) as exists`
66
- );
67
-
68
- expect(Array.isArray(exists)).toBe(true);
69
- expect(typeof exists[0].exists).toBe('boolean');
70
- });
71
-
72
- it('should verify service_role can query buckets_analytics', async () => {
73
- db.setContext({ role: 'service_role' });
74
-
75
- // service_role should be able to query buckets_analytics
76
- const analytics = await db.any(
77
- `SELECT id
78
- FROM storage.buckets_analytics
79
- LIMIT 10`
80
- );
81
-
82
- expect(Array.isArray(analytics)).toBe(true);
83
- });
84
-
85
- it('should verify table structure via information_schema', async () => {
86
- db.setContext({ role: 'service_role' });
87
-
88
- // query table column structure
89
- const columns = await db.any(
90
- `SELECT column_name, data_type
91
- FROM information_schema.columns
92
- WHERE table_schema = 'storage' AND table_name = 'buckets_analytics'
93
- ORDER BY ordinal_position`
94
- );
95
-
96
- expect(Array.isArray(columns)).toBe(true);
97
- });
98
-
99
- it('should verify authenticated access to buckets_analytics based on rls', async () => {
100
- db.setContext({ role: 'service_role' });
101
- const rlsStatus = await db.any(
102
- `SELECT c.relrowsecurity
103
- FROM pg_class c
104
- JOIN pg_namespace n ON n.oid = c.relnamespace
105
- WHERE n.nspname = 'storage' AND c.relname = 'buckets_analytics'`
106
- );
107
- expect(Array.isArray(rlsStatus)).toBe(true);
108
-
109
- db.setContext({ role: 'authenticated', 'request.jwt.claim.sub': testUserId });
110
- const result = await db.any(`SELECT * FROM storage.buckets_analytics LIMIT 1`);
111
- expect(Array.isArray(result)).toBe(true);
112
- if (rlsStatus[0]?.relrowsecurity === true) {
113
- expect(result.length).toBe(0);
114
- }
115
- });
116
-
117
- it('should verify anon access to buckets_analytics based on rls', async () => {
118
- db.setContext({ role: 'service_role' });
119
- const rlsStatus = await db.any(
120
- `SELECT c.relrowsecurity
121
- FROM pg_class c
122
- JOIN pg_namespace n ON n.oid = c.relnamespace
123
- WHERE n.nspname = 'storage' AND c.relname = 'buckets_analytics'`
124
- );
125
-
126
- db.clearContext();
127
- const result = await db.any(`SELECT * FROM storage.buckets_analytics LIMIT 1`);
128
- expect(Array.isArray(result)).toBe(true);
129
- if (rlsStatus[0]?.relrowsecurity === true) {
130
- expect(result.length).toBe(0);
131
- }
132
- });
133
- });
134
-
@@ -1,146 +0,0 @@
1
- import { getConnections, PgTestClient } from 'supabase-test';
2
-
3
- let pg: PgTestClient;
4
- let db: PgTestClient;
5
- let teardown: () => Promise<void>;
6
-
7
- beforeAll(async () => {
8
-
9
-
10
- ({ pg, db, teardown } = await getConnections());
11
-
12
- // verify storage schema exists
13
- const storageSchemaExists = await pg.any(
14
- `SELECT EXISTS (
15
- SELECT FROM information_schema.schemata
16
- WHERE schema_name = 'storage'
17
- ) as exists`
18
- );
19
- expect(storageSchemaExists[0].exists).toBe(true);
20
-
21
- // grant access to storage schema for testing
22
- await pg.any(
23
- `GRANT USAGE ON SCHEMA storage TO public;
24
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO service_role;
25
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO authenticated;
26
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO anon;
27
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO service_role;
28
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO authenticated;
29
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO anon;`,
30
- []
31
- );
32
-
33
- // assert storage.buckets exists
34
- const exists = await pg.any(
35
- `SELECT EXISTS (
36
- SELECT FROM information_schema.tables
37
- WHERE table_schema = 'storage' AND table_name = 'buckets'
38
- ) as exists`
39
- );
40
- expect(exists[0].exists).toBe(true);
41
- });
42
-
43
- afterAll(async () => {
44
- await teardown();
45
- });
46
-
47
- beforeEach(async () => {
48
- await db.beforeEach();
49
- });
50
-
51
- afterEach(async () => {
52
- await db.afterEach();
53
- });
54
-
55
- describe('tutorial: storage buckets table access', () => {
56
-
57
- it('should verify buckets table exists', async () => {
58
- db.setContext({ role: 'service_role' });
59
-
60
- const exists = await db.any(
61
- `SELECT EXISTS (
62
- SELECT FROM information_schema.tables
63
- WHERE table_schema = 'storage' AND table_name = 'buckets'
64
- ) as exists`
65
- );
66
-
67
- expect(Array.isArray(exists)).toBe(true);
68
- expect(exists[0].exists).toBe(true);
69
- });
70
-
71
- it('should verify service_role can read buckets', async () => {
72
- db.setContext({ role: 'service_role' });
73
-
74
- const buckets = await db.any(
75
- `SELECT id, name, owner, created_at, updated_at
76
- FROM storage.buckets
77
- LIMIT 10`
78
- );
79
-
80
- expect(Array.isArray(buckets)).toBe(true);
81
- });
82
-
83
- it('should verify table has primary key on id', async () => {
84
- db.setContext({ role: 'service_role' });
85
-
86
- const pk = await db.any(
87
- `SELECT constraint_name
88
- FROM information_schema.table_constraints
89
- WHERE table_schema = 'storage' AND table_name = 'buckets'
90
- AND constraint_type = 'PRIMARY KEY'`
91
- );
92
-
93
- expect(Array.isArray(pk)).toBe(true);
94
- if (pk.length > 0) {
95
- expect(pk[0].constraint_name).toBeDefined();
96
- }
97
- });
98
-
99
- it('should verify table has unique index on name', async () => {
100
- db.setContext({ role: 'service_role' });
101
-
102
- const indexes = await db.any(
103
- `SELECT indexname, indexdef
104
- FROM pg_indexes
105
- WHERE schemaname = 'storage' AND tablename = 'buckets'`
106
- );
107
-
108
- expect(Array.isArray(indexes)).toBe(true);
109
- if (indexes.length > 0) {
110
- const defs = indexes.map((r: any) => String(r.indexdef).toLowerCase()).join(' ');
111
- expect(defs.includes('unique')).toBe(true);
112
- expect(defs.includes('(name)')).toBe(true);
113
- }
114
- });
115
-
116
- it('should verify table has owner column for user linkage', async () => {
117
- db.setContext({ role: 'service_role' });
118
- const cols = await db.any(
119
- `SELECT column_name
120
- FROM information_schema.columns
121
- WHERE table_schema = 'storage' AND table_name = 'buckets'`
122
- );
123
- expect(Array.isArray(cols)).toBe(true);
124
- const names = cols.map((r: any) => r.column_name);
125
- expect(names).toContain('owner');
126
- });
127
-
128
- it('should verify anon access to buckets based on rls', async () => {
129
- db.setContext({ role: 'service_role' });
130
- const rlsStatus = await db.any(
131
- `SELECT c.relrowsecurity
132
- FROM pg_class c
133
- JOIN pg_namespace n ON n.oid = c.relnamespace
134
- WHERE n.nspname = 'storage' AND c.relname = 'buckets'`
135
- );
136
- expect(Array.isArray(rlsStatus)).toBe(true);
137
-
138
- db.clearContext();
139
- const result = await db.any(`SELECT * FROM storage.buckets LIMIT 1`);
140
- expect(Array.isArray(result)).toBe(true);
141
- if (rlsStatus[0]?.relrowsecurity === true) {
142
- expect(result.length).toBe(0);
143
- }
144
- });
145
- });
146
-
@@ -1,132 +0,0 @@
1
- import { getConnections, PgTestClient } from 'supabase-test';
2
-
3
- let pg: PgTestClient;
4
- let db: PgTestClient;
5
- let teardown: () => Promise<void>;
6
- let testUserId: string | null = null;
7
-
8
- beforeAll(async () => {
9
- ({ pg, db, teardown } = await getConnections());
10
-
11
- // verify storage schema exists
12
- const storageSchemaExists = await pg.any(
13
- `SELECT EXISTS (
14
- SELECT FROM information_schema.schemata
15
- WHERE schema_name = 'storage'
16
- ) as exists`
17
- );
18
- expect(storageSchemaExists[0].exists).toBe(true);
19
-
20
- // grant access to storage schema for testing
21
- await pg.any(
22
- `GRANT USAGE ON SCHEMA storage TO public;
23
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO service_role;
24
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO authenticated;
25
- GRANT SELECT ON ALL TABLES IN SCHEMA storage TO anon;
26
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO service_role;
27
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO authenticated;
28
- ALTER DEFAULT PRIVILEGES IN SCHEMA storage GRANT SELECT ON TABLES TO anon;`,
29
- []
30
- );
31
-
32
- const u = await pg.one(
33
- `INSERT INTO auth.users (id, email)
34
- VALUES (gen_random_uuid(), $1)
35
- RETURNING id`,
36
- ['storage-namespace-test@example.com']
37
- );
38
- testUserId = u.id;
39
- });
40
-
41
- afterAll(async () => {
42
- await teardown();
43
- });
44
-
45
- beforeEach(async () => {
46
- await db.beforeEach();
47
- });
48
-
49
- afterEach(async () => {
50
- await db.afterEach();
51
- });
52
-
53
- describe('tutorial: storage iceberg_namespaces table access', () => {
54
-
55
- it('should verify iceberg_namespaces table exists', async () => {
56
- db.setContext({ role: 'service_role' });
57
-
58
- // verify table exists in information schema
59
- const exists = await db.any(
60
- `SELECT EXISTS (
61
- SELECT FROM information_schema.tables
62
- WHERE table_schema = 'storage' AND table_name = 'iceberg_namespaces'
63
- ) as exists`
64
- );
65
-
66
- expect(Array.isArray(exists)).toBe(true);
67
- expect(exists[0].exists).toBe(true);
68
- });
69
-
70
- it('should verify service_role can query iceberg_namespaces', async () => {
71
- db.setContext({ role: 'service_role' });
72
-
73
- // service_role should be able to query iceberg_namespaces
74
- const namespaces = await db.any(
75
- `SELECT id, bucket_id, name, created_at, updated_at
76
- FROM storage.iceberg_namespaces
77
- LIMIT 10`
78
- );
79
-
80
- expect(Array.isArray(namespaces)).toBe(true);
81
- });
82
-
83
- it('should verify table has proper structure', async () => {
84
- db.setContext({ role: 'service_role' });
85
-
86
- // query table column structure
87
- const columns = await db.any(
88
- `SELECT column_name
89
- FROM information_schema.columns
90
- WHERE table_schema = 'storage' AND table_name = 'iceberg_namespaces'
91
- ORDER BY ordinal_position`
92
- );
93
-
94
- expect(Array.isArray(columns)).toBe(true);
95
- });
96
-
97
- it('should verify authenticated access to iceberg_namespaces based on rls', async () => {
98
- db.setContext({ role: 'service_role' });
99
- const rlsStatus = await db.any(
100
- `SELECT c.relrowsecurity
101
- FROM pg_class c
102
- JOIN pg_namespace n ON n.oid = c.relnamespace
103
- WHERE n.nspname = 'storage' AND c.relname = 'iceberg_namespaces'`
104
- );
105
- expect(Array.isArray(rlsStatus)).toBe(true);
106
-
107
- db.setContext({ role: 'authenticated', 'request.jwt.claim.sub': testUserId });
108
- const result = await db.any(`SELECT * FROM storage.iceberg_namespaces LIMIT 1`);
109
- expect(Array.isArray(result)).toBe(true);
110
- if (rlsStatus[0]?.relrowsecurity === true) {
111
- expect(result.length).toBe(0);
112
- }
113
- });
114
-
115
- it('should verify anon access to iceberg_namespaces based on rls', async () => {
116
- db.setContext({ role: 'service_role' });
117
- const rlsStatus = await db.any(
118
- `SELECT c.relrowsecurity
119
- FROM pg_class c
120
- JOIN pg_namespace n ON n.oid = c.relnamespace
121
- WHERE n.nspname = 'storage' AND c.relname = 'iceberg_namespaces'`
122
- );
123
-
124
- db.clearContext();
125
- const result = await db.any(`SELECT * FROM storage.iceberg_namespaces LIMIT 1`);
126
- expect(Array.isArray(result)).toBe(true);
127
- if (rlsStatus[0]?.relrowsecurity === true) {
128
- expect(result.length).toBe(0);
129
- }
130
- });
131
- });
132
-