Skip to content

Commit eaea991

Browse files
kelvichtristan957
authored andcommitted
Fix regression tests after the patch with CREATEROLE restrictions
1 parent 0cfe0df commit eaea991

File tree

2 files changed

+52
-8
lines changed

2 files changed

+52
-8
lines changed

src/test/regress/expected/create_role.out

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,31 @@ CREATE ROLE regress_noiseword SYSID 12345;
2424
NOTICE: SYSID can no longer be specified
2525
-- fail, cannot grant membership in superuser role
2626
CREATE ROLE regress_nosuch_super IN ROLE regress_role_super;
27-
ERROR: must be superuser to alter superusers
27+
ERROR: permission denied to grant role "regress_role_super"
28+
DETAIL: Only roles with the SUPERUSER attribute may grant roles with the SUPERUSER attribute.
2829
-- fail, database owner cannot have members
2930
CREATE ROLE regress_nosuch_dbowner IN ROLE pg_database_owner;
3031
ERROR: role "pg_database_owner" cannot have explicit members
3132
-- ok, can grant other users into a role
3233
CREATE ROLE regress_inroles ROLE
3334
regress_role_super, regress_createdb, regress_createrole, regress_login,
3435
regress_inherit, regress_connection_limit, regress_encrypted_password, regress_password_null;
36+
ERROR: permission denied to grant role "regress_inroles"
37+
DETAIL: Only roles with the ADMIN option on role "regress_inroles" may grant this role.
3538
-- fail, cannot grant a role into itself
3639
CREATE ROLE regress_nosuch_recursive ROLE regress_nosuch_recursive;
37-
ERROR: role "regress_nosuch_recursive" is a member of role "regress_nosuch_recursive"
40+
ERROR: permission denied to grant role "regress_nosuch_recursive"
41+
DETAIL: Only roles with the ADMIN option on role "regress_nosuch_recursive" may grant this role.
3842
-- ok, can grant other users into a role with admin option
3943
CREATE ROLE regress_adminroles ADMIN
4044
regress_role_super, regress_createdb, regress_createrole, regress_login,
4145
regress_inherit, regress_connection_limit, regress_encrypted_password, regress_password_null;
46+
ERROR: permission denied to grant role "regress_adminroles"
47+
DETAIL: Only roles with the ADMIN option on role "regress_adminroles" may grant this role.
4248
-- fail, cannot grant a role into itself with admin option
4349
CREATE ROLE regress_nosuch_admin_recursive ADMIN regress_nosuch_admin_recursive;
44-
ERROR: role "regress_nosuch_admin_recursive" is a member of role "regress_nosuch_admin_recursive"
50+
ERROR: permission denied to grant role "regress_nosuch_admin_recursive"
51+
DETAIL: Only roles with the ADMIN option on role "regress_nosuch_admin_recursive" may grant this role.
4552
-- fail, regress_createrole does not have CREATEDB privilege
4653
SET SESSION AUTHORIZATION regress_createrole;
4754
CREATE DATABASE regress_nosuch_db;
@@ -75,15 +82,35 @@ REASSIGN OWNED BY regress_tenant TO regress_createrole;
7582
ERROR: permission denied to reassign objects
7683
-- ok, having CREATEROLE is enough to create roles in privileged roles
7784
CREATE ROLE regress_read_all_data IN ROLE pg_read_all_data;
85+
ERROR: permission denied to grant role "pg_read_all_data"
86+
DETAIL: Only roles with the ADMIN option on role "pg_read_all_data" may grant this role.
7887
CREATE ROLE regress_write_all_data IN ROLE pg_write_all_data;
88+
ERROR: permission denied to grant role "pg_write_all_data"
89+
DETAIL: Only roles with the ADMIN option on role "pg_write_all_data" may grant this role.
7990
CREATE ROLE regress_monitor IN ROLE pg_monitor;
91+
ERROR: permission denied to grant role "pg_monitor"
92+
DETAIL: Only roles with the ADMIN option on role "pg_monitor" may grant this role.
8093
CREATE ROLE regress_read_all_settings IN ROLE pg_read_all_settings;
94+
ERROR: permission denied to grant role "pg_read_all_settings"
95+
DETAIL: Only roles with the ADMIN option on role "pg_read_all_settings" may grant this role.
8196
CREATE ROLE regress_read_all_stats IN ROLE pg_read_all_stats;
97+
ERROR: permission denied to grant role "pg_read_all_stats"
98+
DETAIL: Only roles with the ADMIN option on role "pg_read_all_stats" may grant this role.
8299
CREATE ROLE regress_stat_scan_tables IN ROLE pg_stat_scan_tables;
100+
ERROR: permission denied to grant role "pg_stat_scan_tables"
101+
DETAIL: Only roles with the ADMIN option on role "pg_stat_scan_tables" may grant this role.
83102
CREATE ROLE regress_read_server_files IN ROLE pg_read_server_files;
103+
ERROR: permission denied to grant role "pg_read_server_files"
104+
DETAIL: Only roles with the ADMIN option on role "pg_read_server_files" may grant this role.
84105
CREATE ROLE regress_write_server_files IN ROLE pg_write_server_files;
106+
ERROR: permission denied to grant role "pg_write_server_files"
107+
DETAIL: Only roles with the ADMIN option on role "pg_write_server_files" may grant this role.
85108
CREATE ROLE regress_execute_server_program IN ROLE pg_execute_server_program;
109+
ERROR: permission denied to grant role "pg_execute_server_program"
110+
DETAIL: Only roles with the ADMIN option on role "pg_execute_server_program" may grant this role.
86111
CREATE ROLE regress_signal_backend IN ROLE pg_signal_backend;
112+
ERROR: permission denied to grant role "pg_signal_backend"
113+
DETAIL: Only roles with the ADMIN option on role "pg_signal_backend" may grant this role.
87114
-- fail, creation of these roles failed above so they do not now exist
88115
SET SESSION AUTHORIZATION regress_role_admin;
89116
DROP ROLE regress_nosuch_superuser;
@@ -113,18 +140,30 @@ DROP ROLE regress_encrypted_password;
113140
DROP ROLE regress_password_null;
114141
DROP ROLE regress_noiseword;
115142
DROP ROLE regress_inroles;
143+
ERROR: role "regress_inroles" does not exist
116144
DROP ROLE regress_adminroles;
145+
ERROR: role "regress_adminroles" does not exist
117146
DROP ROLE regress_rolecreator;
118147
DROP ROLE regress_read_all_data;
148+
ERROR: role "regress_read_all_data" does not exist
119149
DROP ROLE regress_write_all_data;
150+
ERROR: role "regress_write_all_data" does not exist
120151
DROP ROLE regress_monitor;
152+
ERROR: role "regress_monitor" does not exist
121153
DROP ROLE regress_read_all_settings;
154+
ERROR: role "regress_read_all_settings" does not exist
122155
DROP ROLE regress_read_all_stats;
156+
ERROR: role "regress_read_all_stats" does not exist
123157
DROP ROLE regress_stat_scan_tables;
158+
ERROR: role "regress_stat_scan_tables" does not exist
124159
DROP ROLE regress_read_server_files;
160+
ERROR: role "regress_read_server_files" does not exist
125161
DROP ROLE regress_write_server_files;
162+
ERROR: role "regress_write_server_files" does not exist
126163
DROP ROLE regress_execute_server_program;
164+
ERROR: role "regress_execute_server_program" does not exist
127165
DROP ROLE regress_signal_backend;
166+
ERROR: role "regress_signal_backend" does not exist
128167
-- fail, role still owns database objects
129168
DROP ROLE regress_tenant;
130169
ERROR: role "regress_tenant" cannot be dropped because some objects depend on it

