mariadb/mysql-test/suite/roles/show_grants.test

91 lines
2.1 KiB
Text
Raw Normal View History

2013-10-18 18:56:28 -07:00
source include/not_embedded.inc;
2013-10-18 06:40:25 -07:00
#create a user with no privileges
create user test_user@localhost;
create role test_role1;
create role test_role2;
2013-10-18 06:40:25 -07:00
grant test_role1 to test_user@localhost;
grant test_role2 to test_user@localhost;
grant test_role2 to test_role1;
2013-10-18 06:40:25 -07:00
--sorted_result
select user, host from mysql.user where user not like 'root';
--sorted_result
select * from mysql.roles_mapping;
--sorted_result
select user, host from mysql.db;
grant select on mysql.* to test_role2;
2013-10-18 06:40:25 -07:00
flush privileges;
--sorted_result
select * from information_schema.applicable_roles;
2013-10-18 06:40:25 -07:00
change_user 'test_user';
--sorted_result
select * from information_schema.applicable_roles;
2013-10-18 06:40:25 -07:00
--sorted_result
show grants;
2013-10-18 06:55:26 -07:00
select current_user(), current_role();
2013-10-18 06:40:25 -07:00
set role test_role1;
--sorted_result
2013-10-18 09:15:46 -07:00
select * from information_schema.enabled_roles;
2013-10-18 06:55:26 -07:00
select current_user(), current_role();
2013-10-18 06:40:25 -07:00
--sorted_result
show grants;
set role none;
--sorted_result
2013-10-18 09:15:46 -07:00
select * from information_schema.enabled_roles;
2013-10-18 06:55:26 -07:00
select current_user(), current_role();
2013-10-18 06:40:25 -07:00
--sorted_result
show grants;
--sorted_result
2013-10-18 06:40:25 -07:00
show grants for test_user@localhost;
--error ER_DBACCESS_DENIED_ERROR
show grants for test_role1;
--error ER_DBACCESS_DENIED_ERROR
show grants for test_role2;
--sorted_result
show grants for CURRENT_USER;
--sorted_result
show grants for CURRENT_USER();
--error ER_NONEXISTING_GRANT
show grants for CURRENT_ROLE;
--error ER_NONEXISTING_GRANT
show grants for CURRENT_ROLE();
set role test_role2;
--sorted_result
2013-10-18 09:15:46 -07:00
select * from information_schema.enabled_roles;
2013-10-18 06:55:26 -07:00
select current_user(), current_role();
2013-10-18 06:40:25 -07:00
--sorted_result
show grants;
--sorted_result
show grants for test_user@localhost;
--sorted_result
show grants for test_role1;
--sorted_result
show grants for test_role2;
--sorted_result
show grants for CURRENT_USER;
--sorted_result
show grants for CURRENT_USER();
--sorted_result
show grants for CURRENT_ROLE;
--sorted_result
show grants for CURRENT_ROLE();
change_user 'root';
drop user 'test_user'@'localhost';
revoke select on mysql.* from test_role2;
drop role test_role1;
drop role test_role2;
delete from mysql.roles_mapping where Role='test_role1';
delete from mysql.roles_mapping where Role='test_role2';
2013-10-18 06:40:25 -07:00
flush privileges;