~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/auth_schema/tests/t/basic.test

  • Committer: Daniel Nichter
  • Date: 2011-09-26 01:40:03 UTC
  • mto: This revision was merged to the branch mainline in revision 2437.
  • Revision ID: daniel@percona.com-20110926014003-5q2prdqcl84v583m
auth_schema (auth_db) working prototype.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
4
 
 
5
# Check that the plugin is loaded and using the default auth.users table.
 
6
SHOW VARIABLES LIKE 'auth_schema%';
 
7
 
 
8
# mysql_protocol provides MYSQL_PASSWORD().
 
9
SELECT MYSQL_PASSWORD('test_pass');
 
10
 
 
11
CREATE SCHEMA auth;
 
12
USE auth;
 
13
CREATE TABLE users (
 
14
  user     VARCHAR(255) NOT NULL,
 
15
  password VARCHAR(40),
 
16
  UNIQUE INDEX user_idx (user)
 
17
);
 
18
INSERT INTO users VALUES ('test_user', '34F2496C75CF8F8D8EBE14067C9C8B1AA8E80DEF');
 
19
 
 
20
SELECT * FROM users ORDER BY user;
 
21
 
 
22
connect(conn1, localhost, test_user, test_pass,,);
 
23
connection conn1;
 
24
SELECT 'connection 1 works';
 
25
 
 
26
--exec $TOP_BUILDDIR/client/drizzle --host=localhost --port=$MASTER_MYPORT -e "SELECT 'client 1 works'" --user=test_user --password=test_pass 2>&1
 
27
 
 
28
# Test that bad passwords aren't accepted.
 
29
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
30
--replace_regex /@'.*?'/@'LOCALHOST'/
 
31
--error ER_ACCESS_DENIED_ERROR
 
32
connect (bad_user,localhost,test_user,foo,,);
 
33
 
 
34
# Test that the auth table can be changed dynamically.
 
35
USE auth;
 
36
CREATE TABLE users2 (
 
37
  user     VARCHAR(255) NOT NULL,
 
38
  password VARCHAR(40),
 
39
  UNIQUE INDEX user_idx (user)
 
40
);
 
41
INSERT INTO users2 VALUES ('test_user2', '34F2496C75CF8F8D8EBE14067C9C8B1AA8E80DEF');
 
42
SELECT * FROM users2 ORDER BY user;
 
43
 
 
44
SET GLOBAL auth_schema_table='auth.users2';
 
45
SHOW VARIABLES LIKE 'auth_schema%';
 
46
 
 
47
connect(conn2, localhost, test_user2, test_pass,,);
 
48
connection conn2;
 
49
SELECT 'connection 2 works';
 
50
 
 
51
--exec $TOP_BUILDDIR/client/drizzle --host=localhost --port=$MASTER_MYPORT -e "SELECT 'client 2 works'" --user=test_user2 --password=test_pass 2>&1
 
52
 
 
53
# Restore the original auth table for subsequent tests (or --repeat 2).
 
54
SET GLOBAL auth_schema_table='auth.users';
 
55
 
 
56
# Test that auth_schema works with hex strings created MYSQL_PASSWORD().
 
57
INSERT INTO auth.users VALUES ('test_user3', MYSQL_PASSWORD('mypass'));
 
58
SELECT * FROM auth.users WHERE user='test_user3';
 
59
 
 
60
--exec $TOP_BUILDDIR/client/drizzle --host=localhost --port=$MASTER_MYPORT -e "SELECT 'client 3 works'" --user=test_user3 --password=mypass 2>&1
 
61
 
 
62
DROP SCHEMA auth;