src/test/regress/expected/privileges.out

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,8 @@ REFRESH MATERIALIZED VIEW sro_mv;
16791679
ERROR: cannot fire deferred trigger within security-restricted operation
16801680
CONTEXT: SQL function "mv_action" statement 1
16811681
BEGIN; SET CONSTRAINTS ALL IMMEDIATE; REFRESH MATERIALIZED VIEW sro_mv; COMMIT;
1682-
ERROR: must have admin option on role "regress_priv_group2"
1682+
ERROR: permission denied to grant role "regress_priv_group2"
1683+
DETAIL: Only roles with the ADMIN option on role "regress_priv_group2" may grant this role.
16831684
CONTEXT: SQL function "unwanted_grant" statement 1
16841685
SQL statement "SELECT unwanted_grant()"
16851686
PL/pgSQL function sro_trojan() line 1 at PERFORM
@@ -1709,10 +1710,12 @@ CREATE FUNCTION dogrant_ok() RETURNS void LANGUAGE sql SECURITY DEFINER AS
17091710
GRANT regress_priv_group2 TO regress_priv_user5; -- ok: had ADMIN OPTION
17101711
SET ROLE regress_priv_group2;
17111712
GRANT regress_priv_group2 TO regress_priv_user5; -- fails: SET ROLE suspended privilege
1712-
ERROR: must have admin option on role "regress_priv_group2"
1713+
ERROR: permission denied to grant role "regress_priv_group2"
1714+
DETAIL: Only roles with the ADMIN option on role "regress_priv_group2" may grant this role.
17131715
SET SESSION AUTHORIZATION regress_priv_user1;
17141716
GRANT regress_priv_group2 TO regress_priv_user5; -- fails: no ADMIN OPTION
1715-
ERROR: must have admin option on role "regress_priv_group2"
1717+
ERROR: permission denied to grant role "regress_priv_group2"
1718+
DETAIL: Only roles with the ADMIN option on role "regress_priv_group2" may grant this role.
17161719
SELECT dogrant_ok(); -- ok: SECURITY DEFINER conveys ADMIN
17171720
NOTICE: role "regress_priv_user5" is already a member of role "regress_priv_group2"
17181721
dogrant_ok
@@ -1722,10 +1725,12 @@ NOTICE: role "regress_priv_user5" is already a member of role "regress_priv_gro
17221725

17231726
SET ROLE regress_priv_group2;
17241727
GRANT regress_priv_group2 TO regress_priv_user5; -- fails: SET ROLE did not help
1725-
ERROR: must have admin option on role "regress_priv_group2"
1728+
ERROR: permission denied to grant role "regress_priv_group2"
1729+
DETAIL: Only roles with the ADMIN option on role "regress_priv_group2" may grant this role.
17261730
SET SESSION AUTHORIZATION regress_priv_group2;
17271731
GRANT regress_priv_group2 TO regress_priv_user5; -- fails: no self-admin
1728-
ERROR: must have admin option on role "regress_priv_group2"
1732+
ERROR: permission denied to grant role "regress_priv_group2"
1733+
DETAIL: Only roles with the ADMIN option on role "regress_priv_group2" may grant this role.
17291734
SET SESSION AUTHORIZATION regress_priv_user4;
17301735
DROP FUNCTION dogrant_ok();
17311736
REVOKE regress_priv_group2 FROM regress_priv_user5;

0 commit comments

Comments
 (0)