|
| 1 | +# Grant tests not performed with embedded server |
| 2 | +-- source include/not_embedded.inc |
| 3 | + |
| 4 | +--echo # |
| 5 | +--echo # Tests for checking permission denied on CREATE OR REPLACE if DROP |
| 6 | +--echo # access is revoked |
| 7 | +--echo # |
| 8 | + |
| 9 | +--echo # These statements do not need special tests for CREATE OR REPLACE, |
| 10 | +--echo # because they do not have separate permissions for create and drop: |
| 11 | +--echo # CREATE OR REPLACE EVENT (uses EVENT_ACL for both CREATE and DROP) |
| 12 | +--echo # CREATE OR DROP SERVER (uses SUPER_ALC for both CREATE and DROP) |
| 13 | +--echo # CREATE OR DROP TRIGGER (uses TRIGGER_ACL for both CREATE and DROP) |
| 14 | + |
| 15 | +SELECT CURRENT_USER; |
| 16 | +CREATE DATABASE db1; |
| 17 | +GRANT ALL ON db1.* TO mysqltest_1@localhost; |
| 18 | +REVOKE DROP ON db1.* FROM mysqltest_1@localhost; |
| 19 | +REVOKE ALTER ROUTINE ON db1.* FROM mysqltest_1@localhost; |
| 20 | +GRANT DELETE ON mysql.* TO mysqltest_1@localhost; |
| 21 | +REVOKE DELETE ON mysql.* FROM mysqltest_1@localhost; |
| 22 | +FLUSH PRIVILEGES; |
| 23 | + |
| 24 | +connect (user_a, localhost, mysqltest_1,,); |
| 25 | +connection user_a; |
| 26 | +SELECT CURRENT_USER; |
| 27 | + |
| 28 | +# mysqltest_1 has CREATE privilege on db1 |
| 29 | +--error ER_DB_CREATE_EXISTS |
| 30 | +CREATE DATABASE db1; |
| 31 | + |
| 32 | +# mysqltest_1 has no DROP privilege on db1 |
| 33 | +--error ER_DBACCESS_DENIED_ERROR |
| 34 | +CREATE OR REPLACE DATABASE db1; |
| 35 | + |
| 36 | +# mysqltest_1 has no any privileges on db2 |
| 37 | +--error ER_DBACCESS_DENIED_ERROR |
| 38 | +CREATE OR REPLACE DATABASE db2; |
| 39 | + |
| 40 | +USE db1; |
| 41 | +--error ER_TABLEACCESS_DENIED_ERROR |
| 42 | +CREATE OR REPLACE TABLE t1(id INT); |
| 43 | + |
| 44 | +#TODO: add this when "MDEV-5359 CREATE OR REPLACE..." is done |
| 45 | +#DELIMITER $; |
| 46 | +#--error ER_PROCACCESS_DENIED_ERROR |
| 47 | +#CREATE OR REPLACE PROCEDURE proc1 (OUT cnt INT) BEGIN SELECT COUNT(*) INTO cnt FROM t1; END$ |
| 48 | +#DELIMITER ;$ |
| 49 | +# |
| 50 | +#--error ER_DBACCESS_DENIED_ERROR |
| 51 | +#CREATE OR REPLACE FUNCTION lookup RETURNS STRING SONAME "udf_example.so"; |
| 52 | +# |
| 53 | +#--error ER_PROCACCESS_DENIED_ERROR |
| 54 | +#CREATE OR REPLACE FUNCTION hello(str char(20)) RETURNS TEXT RETURN CONCAT('Hello, ', str, '!'); |
| 55 | +# |
| 56 | +#--error ER_SPECIFIC_ACCESS_DENIED_ERROR |
| 57 | +#CREATE OR REPLACE USER u1@localhost; |
| 58 | +# |
| 59 | +#--error ER_SPECIFIC_ACCESS_DENIED_ERROR |
| 60 | +#CREATE OR REPLACE ROLE developer; |
| 61 | + |
| 62 | +connection default; |
| 63 | +SELECT CURRENT_USER; |
| 64 | +REVOKE ALL ON db1.* FROM mysqltest_1@localhost; |
| 65 | +DROP DATABASE IF EXISTS db2; |
| 66 | +DROP DATABASE db1; |
| 67 | +DROP USER mysqltest_1@localhost; |
0 commit comments