2022-07-22 13:31:37 +02:00
|
|
|
-- ========================================================
|
|
|
|
-- Some Tests
|
|
|
|
-- --------------------------------------------------------
|
|
|
|
|
|
|
|
|
2022-08-31 09:42:40 +02:00
|
|
|
select isGranted(findRoleId('administrators'), findRoleId('test_package#aaa00.owner'));
|
|
|
|
select isGranted(findRoleId('test_package#aaa00.owner'), findRoleId('administrators'));
|
|
|
|
-- call grantRoleToRole(findRoleId('test_package#aaa00.owner'), findRoleId('administrators'));
|
|
|
|
-- call grantRoleToRole(findRoleId('administrators'), findRoleId('test_package#aaa00.owner'));
|
2022-07-22 13:31:37 +02:00
|
|
|
|
|
|
|
select count(*)
|
2022-09-14 09:56:22 +02:00
|
|
|
FROM queryAllPermissionsOfSubjectIdForObjectUuids(findRbacUser('superuser-fran@hostsharing.net'),
|
2022-07-22 13:31:37 +02:00
|
|
|
ARRAY(select uuid from customer where reference < 1100000));
|
|
|
|
select count(*)
|
2022-09-14 09:56:22 +02:00
|
|
|
FROM queryAllPermissionsOfSubjectId(findRbacUser('superuser-fran@hostsharing.net'));
|
2022-07-22 13:31:37 +02:00
|
|
|
select *
|
|
|
|
FROM queryAllPermissionsOfSubjectId(findRbacUser('alex@example.com'));
|
|
|
|
select *
|
|
|
|
FROM queryAllPermissionsOfSubjectId(findRbacUser('rosa@example.com'));
|
|
|
|
|
|
|
|
select *
|
2024-02-16 16:48:37 +01:00
|
|
|
FROM queryAllRbacUsersWithPermissionsFor(findEffectivePermissionId('customer',
|
2022-07-22 13:31:37 +02:00
|
|
|
(SELECT uuid FROM RbacObject WHERE objectTable = 'customer' LIMIT 1),
|
|
|
|
'add-package'));
|
|
|
|
select *
|
2024-02-16 16:48:37 +01:00
|
|
|
FROM queryAllRbacUsersWithPermissionsFor(findEffectivePermissionId('package',
|
2022-07-22 13:31:37 +02:00
|
|
|
(SELECT uuid FROM RbacObject WHERE objectTable = 'package' LIMIT 1),
|
2024-03-11 12:30:43 +01:00
|
|
|
'DELETE'));
|
2022-07-22 13:31:37 +02:00
|
|
|
|
|
|
|
DO LANGUAGE plpgsql
|
|
|
|
$$
|
|
|
|
DECLARE
|
|
|
|
userId uuid;
|
|
|
|
result bool;
|
|
|
|
BEGIN
|
2022-09-14 09:56:22 +02:00
|
|
|
userId = findRbacUser('superuser-alex@hostsharing.net');
|
2024-03-11 12:30:43 +01:00
|
|
|
result = (SELECT * FROM isPermissionGrantedToSubject(findPermissionId('package', 94928, 'add-package'), userId));
|
2022-07-22 13:31:37 +02:00
|
|
|
IF (result) THEN
|
|
|
|
RAISE EXCEPTION 'expected permission NOT to be granted, but it is';
|
|
|
|
end if;
|
|
|
|
|
2024-03-11 12:30:43 +01:00
|
|
|
result = (SELECT * FROM isPermissionGrantedToSubject(findPermissionId('package', 94928, 'SELECT'), userId));
|
2022-07-22 13:31:37 +02:00
|
|
|
IF (NOT result) THEN
|
|
|
|
RAISE EXCEPTION 'expected permission to be granted, but it is NOT';
|
|
|
|
end if;
|
|
|
|
|
|
|
|
RAISE LOG 'isPermissionGrantedToSubjectId test passed';
|
|
|
|
END;
|
|
|
|
$$;
|
|
|
|
|