mariadb/mysql-test/suite/roles/none_public.test
Sergei Golubchik b4e7803a6f MDEV-5215 post-review fixes
* "public" should work in any letter case
* PUBLIC is not a valid definer
* granting to public should auto-create an entry in mysql.global_priv
* SHOW GRANTS should show privileges obtained via PUBLIC
* LEX_USER::is_public was often uninitialized
* comments, whitespaces, typos, etc
2022-11-01 22:20:02 +01:00

75 lines
1.7 KiB
Text

source include/not_embedded.inc;
create role role1;
--error ER_INVALID_ROLE
create role none;
--error ER_INVALID_ROLE
create role public;
--error ER_CANNOT_USER
drop role none;
--error ER_CANNOT_USER
drop role public;
--error ER_INVALID_ROLE
grant none to role1;
--error ER_INVALID_ROLE
grant role1 to none;
--error ER_INVALID_ROLE
grant select on *.* to none;
--error ER_INVALID_ROLE
grant public to role1;
grant role1 to public;
grant select on *.* to public;
--error ER_INVALID_ROLE
grant role1 to current_role;
--error ER_INVALID_ROLE
revoke none from role1;
--error ER_INVALID_ROLE
revoke role1 from none;
--error ER_INVALID_ROLE
revoke select on *.* from none;
--error ER_INVALID_ROLE
revoke public from role1;
revoke role1 from public;
revoke select on *.* from public;
--error ER_INVALID_ROLE
show grants for none;
show grants for public;
--error ER_INVALID_ROLE
create definer=none view test.v1 as select 1;
--error ER_INVALID_ROLE
create definer=public view test.v1 as select 1;
drop role role1;
create user foo@localhost;
connect foo,localhost,foo;
--error ER_INVALID_ROLE
set default role public;
disconnect foo;
connection default;
update mysql.global_priv set priv=json_insert(priv, '$.default_role', 'none') where user='foo';
connect foo,localhost,foo;
show grants;
select * from information_schema.enabled_roles;
disconnect foo;
connection default;
update mysql.global_priv set priv=json_insert(priv, '$.default_role', 'public') where user='foo';
connect foo,localhost,foo;
show grants;
select * from information_schema.enabled_roles;
disconnect foo;
connection default;
drop user foo@localhost;
insert mysql.global_priv values ('', 'none', '{"is_role":true}');
flush privileges;
delete from mysql.global_priv where host='';