Commit f284c9b7 authored by Alexander Barkov's avatar Alexander Barkov

Adding FILE privilege tests for TABLE_TYPE=INI

modified:
  mysql-test/suite/connect/r/ini.result
  mysql-test/suite/connect/t/ini.test
parent 92bb9d3f
#
# Checking FILE privileges
#
GRANT ALL PRIVILEGES ON *.* TO user@localhost;
REVOKE FILE ON *.* FROM user@localhost;
SELECT user();
user()
user@localhost
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI;
Warnings:
Warning 1105 No file name. Table will use t1.INI
INSERT INTO t1 VALUES ('sec1','val1');
SELECT * FROM t1;
sec val
sec1 val1
UPDATE t1 SET val='val11';
SELECT * FROM t1;
sec val
sec1 val11
DELETE FROM t1;
SELECT * FROM t1;
sec val
INSERT INTO t1 VALUES('sec2','val2');
TRUNCATE TABLE t1;
SELECT * FROM t1;
sec val
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1;
sec val
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT';
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
SELECT user();
user()
root@localhost
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT';
INSERT INTO t1 VALUES ('sec1','val1');
SELECT user();
user()
user@localhost
INSERT INTO t1 VALUES ('sec2','val2');
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
SELECT * FROM t1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
UPDATE t1 SET val='val11';
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
DELETE FROM t1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
TRUNCATE TABLE t1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
ALTER TABLE t1 READONLY=1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
DROP TABLE t1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
CREATE VIEW v1 AS SELECT * FROM t1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
# Testing a VIEW created with FILE privileges but accessed with no FILE
SELECT user();
user()
root@localhost
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT user();
user()
user@localhost
SELECT * FROM v1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
INSERT INTO v1 VALUES ('sec3','val3');
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
UPDATE v1 SET val='val11';
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
DELETE FROM v1;
ERROR 28000: Access denied for user 'user'@'localhost' (using password: NO)
DROP VIEW v1;
DROP TABLE t1;
DROP USER user@localhost;
#
# Checking FILE privileges: done
#
#
# Testing errors
#
CREATE TABLE t1
......
let $MYSQLD_DATADIR= `select @@datadir`;
--echo #
--echo # Checking FILE privileges
--echo #
GRANT ALL PRIVILEGES ON *.* TO user@localhost;
REVOKE FILE ON *.* FROM user@localhost;
--connect(user,localhost,user,,)
--connection user
SELECT user();
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI;
INSERT INTO t1 VALUES ('sec1','val1');
SELECT * FROM t1;
UPDATE t1 SET val='val11';
SELECT * FROM t1;
DELETE FROM t1;
SELECT * FROM t1;
INSERT INTO t1 VALUES('sec2','val2');
TRUNCATE TABLE t1;
SELECT * FROM t1;
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
# Making sure DROP erased the data file
--error 1
--remove_file $MYSQLD_DATADIR/test/t1.INI
--error ER_ACCESS_DENIED_ERROR
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT';
--connection default
SELECT user();
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT';
INSERT INTO t1 VALUES ('sec1','val1');
--connection user
SELECT user();
--error ER_ACCESS_DENIED_ERROR
INSERT INTO t1 VALUES ('sec2','val2');
--error ER_ACCESS_DENIED_ERROR
SELECT * FROM t1;
--error ER_ACCESS_DENIED_ERROR
UPDATE t1 SET val='val11';
--error ER_ACCESS_DENIED_ERROR
DELETE FROM t1;
--error ER_ACCESS_DENIED_ERROR
TRUNCATE TABLE t1;
--error ER_ACCESS_DENIED_ERROR
ALTER TABLE t1 READONLY=1;
--error ER_ACCESS_DENIED_ERROR
DROP TABLE t1;
--error ER_ACCESS_DENIED_ERROR
CREATE VIEW v1 AS SELECT * FROM t1;
--echo # Testing a VIEW created with FILE privileges but accessed with no FILE
--connection default
SELECT user();
CREATE VIEW v1 AS SELECT * FROM t1;
--connection user
SELECT user();
--error ER_ACCESS_DENIED_ERROR
SELECT * FROM v1;
--error ER_ACCESS_DENIED_ERROR
INSERT INTO v1 VALUES ('sec3','val3');
--error ER_ACCESS_DENIED_ERROR
UPDATE v1 SET val='val11';
--error ER_ACCESS_DENIED_ERROR
DELETE FROM v1;
--disconnect user
--connection default
DROP VIEW v1;
DROP TABLE t1;
--remove_file $MYSQLD_DATADIR/test/t1.EXT
DROP USER user@localhost;
--echo #
--echo # Checking FILE privileges: done
--echo #
--copy_file $MYSQL_TEST_DIR/suite/connect/std_data/contact.ini $MYSQLD_DATADIR/test/contact.ini
--echo #
......
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