1
# auth_file has to be used to provide access for user root, else the tests
2
# won't work. auth_schema can't provide this access because no one has
3
# access until the auth table is created.
5
# Check that the plugin is loaded and using the default auth.users table.
6
SHOW VARIABLES LIKE 'auth_schema%';
8
# mysql_protocol provides MYSQL_PASSWORD().
9
SELECT MYSQL_PASSWORD('test_pass');
14
user VARCHAR(255) NOT NULL,
16
UNIQUE INDEX user_idx (user)
18
INSERT INTO users VALUES ('test_user', '34F2496C75CF8F8D8EBE14067C9C8B1AA8E80DEF');
20
SELECT * FROM users ORDER BY user;
22
connect(conn1, localhost, test_user, test_pass,,);
23
SELECT 'connection 1 works';
25
--exec $TOP_BUILDDIR/client/drizzle --host=localhost --port=$MASTER_MYPORT -e "SELECT 'client 1 works'" --user=test_user --password=test_pass 2>&1
27
# Test that bad passwords aren't accepted.
28
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
29
--replace_regex /@'.*?'/@'LOCALHOST'/
30
--error ER_ACCESS_DENIED_ERROR
31
connect (bad_user,localhost,test_user,foo,,);
33
# Test that the auth table can be changed dynamically.
36
user VARCHAR(255) NOT NULL,
38
UNIQUE INDEX user_idx (user)
40
INSERT INTO users2 VALUES ('test_user2', '34F2496C75CF8F8D8EBE14067C9C8B1AA8E80DEF');
41
SELECT * FROM users2 ORDER BY user;
43
SET GLOBAL auth_schema_table='`auth`.`users2`';
44
SHOW VARIABLES LIKE 'auth_schema%';
46
connect(conn2, localhost, test_user2, test_pass,,);
47
SELECT 'connection 2 works';
49
--exec $TOP_BUILDDIR/client/drizzle --host=localhost --port=$MASTER_MYPORT -e "SELECT 'client 2 works'" --user=test_user2 --password=test_pass 2>&1
51
# Restore the original auth table for subsequent tests (or --repeat 2).
52
SET GLOBAL auth_schema_table='auth.users';
54
# Test that auth_schema works with hex strings created MYSQL_PASSWORD().
55
INSERT INTO auth.users VALUES ('test_user3', MYSQL_PASSWORD('mypass'));
56
SELECT * FROM auth.users WHERE user='test_user3';
58
--exec $TOP_BUILDDIR/client/drizzle --host=localhost --port=$MASTER_MYPORT -e "SELECT 'client 3 works'" --user=test_user3 --password=mypass 2>&1
60
# Disable authentication.
61
SET GLOBAL auth_schema_enabled=0;
62
SHOW VARIABLES LIKE 'auth_schema%';
64
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
65
--replace_regex /@'.*?'/@'LOCALHOST'/
66
--error ER_ACCESS_DENIED_ERROR
67
connect(conn3, localhost, test_user, test_pass,,);
69
# Re-enable authentication.
70
SET GLOBAL auth_schema_enabled=1;
71
SHOW VARIABLES LIKE 'auth_schema%';
73
connect(conn3, localhost, test_user, test_pass,,);
74
SELECT 'auth re-enabled';
76
# Escape user name; avoid SQL injection.
77
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
78
--replace_regex /@'.*?'/@'LOCALHOST'/
79
--error ER_ACCESS_DENIED_ERROR
80
connect(conn4, localhost, "'; drop table auth.users; select '", test_pass,,);
82
SHOW TABLES FROM auth;
84
# Don't crash if we try to set the auth table to NULL.
85
--error ER_WRONG_ARGUMENTS
86
SET GLOBAL auth_schema_table=NULL;
87
SHOW VARIABLES LIKE 'auth_schema_table';
89
# And don't permit a blank string for the auth table.
90
--error ER_WRONG_ARGUMENTS
91
SET GLOBAL auth_schema_table='';
92
SHOW VARIABLES LIKE 'auth_schema_table';