docs: complete function reference, drop unicode punctuation
Documents refresh_hierarchy_cache, is_rule_valid and org_in_scope, and corrects the get_org_scope scope list which still omitted unattributed and all. Replaces em dashes and other typographic unicode with ASCII throughout the schema comments, the test suite and the documentation. Comments and prose are ASCII only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+10
-10
@@ -37,7 +37,7 @@
|
||||
\echo '================================================================'
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
-- Section 1: No user_id set — always FALSE
|
||||
-- Section 1: No user_id set - always FALSE
|
||||
-- ---------------------------------------------------------------------------
|
||||
\echo ''
|
||||
\echo '--- 1. No user_id: always FALSE ---'
|
||||
@@ -64,19 +64,19 @@ SELECT morbac.t('rls_check without user_id, global row',
|
||||
SET morbac.user_id = '30000000-0000-0000-0000-000000000011'; -- Karl
|
||||
SET morbac.org_id = '10000000-0000-0000-0000-000000000001'; -- GlobalTech HQ
|
||||
|
||||
-- 2a: org-scoped row, matching org — Karl has user_rule for read documents
|
||||
-- 2a: org-scoped row, matching org - Karl has user_rule for read documents
|
||||
SELECT morbac.t('rls_check single org, org row matches session org (Karl/documents)',
|
||||
morbac.rls_check('read', 'documents',
|
||||
'10000000-0000-0000-0000-000000000001'::uuid),
|
||||
TRUE);
|
||||
|
||||
-- 2b: org-scoped row, different org — blocked before is_allowed
|
||||
-- 2b: org-scoped row, different org - blocked before is_allowed
|
||||
SELECT morbac.t('rls_check single org, org row from different org (blocked)',
|
||||
morbac.rls_check('read', 'documents',
|
||||
'10000000-0000-0000-0000-000000000002'::uuid),
|
||||
FALSE);
|
||||
|
||||
-- 2c: NULL row — filtered out under a single org pin (orphan not requested)
|
||||
-- 2c: NULL row - filtered out under a single org pin (orphan not requested)
|
||||
SELECT morbac.t('rls_check single org, NULL row filtered out under org pin',
|
||||
morbac.rls_check('read', 'documents', NULL),
|
||||
FALSE);
|
||||
@@ -98,19 +98,19 @@ RESET morbac.org_id;
|
||||
SET morbac.user_id = '30000000-0000-0000-0000-000000000011'; -- Karl
|
||||
SET morbac.org_ids = '["10000000-0000-0000-0000-000000000001"]'; -- [GlobalTech HQ]
|
||||
|
||||
-- 3a: org-scoped row in the list — Karl has user_rule for read documents in GlobalTech
|
||||
-- 3a: org-scoped row in the list - Karl has user_rule for read documents in GlobalTech
|
||||
SELECT morbac.t('rls_check org_ids, org row in list (Karl/documents/GlobalTech)',
|
||||
morbac.rls_check('read', 'documents',
|
||||
'10000000-0000-0000-0000-000000000001'::uuid),
|
||||
TRUE);
|
||||
|
||||
-- 3b: org-scoped row not in the list — blocked
|
||||
-- 3b: org-scoped row not in the list - blocked
|
||||
SELECT morbac.t('rls_check org_ids, org row not in list (blocked)',
|
||||
morbac.rls_check('read', 'documents',
|
||||
'10000000-0000-0000-0000-000000000002'::uuid),
|
||||
FALSE);
|
||||
|
||||
-- 3c: NULL row, list WITHOUT null marker — filtered out even with a global grant
|
||||
-- 3c: NULL row, list WITHOUT null marker - filtered out even with a global grant
|
||||
INSERT INTO morbac.global_rules (user_id, activity, view, context_id, modality)
|
||||
VALUES (
|
||||
'30000000-0000-0000-0000-000000000011', -- Karl
|
||||
@@ -123,7 +123,7 @@ SELECT morbac.t('rls_check org_ids without null marker, NULL row filtered out de
|
||||
morbac.rls_check('read', 'contracts', NULL),
|
||||
FALSE);
|
||||
|
||||
-- 3c2: NULL row, list WITH null marker + global permission — allowed
|
||||
-- 3c2: NULL row, list WITH null marker + global permission - allowed
|
||||
SET morbac.org_ids = '["10000000-0000-0000-0000-000000000001", null]';
|
||||
|
||||
SELECT morbac.t('rls_check org_ids with null marker, NULL row + global permission',
|
||||
@@ -167,7 +167,7 @@ RESET morbac.org_ids;
|
||||
|
||||
SET morbac.user_id = '30000000-0000-0000-0000-000000000011'; -- Karl
|
||||
|
||||
-- 4a: org-scoped row — uses row's org_id (Karl has user_rule in GlobalTech)
|
||||
-- 4a: org-scoped row - uses row's org_id (Karl has user_rule in GlobalTech)
|
||||
SELECT morbac.t('rls_check no org context, org row: uses row org (Karl/documents/GlobalTech)',
|
||||
morbac.rls_check('read', 'documents',
|
||||
'10000000-0000-0000-0000-000000000001'::uuid),
|
||||
@@ -179,7 +179,7 @@ SELECT morbac.t('rls_check no org context, org row: no permission in row org (En
|
||||
'10000000-0000-0000-0000-000000000002'::uuid),
|
||||
FALSE);
|
||||
|
||||
-- 4b: global row + global permission — now goes to is_allowed(Karl, NULL, ...) → global_rules only
|
||||
-- 4b: NULL row + global permission - is_allowed(Karl, NULL, ...) sees unattributed + global rules
|
||||
INSERT INTO morbac.global_rules (user_id, activity, view, context_id, modality)
|
||||
VALUES (
|
||||
'30000000-0000-0000-0000-000000000011', -- Karl
|
||||
|
||||
Reference in New Issue
Block a user