Commit 29753fb9 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

MDEV-9443: Add reexecution test cases.

parent 287f2d29
...@@ -20,12 +20,17 @@ Grants for root@localhost ...@@ -20,12 +20,17 @@ Grants for root@localhost
GRANT developers TO 'root'@'localhost' WITH ADMIN OPTION GRANT developers TO 'root'@'localhost' WITH ADMIN OPTION
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
# Test reexecution.
EXECUTE stmtCreateRole;
ERROR HY000: Operation CREATE ROLE failed for 'developers'
# #
# Now grant the role to the test user. # Now grant the role to the test user.
# #
SET @grantRole = 'GRANT developers to test_user'; SET @grantRole = 'GRANT developers to test_user';
PREPARE stmtGrantRole FROM @grantRole; PREPARE stmtGrantRole FROM @grantRole;
EXECUTE stmtGrantRole; EXECUTE stmtGrantRole;
# Test reexecution.
EXECUTE stmtGrantRole;
# #
# We should see 2 entries in the roles_mapping table. # We should see 2 entries in the roles_mapping table.
# #
...@@ -43,6 +48,17 @@ GRANT USAGE ON *.* TO 'test_user'@'%' ...@@ -43,6 +48,17 @@ GRANT USAGE ON *.* TO 'test_user'@'%'
SET @revokeRole = 'REVOKE developers FROM test_user'; SET @revokeRole = 'REVOKE developers FROM test_user';
PREPARE stmtRevokeRole FROM @revokeRole; PREPARE stmtRevokeRole FROM @revokeRole;
EXECUTE stmtRevokeRole; EXECUTE stmtRevokeRole;
EXECUTE stmtRevokeRole;
ERROR HY000: Cannot revoke role 'developers' from: 'test_user'@'%'.
SHOW GRANTS FOR test_user;
Grants for test_user@%
GRANT USAGE ON *.* TO 'test_user'@'%'
EXECUTE stmtGrantRole;
SHOW GRANTS FOR test_user;
Grants for test_user@%
GRANT developers TO 'test_user'@'%'
GRANT USAGE ON *.* TO 'test_user'@'%'
EXECUTE stmtRevokeRole;
SHOW GRANTS FOR test_user; SHOW GRANTS FOR test_user;
Grants for test_user@% Grants for test_user@%
GRANT USAGE ON *.* TO 'test_user'@'%' GRANT USAGE ON *.* TO 'test_user'@'%'
...@@ -67,5 +83,25 @@ GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION ...@@ -67,5 +83,25 @@ GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
SHOW GRANTS FOR test_user; SHOW GRANTS FOR test_user;
Grants for test_user@% Grants for test_user@%
GRANT USAGE ON *.* TO 'test_user'@'%' GRANT USAGE ON *.* TO 'test_user'@'%'
#
# Test reexecution.
#
EXECUTE stmtCreateRole;
SELECT user, host,is_role FROM mysql.user
WHERE user = 'developers';
user host is_role
developers Y
SELECT * FROM mysql.roles_mapping;
Host User Role Admin_option
localhost root developers Y
SHOW GRANTS;
Grants for root@localhost
GRANT developers TO 'root'@'localhost' WITH ADMIN OPTION
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
SHOW GRANTS FOR test_user;
Grants for test_user@%
GRANT USAGE ON *.* TO 'test_user'@'%'
EXECUTE stmtDropRole;
# Cleanup. # Cleanup.
DROP USER test_user; DROP USER test_user;
...@@ -18,12 +18,18 @@ SELECT user, host,is_role FROM mysql.user ...@@ -18,12 +18,18 @@ SELECT user, host,is_role FROM mysql.user
WHERE user = 'developers'; WHERE user = 'developers';
SHOW GRANTS; SHOW GRANTS;
--echo # Test reexecution.
--error ER_CANNOT_USER
EXECUTE stmtCreateRole;
--echo # --echo #
--echo # Now grant the role to the test user. --echo # Now grant the role to the test user.
--echo # --echo #
SET @grantRole = 'GRANT developers to test_user'; SET @grantRole = 'GRANT developers to test_user';
PREPARE stmtGrantRole FROM @grantRole; PREPARE stmtGrantRole FROM @grantRole;
EXECUTE stmtGrantRole; EXECUTE stmtGrantRole;
--echo # Test reexecution.
EXECUTE stmtGrantRole;
--echo # --echo #
--echo # We should see 2 entries in the roles_mapping table. --echo # We should see 2 entries in the roles_mapping table.
...@@ -38,7 +44,13 @@ SHOW GRANTS FOR test_user; ...@@ -38,7 +44,13 @@ SHOW GRANTS FOR test_user;
SET @revokeRole = 'REVOKE developers FROM test_user'; SET @revokeRole = 'REVOKE developers FROM test_user';
PREPARE stmtRevokeRole FROM @revokeRole; PREPARE stmtRevokeRole FROM @revokeRole;
EXECUTE stmtRevokeRole; EXECUTE stmtRevokeRole;
--error ER_CANNOT_REVOKE_ROLE
EXECUTE stmtRevokeRole;
SHOW GRANTS FOR test_user;
EXECUTE stmtGrantRole;
SHOW GRANTS FOR test_user;
EXECUTE stmtRevokeRole;
SHOW GRANTS FOR test_user; SHOW GRANTS FOR test_user;
--echo # --echo #
...@@ -57,5 +69,17 @@ SELECT * FROM mysql.roles_mapping; ...@@ -57,5 +69,17 @@ SELECT * FROM mysql.roles_mapping;
SHOW GRANTS; SHOW GRANTS;
SHOW GRANTS FOR test_user; SHOW GRANTS FOR test_user;
--echo #
--echo # Test reexecution.
--echo #
EXECUTE stmtCreateRole;
SELECT user, host,is_role FROM mysql.user
WHERE user = 'developers';
SELECT * FROM mysql.roles_mapping;
SHOW GRANTS;
SHOW GRANTS FOR test_user;
EXECUTE stmtDropRole;
--echo # Cleanup. --echo # Cleanup.
DROP USER test_user; DROP USER test_user;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment