| 1 |
include/save_binlog_position.inc |
| 2 |
# ---------------------------------------------------------------------- |
| 3 |
# Begin : Tests for GRANT : Routine grants |
| 4 |
CREATE USER userX, userY, userZ; |
| 5 |
CREATE DATABASE db1; |
| 6 |
CREATE PROCEDURE db1.proc1() |
| 7 |
BEGIN |
| 8 |
SELECT 1234; |
| 9 |
END || |
| 10 |
include/save_binlog_position.inc |
| 11 |
# Case 1 : Valid grants |
| 12 |
GRANT EXECUTE ON PROCEDURE db1.proc1 TO userX, userY, userZ; |
| 13 |
# Must show new grant |
| 14 |
SHOW GRANTS FOR userX; |
| 15 |
Grants for userX@% |
| 16 |
GRANT USAGE ON *.* TO `userX`@`%` |
| 17 |
GRANT EXECUTE ON PROCEDURE `db1`.`proc1` TO `userX`@`%` |
| 18 |
SHOW GRANTS FOR userY; |
| 19 |
Grants for userY@% |
| 20 |
GRANT USAGE ON *.* TO `userY`@`%` |
| 21 |
GRANT EXECUTE ON PROCEDURE `db1`.`proc1` TO `userY`@`%` |
| 22 |
SHOW GRANTS FOR userZ; |
| 23 |
Grants for userZ@% |
| 24 |
GRANT USAGE ON *.* TO `userZ`@`%` |
| 25 |
GRANT EXECUTE ON PROCEDURE `db1`.`proc1` TO `userZ`@`%` |
| 26 |
# This event sequence pattern MUST be present in binlog: !Q(GRANT EXECUTE ON PROCEDURE.*db1.*proc1.*TO.*userX.*userY.*userZ.*) |
| 27 |
include/assert_binlog_events.inc |
| 28 |
include/save_binlog_position.inc |
| 29 |
# Case 6 : Create new user with an account without CREATE USER privilege |
| 30 |
CREATE USER userA, userB; |
| 31 |
GRANT EXECUTE ON PROCEDURE db1.proc1 to userX WITH GRANT OPTION; |
| 32 |
SHOW GRANTS FOR userY; |
| 33 |
Grants for userY@% |
| 34 |
GRANT USAGE ON *.* TO `userY`@`%` |
| 35 |
GRANT EXECUTE ON PROCEDURE `db1`.`proc1` TO `userY`@`%` |
| 36 |
SHOW GRANTS FOR userZ; |
| 37 |
Grants for userZ@% |
| 38 |
GRANT USAGE ON *.* TO `userZ`@`%` |
| 39 |
GRANT EXECUTE ON PROCEDURE `db1`.`proc1` TO `userZ`@`%` |
| 40 |
SHOW GRANTS FOR userA; |
| 41 |
Grants for userA@% |
| 42 |
GRANT USAGE ON *.* TO `userA`@`%` |
| 43 |
SHOW GRANTS FOR userB; |
| 44 |
Grants for userB@% |
| 45 |
GRANT USAGE ON *.* TO `userB`@`%` |
| 46 |
include/save_binlog_position.inc |
| 47 |
# should succeed |
| 48 |
GRANT EXECUTE ON PROCEDURE db1.proc1 TO userY, userZ; |
| 49 |
# should fail |
| 50 |
GRANT EXECUTE ON PROCEDURE db1.proc1 TO userA, userB, userC; |
| 51 |
ERROR 42000: You are not allowed to create a user with GRANT |
| 52 |
# Must show updated grants |
| 53 |
SHOW GRANTS FOR userY; |
| 54 |
Grants for userY@% |
| 55 |
GRANT USAGE ON *.* TO `userY`@`%` |
| 56 |
GRANT EXECUTE ON PROCEDURE `db1`.`proc1` TO `userY`@`%` |
| 57 |
SHOW GRANTS FOR userZ; |
| 58 |
Grants for userZ@% |
| 59 |
GRANT USAGE ON *.* TO `userZ`@`%` |
| 60 |
GRANT EXECUTE ON PROCEDURE `db1`.`proc1` TO `userZ`@`%` |
| 61 |
# Must not have any change |
| 62 |
SHOW GRANTS FOR userA; |
| 63 |
Grants for userA@% |
| 64 |
GRANT USAGE ON *.* TO `userA`@`%` |
| 65 |
SHOW GRANTS FOR userB; |
| 66 |
Grants for userB@% |
| 67 |
GRANT USAGE ON *.* TO `userB`@`%` |
| 68 |
# This event sequence pattern MUST be present in binlog: !Q(GRANT EXECUTE ON PROCEDURE.*db1.*proc1.*TO.*userY.*userZ.*) |
| 69 |
include/assert_binlog_events.inc |
| 70 |
DROP USER userX, userY, userZ, userA, userB; |
| 71 |
DROP PROCEDURE db1.proc1; |
| 72 |
DROP DATABASE db1; |
| 73 |
include/save_binlog_position.inc |
| 74 |
# End : Tests for GRANT : Routine grants |
| 75 |
# ---------------------------------------------------------------------- |