Debian Codegraph @

mysql-test/suite/roles/set_role-recursive.test

raw
1 source include/not_embedded.inc;
2
3 #create a user with no privileges
4 create user test_user@localhost;
5 create role test_role1;
6 grant test_role1 to test_user@localhost;
7 create role test_role2;
8 grant test_role2 to test_role1;
9
10 --sorted_result
11 select user, host from mysql.user where user not like 'root';
12 --sorted_result
13 select * from mysql.roles_mapping where User like 'test_user';
14 --sorted_result
15 select * from mysql.roles_mapping where User like 'test_role1';
16 grant select on *.* to test_role2;
17 --sorted_result
18 select * from mysql.user where user like 'test_role1';
19 --sorted_result
20 select * from mysql.user where user like 'test_role2';
21
22 change_user 'test_user';
23
24 --error ER_TABLEACCESS_DENIED_ERROR
25 select * from mysql.roles_mapping;
26
27 --sorted_result
28 show grants;
29 select current_user(), current_role();
30 set role test_role1;
31 select current_user(), current_role();
32 --sorted_result
33 show grants;
34 select * from mysql.roles_mapping where Host='';
35
36 --sorted_result
37 show grants;
38 set role none;
39 select current_user(), current_role();
40 --sorted_result
41 show grants;
42 --error ER_TABLEACCESS_DENIED_ERROR
43 select * from mysql.roles_mapping;
44
45 --sorted_result
46 show grants;
47 --error ER_INVALID_ROLE
48 set role test_role2;
49 select current_user(), current_role();
50 --sorted_result
51 show grants;
52 --error ER_TABLEACCESS_DENIED_ERROR
53 select * from mysql.roles_mapping;
54
55 #Make sure that this still works after an ER_INVALID_ROLE error
56 --sorted_result
57 show grants;
58 set role test_role1;
59 select current_user(), current_role();
60 --sorted_result
61 show grants;
62 --sorted_result
63 select * from mysql.roles_mapping where Host='';
64
65 --sorted_result
66 show grants;
67 set role none;
68 select current_user(), current_role();
69 --sorted_result
70 show grants;
71 --error ER_TABLEACCESS_DENIED_ERROR
72 select * from mysql.roles_mapping;
73
74 change_user 'root';
75 delete from mysql.user where user='test_role1';
76 delete from mysql.user where user='test_role2';
77 delete from mysql.roles_mapping;
78 flush privileges;
79 drop user 'test_user'@'localhost';