Skip to content

Commit fdf2ff4

Browse files
committed
fixed integration test
1 parent f2427ee commit fdf2ff4

5 files changed

Lines changed: 59 additions & 5 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
BEGIN;
33

4-
DROP SCHEMA collections_public;
4+
DROP SCHEMA collections_public CASCADE;
55

66
COMMIT;

packages/security/default-roles/revert/roles/administrator/role.sql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
BEGIN;
44

5-
DROP ROLE administrator;
5+
DO $revert$
6+
BEGIN
7+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'administrator') THEN
8+
REVOKE anonymous FROM administrator;
9+
REVOKE authenticated FROM administrator;
10+
REASSIGN OWNED BY administrator TO CURRENT_USER;
11+
DROP OWNED BY administrator CASCADE;
12+
BEGIN
13+
DROP ROLE administrator;
14+
EXCEPTION
15+
WHEN dependent_objects_still_exist THEN
16+
RAISE NOTICE 'Skipping drop of administrator role because dependent objects remain elsewhere';
17+
END;
18+
END IF;
19+
END;
20+
$revert$;
621

722
COMMIT;

packages/security/default-roles/revert/roles/anonymous/role.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
BEGIN;
44

5-
DROP ROLE anonymous;
5+
DO $revert$
6+
BEGIN
7+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'anonymous') THEN
8+
REASSIGN OWNED BY anonymous TO CURRENT_USER;
9+
DROP OWNED BY anonymous CASCADE;
10+
BEGIN
11+
DROP ROLE anonymous;
12+
EXCEPTION
13+
WHEN dependent_objects_still_exist THEN
14+
RAISE NOTICE 'Skipping drop of anonymous role because dependent objects remain elsewhere';
15+
END;
16+
END IF;
17+
END;
18+
$revert$;
619

720
COMMIT;

packages/security/default-roles/revert/roles/authenticated/role.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
BEGIN;
44

5-
DROP ROLE authenticated;
5+
DO $revert$
6+
BEGIN
7+
IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'authenticated') THEN
8+
REASSIGN OWNED BY authenticated TO CURRENT_USER;
9+
DROP OWNED BY authenticated CASCADE;
10+
BEGIN
11+
DROP ROLE authenticated;
12+
EXCEPTION
13+
WHEN dependent_objects_still_exist THEN
14+
RAISE NOTICE 'Skipping drop of authenticated role because dependent objects remain elsewhere';
15+
END;
16+
END IF;
17+
END;
18+
$revert$;
619

720
COMMIT;

packages/utils/verify/deploy/procedures/verify_function.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,26 @@ CREATE FUNCTION verify_function (_name text, _user text DEFAULT NULL)
99
AS $$
1010
DECLARE
1111
check_user text;
12+
func_oid oid;
1213
BEGIN
1314
IF (_user IS NOT NULL) THEN
1415
check_user = _user;
1516
ELSE
1617
check_user = CURRENT_USER;
1718
END IF;
19+
IF position('(' IN _name) > 0 THEN
20+
func_oid = to_regprocedure(_name);
21+
IF func_oid IS NULL THEN
22+
RAISE EXCEPTION 'Nonexistent function --> %', _name
23+
USING HINT = 'Please check';
24+
END IF;
25+
IF has_function_privilege(check_user, func_oid, 'execute') THEN
26+
RETURN TRUE;
27+
ELSE
28+
RAISE EXCEPTION 'Nonexistent function --> %', _name
29+
USING HINT = 'Please check';
30+
END IF;
31+
END IF;
1832
IF EXISTS (
1933
SELECT
2034
has_function_privilege(check_user, p.oid, 'execute')
@@ -34,4 +48,3 @@ $$
3448
LANGUAGE 'plpgsql'
3549
IMMUTABLE;
3650
COMMIT;
37-

0 commit comments

Comments
 (0)