fix: correct RLS test fixtures — tree_structure NOT NULL, tree_tags schema, session-scoped set_config
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -92,22 +92,22 @@ async def seed_rls_test_data(admin_conn):
|
|||||||
# Insert one private tree per account with explicit author_id
|
# Insert one private tree per account with explicit author_id
|
||||||
await admin_conn.execute(f"""
|
await admin_conn.execute(f"""
|
||||||
INSERT INTO trees (
|
INSERT INTO trees (
|
||||||
id, name, account_id, author_id, is_active, is_default,
|
id, name, tree_structure, account_id, author_id, is_active, is_default,
|
||||||
is_public, visibility, tree_type, created_at, updated_at
|
is_public, visibility, tree_type, created_at, updated_at
|
||||||
) VALUES
|
) VALUES
|
||||||
(gen_random_uuid(), 'RLS Tree A', '{ACCOUNT_A_ID}', '{actual_user_a}',
|
(gen_random_uuid(), 'RLS Tree A', '[]'::jsonb, '{ACCOUNT_A_ID}', '{actual_user_a}',
|
||||||
TRUE, FALSE, FALSE, 'private', 'troubleshooting', NOW(), NOW()),
|
TRUE, FALSE, FALSE, 'private', 'troubleshooting', NOW(), NOW()),
|
||||||
(gen_random_uuid(), 'RLS Tree B', '{ACCOUNT_B_ID}', '{actual_user_b}',
|
(gen_random_uuid(), 'RLS Tree B', '[]'::jsonb, '{ACCOUNT_B_ID}', '{actual_user_b}',
|
||||||
TRUE, FALSE, FALSE, 'private', 'troubleshooting', NOW(), NOW())
|
TRUE, FALSE, FALSE, 'private', 'troubleshooting', NOW(), NOW())
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# One platform-owned tree_tag (global, visible to all tenants)
|
# One platform-owned tree_tag (global, visible to all tenants)
|
||||||
await admin_conn.execute(f"""
|
await admin_conn.execute(f"""
|
||||||
INSERT INTO tree_tags (
|
INSERT INTO tree_tags (
|
||||||
id, name, slug, account_id, usage_count, created_at, updated_at
|
id, name, slug, account_id, usage_count, created_at
|
||||||
) VALUES (
|
) VALUES (
|
||||||
gen_random_uuid(), 'rls-global-tag', 'rls-global-tag',
|
gen_random_uuid(), 'rls-global-tag', 'rls-global-tag',
|
||||||
'{PLATFORM_ACCOUNT_ID}', 0, NOW(), NOW()
|
'{PLATFORM_ACCOUNT_ID}', 0, NOW()
|
||||||
) ON CONFLICT DO NOTHING
|
) ON CONFLICT DO NOTHING
|
||||||
""")
|
""")
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ async def conn_a():
|
|||||||
user="resolutionflow_app", password=_APP_PASSWORD,
|
user="resolutionflow_app", password=_APP_PASSWORD,
|
||||||
)
|
)
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
"SELECT set_config('app.current_account_id', $1, true)", ACCOUNT_A_ID
|
"SELECT set_config('app.current_account_id', $1, false)", ACCOUNT_A_ID
|
||||||
)
|
)
|
||||||
yield conn
|
yield conn
|
||||||
await conn.close()
|
await conn.close()
|
||||||
@@ -149,7 +149,7 @@ async def conn_b():
|
|||||||
user="resolutionflow_app", password=_APP_PASSWORD,
|
user="resolutionflow_app", password=_APP_PASSWORD,
|
||||||
)
|
)
|
||||||
await conn.execute(
|
await conn.execute(
|
||||||
"SELECT set_config('app.current_account_id', $1, true)", ACCOUNT_B_ID
|
"SELECT set_config('app.current_account_id', $1, false)", ACCOUNT_B_ID
|
||||||
)
|
)
|
||||||
yield conn
|
yield conn
|
||||||
await conn.close()
|
await conn.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user