Debian Codegraph @

mysql-test/suite/roles/set_role-9614.result

raw
1 #
2 # MDEV-9614 Roles and Users Longer than 6 characters
3 #
4 # This test case checks the edge case presented in the MDEV. The
5 # real issue is actually apparent when the username is longer than the
6 # rolename.
7 #
8 # We need a separate database not including test or test_% names. Due to
9 # default privileges given on these databases.
10 #
11 DROP DATABASE IF EXISTS `bug_db`;
12 Warnings:
13 Note 1008 Can't drop database 'bug_db'; database doesn't exist
14 #
15 # The first user did not show the bug as john's length is smaller
16 # than client. The bug is apparent most of the time for usertestjohn.
17 #
18 CREATE USER `john`@`%`;
19 CREATE USER `usertestjohn`@`%`;
20 CREATE ROLE `client`;
21 #
22 # Setup the required tables.
23 #
24 CREATE DATABASE `bug_db`;
25 CREATE TABLE `bug_db`.`t0`(`c0` INT);
26 #
27 # Setup select privileges only on the role. Setting the role should give
28 # select access to bug_db.t0.
29 #
30 GRANT SELECT ON `bug_db`.`t0` TO `client`;
31 GRANT `client` TO `john`@`%`;
32 GRANT `client` TO `usertestjohn`@`%`;
33 #
34 # Check to see grants are set.
35 #
36 SHOW GRANTS FOR `john`@`%`;
37 Grants for john@%
38 GRANT `client` TO `john`@`%`
39 GRANT USAGE ON *.* TO `john`@`%`
40 SHOW GRANTS FOR `usertestjohn`@`%`;
41 Grants for usertestjohn@%
42 GRANT `client` TO `usertestjohn`@`%`
43 GRANT USAGE ON *.* TO `usertestjohn`@`%`
44 SHOW GRANTS FOR `client`;
45 Grants for client
46 GRANT USAGE ON *.* TO `client`
47 GRANT SELECT ON `bug_db`.`t0` TO `client`
48 show databases;
49 Database
50 bug_db
51 information_schema
52 mtr
53 mysql
54 performance_schema
55 sys
56 test
57 #
58 # Try using the database as john.
59 #
60 connect john, localhost, john,,information_schema;
61 show databases;
62 Database
63 information_schema
64 set role client;
65 show databases;
66 Database
67 bug_db
68 information_schema
69 use bug_db;
70 #
71 # Try using the database as usertestjohn.
72 #
73 connect usertestjohn, localhost, usertestjohn,,information_schema;
74 show databases;
75 Database
76 information_schema
77 set role client;
78 show databases;
79 Database
80 bug_db
81 information_schema
82 show grants;
83 Grants for usertestjohn@%
84 GRANT `client` TO `usertestjohn`@`%`
85 GRANT USAGE ON *.* TO `usertestjohn`@`%`
86 GRANT USAGE ON *.* TO `client`
87 GRANT SELECT ON `bug_db`.`t0` TO `client`
88 use bug_db;
89 #
90 # Cleanup
91 #
92 connection default;
93 drop user john;
94 drop user usertestjohn;
95 drop role client;
96 drop database bug_db;