~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Clint Byrum
  • Date: 2011-03-03 01:55:10 UTC
  • mto: (2222.1.1 build)
  • mto: This revision was merged to the branch mainline in revision 2223.
  • Revision ID: clint@ubuntu.com-20110303015510-fj9fsdimwyo2gefy
Adding regex_policy plugin for detailed authorization specifiction

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Check for error if no parameter provided
 
2
create schema user1;
 
3
create schema user2;
 
4
SELECT SCHEMA_NAME FROM DATA_DICTIONARY.SCHEMAS ORDER BY SCHEMA_NAME;
 
5
 
 
6
# Set up a table to be able to test not being able to kill other people
 
7
use user2;
 
8
create table t1 (kill_id int);
 
9
insert into t1 values(connection_id());
 
10
 
 
11
# Test that we get a normal don't exist error for things that don't exist
 
12
--error ER_TABLE_UNKNOWN
 
13
SELECT * from user1.dont_exist;
 
14
 
 
15
# Connect as user1 - should only see information_schema, user1 and
 
16
# data_dictionary
 
17
# Also tests that we are able to read data_dictionary, without which fail
 
18
# would happen
 
19
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
20
connect (should_succeed,localhost,user1,,user1,,);
 
21
connection should_succeed;
 
22
SELECT SCHEMA_NAME FROM DATA_DICTIONARY.SCHEMAS ORDER BY SCHEMA_NAME;
 
23
 
 
24
# Test that we get blocked on not being allowed to see user2 at all before
 
25
# we get blocked on the table not existing
 
26
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
27
--replace_regex /@'.*?'/@'LOCALHOST'/
 
28
--error ER_DBACCESS_DENIED_ERROR
 
29
SELECT * from user2.dont_exist;
 
30
 
 
31
# Test that we can't create a schema that isn't named the same as we are
 
32
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
33
--replace_regex /@'.*?'/@'LOCALHOST'/
 
34
--error ER_DBACCESS_DENIED_ERROR
 
35
create schema authorize_fail;
 
36
 
 
37
# Test that we can't drop a schema that isn't named the same as we are
 
38
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
39
--replace_regex /@'.*?'/@'LOCALHOST'/
 
40
--error ER_DBACCESS_DENIED_ERROR
 
41
drop schema user2;
 
42
 
 
43
# Set up a table to test that we can kill other versions of us
 
44
create table t1 (kill_id int);
 
45
insert into t1 values(connection_id());
 
46
 
 
47
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
48
connect (con1,localhost,user1,,user1,);
 
49
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
50
connect (con2,localhost,user2,,user2,);
 
51
connection con1;
 
52
 
 
53
# Check that we don't see other people's connections
 
54
SELECT USERNAME, DB FROM DATA_DICTIONARY.PROCESSLIST ORDER BY USERNAME, DB;
 
55
 
 
56
# Check that we can kill a process that is owned by our user
 
57
--disable_reconnect
 
58
select IF(((@id := kill_id) - kill_id), "NO", "YES") from t1;
 
59
kill @id;
 
60
 
 
61
connection should_succeed;
 
62
--sleep 2
 
63
 
 
64
--disable_query_log
 
65
--disable_result_log
 
66
# One of the following statements should fail
 
67
--error EE_OK,EE_BADCLOSE,EE_UNKNOWN_CHARSET,EE_CANT_SYMLINK
 
68
select 1;
 
69
--error EE_OK,EE_BADCLOSE,EE_UNKNOWN_CHARSET,EE_CANT_SYMLINK
 
70
select 1;
 
71
--enable_query_log
 
72
--enable_result_log
 
73
--enable_reconnect
 
74
 
 
75
select IF(((@id := kill_id) - kill_id), "NO", "YES") from t1;
 
76
select @id != connection_id();
 
77
 
 
78
# Set the table to our current id now
 
79
update t1 set kill_id = connection_id();
 
80
 
 
81
# Test that we cannot kill a process owned by someone else
 
82
connection con2;
 
83
SELECT USERNAME, DB FROM DATA_DICTIONARY.PROCESSLIST ORDER BY USERNAME, DB;
 
84
select IF(((@id := kill_id) - kill_id), "NO", "YES") from t1;
 
85
 
 
86
--replace_regex /Unknown session id: [0-9]+/Unknown session id: #/
 
87
--error ER_NO_SUCH_THREAD
 
88
kill @id;
 
89
 
 
90
# Test that root can see everybody
 
91
connection default;
 
92
SELECT USERNAME, DB FROM DATA_DICTIONARY.PROCESSLIST ORDER BY USERNAME, DB;
 
93
 
 
94
# Test that root can kill someone else
 
95
use user1;
 
96
--disable_reconnect
 
97
select IF(((@id := kill_id) - kill_id), "NO", "YES") from t1;
 
98
kill @id;
 
99
 
 
100
connection should_succeed;
 
101
--sleep 2
 
102
 
 
103
--disable_query_log
 
104
--disable_result_log
 
105
# One of the following statements should fail
 
106
--error EE_OK,EE_BADCLOSE,EE_UNKNOWN_CHARSET,EE_CANT_SYMLINK
 
107
select 1;
 
108
--error EE_OK,EE_BADCLOSE,EE_UNKNOWN_CHARSET,EE_CANT_SYMLINK
 
109
select 1;
 
110
--enable_query_log
 
111
--enable_result_log
 
112
--enable_reconnect
 
113
 
 
114
select IF(((@id := kill_id) - kill_id), "NO", "YES") from t1;
 
115
select @id != connection_id();
 
116
 
 
117
 
 
118
# Test failing initial connection
 
119
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
 
120
--replace_regex /@'.*?'/@'LOCALHOST'/
 
121
--error ER_DBACCESS_DENIED_ERROR
 
122
connect (should_fail,localhost,authz,,authz_no,,);
 
123
 
 
124
# Clean up after ourselves
 
125
connection default;
 
126
drop schema user1;
 
127
drop schema user2;
 
128
disconnect con1;
 
129
disconnect con2;
 
130
disconnect should_succeed;