Debian Codegraph @

mysql-test/suite/information_schema/t/enabled_roles.test

raw
1 # This file tests INFORMATION_SCHEMA.ENABLED_ROLES.
2
3 --echo # SETUP SCHEMA
4 --source suite/information_schema/include/roles_schema.inc
5
6 --let $TEST_TABLE=ENABLED_ROLES
7
8 --echo # USER WITH ROLES.
9
10 --echo #
11 --echo # Case 1: Login as user1
12 --echo #
13 --let USER_NAME=user1
14 --let ROLE_LIST=hr_rules
15 --source suite/information_schema/include/roles_i_s_test.inc
16
17 --echo #
18 --echo # Case 2: Login as user2
19 --echo #
20 --let USER_NAME=user2
21 --let ROLE_LIST=hr_rules
22 --source suite/information_schema/include/roles_i_s_test.inc
23
24 --echo #
25 --echo # Case 3: Login as lead_user1 with mandatory roles.
26 --echo #
27 SET GLOBAL mandatory_roles = 'hr_access';
28 --let USER_NAME=lead_user1
29 --let ROLE_LIST=hr_access
30 --source suite/information_schema/include/roles_i_s_test.inc
31
32 SET GLOBAL activate_all_roles_on_login=on;
33 --let USER_NAME=lead_user1
34 --let ROLE_LIST=hr_access
35 --source suite/information_schema/include/roles_i_s_test.inc
36 SET GLOBAL activate_all_roles_on_login=off;
37
38 --echo # Set 'task2' as mandatory which is not directly granted to lead_user1
39 --echo # and then use SET ROLE ALL
40 SET GLOBAL mandatory_roles = 'task2';
41 --let ROLE_LIST=task2
42 --let ROLE_LIST=ALL
43 --source suite/information_schema/include/roles_i_s_test.inc
44
45 --echo # Set 'task2' as mandatory which is not directly granted to lead_user1
46 --echo # and then use SET ROLE ALL EXCEPT 'task2'
47 SET GLOBAL mandatory_roles = 'task2';
48 --let ROLE_LIST=task2
49 --let ROLE_LIST=ALL EXCEPT task2
50 --source suite/information_schema/include/roles_i_s_test.inc
51
52 SET GLOBAL mandatory_roles = default;
53
54 --echo #
55 --echo # Case 4: Login as lead_user2 with default roles.
56 --echo #
57 SET DEFAULT ROLE hr_access TO lead_user2;
58 --let USER_NAME=lead_user2
59 --let ROLE_LIST=task2_lead
60 --source suite/information_schema/include/roles_i_s_test.inc
61 SET DEFAULT ROLE NONE TO lead_user1;
62
63 --echo # Set 'task2' as mandatory while CREATEing and ALTERing the user.
64 CREATE USER lead_user3 IDENTIFIED BY 'foo' DEFAULT ROLE task2;
65 GRANT SELECT ON test.* TO lead_user3;
66 GRANT task2 TO lead_user3;
67
68 --let USER_NAME=lead_user3
69 --let ROLE_LIST=NONE
70 --source suite/information_schema/include/roles_i_s_test.inc
71 ALTER USER lead_user3 DEFAULT ROLE NONE;
72 --source suite/information_schema/include/roles_i_s_test.inc
73 ALTER USER lead_user3 DEFAULT ROLE task2;
74 --source suite/information_schema/include/roles_i_s_test.inc
75 DROP USER lead_user3;
76
77 --echo #
78 --echo # Case 5: Login as project_lead_user with role graph.
79 --echo #
80 --let USER_NAME=project_lead_user
81 --let ROLE_LIST=hr_access
82 --source suite/information_schema/include/roles_i_s_test.inc
83
84 --echo #
85 --echo # Case 6: Login as project_lead_user with cyclic role graph.
86 --echo #
87 --echo # Form a role graph loop.
88 --echo #
89 --echo # reader
90 --echo # |
91 --echo # V
92 --echo # updater<------------\
93 --echo # | |
94 --echo # |``````````````| |
95 --echo # V V |
96 --echo # task1_lead task2_lead |
97 --echo # | | |
98 --echo # ````````|``````` |
99 --echo # V |
100 --echo # project_lead-----------/
101 --echo #
102 connection default;
103 # GRANT project_lead to updater;
104 INSERT INTO mysql.role_edges (FROM_USER,FROM_HOST,TO_USER,TO_HOST)
105 VALUES('project_lead','%','updater','%');
106 FLUSH PRIVILEGES;
107
108 --let USER_NAME=project_lead_user
109 --let ROLE_LIST=hr_access
110 --source suite/information_schema/include/roles_i_s_test.inc
111
112 REVOKE project_lead FROM updater;
113
114 --echo # Cleanup
115 --source suite/information_schema/include/roles_schema_clean.inc