fix: is_allowed answers FALSE for a NULL user instead of failing on auth_cache
release / release (push) Canceled after 0s

This commit is contained in:
2026-11-06 13:43:59 +01:00
parent ca4dc379ab
commit f6eef6c4bb
7 changed files with 391 additions and 6 deletions
+29
View File
@@ -0,0 +1,29 @@
-- =============================================================================
-- NULL user Tests
-- =============================================================================
-- is_allowed() and is_allowed_nocache() answer FALSE for a NULL user id, as
-- rls_check() does, instead of failing on the auth_cache NOT NULL constraint.
--
-- Prerequisites: 00_setup.sql -> 17_is_allowed_equivalence.sql
-- =============================================================================
\echo ''
\echo '================================================================'
\echo '18 -- NULL USER'
\echo '================================================================'
SELECT morbac.t('is_allowed NULL user, org',
morbac.is_allowed(NULL, '10000000-0000-0000-0000-000000000001'::uuid, 'read', 'documents'),
FALSE);
SELECT morbac.t('is_allowed NULL user, no org',
morbac.is_allowed(NULL, NULL, 'read', 'documents'),
FALSE);
SELECT morbac.t('is_allowed_nocache NULL user, org',
morbac.is_allowed_nocache(NULL, '10000000-0000-0000-0000-000000000001'::uuid, 'read', 'documents'),
FALSE);
SELECT morbac.t('is_allowed NULL user writes nothing to auth_cache',
NOT EXISTS (SELECT 1 FROM morbac.auth_cache WHERE user_id IS NULL),
TRUE);