Debian Codegraph @

mysql-test/suite/connection_control/t/connection_exempt_proxy_users.test

raw
1 # Same test as "connection_delay_proxy_users.test" but with
2 # exempt_unknown_users set to ON, this helped to increase
3 # the code coverage.
4
5 # Make sure that connection_control plugin can be loaded
6 --source ../inc/have_connection_control_plugin.inc
7 --source ../inc/have_test_plugin.inc
8
9 # Save the initial number of concurrent sessions
10 --source include/count_sessions.inc
11
12 --echo #-----------------------------------------------------------------------
13 --echo # Setup
14 --echo # Install connection_control plugin
15 --source ../inc/install_connection_control_plugin.inc
16 --echo # Do proxy setup
17 --source ../inc/setup_proxy_accounts.inc
18
19 # Official builds include separate debug enabled plugins to be used by
20 # the debug enabled server. But the non-debug *client* should not use them.
21
22 let PLUGIN_AUTH_OPT=`SELECT TRIM(TRAILING '/debug' FROM '$PLUGIN_AUTH_OPT')`;
23 let CONNECTION_CONTROL_PLUGIN_OPT=`SELECT TRIM(TRAILING '/debug' FROM '$CONNECTION_CONTROL_PLUGIN_OPT')`;
24
25 # Suppress error messages from test_plugin_server
26 CALL mtr.add_suppression("Plugin test_plugin_server reported: 'Wrong password supplied for proxied'");
27
28 # Save original values of connection_control variables
29 SET @saved_connections_threshold = @@global.connection_control_failed_connections_threshold;
30 SET @saved_max_delay = @@global.connection_control_max_connection_delay;
31 SET @saved_min_delay= @@global.connection_control_min_connection_delay;
32 SET @saved_exempt= @@global.connection_control_exempt_unknown_users;
33
34 # Set a small values for connection_control variables
35 SET @@global.connection_control_failed_connections_threshold = 3;
36 SET @@global.connection_control_max_connection_delay = 4000;
37 SET @@global.connection_control_min_connection_delay = 2000;
38
39 # Exempt users
40 SET @@global.connection_control_exempt_unknown_users= 1;
41
42 # We will use client side authentication plugin for this test.
43 let $USE_AUTH_PLUGIN= 1;
44 let $CLIENT_AUTH_PLUGIN= $PLUGIN_AUTH_OPT;
45
46 --echo #-----------------------------------------------------------------------
47
48 --echo # Case 1 : Tests for valid user accounts
49
50 --echo # Make enough failed attempts to trigger delays
51
52 disable_result_log;
53
54 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
55 --error ER_ACCESS_DENIED_ERROR
56 connect(fail_con_u1, localhost, u1,,,,,);
57 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
58 --error ER_ACCESS_DENIED_ERROR
59 connect(fail_con_u1, localhost, u1,haha,,,,);
60 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
61 --error ER_ACCESS_DENIED_ERROR
62 connect(fail_con_u1, localhost, u2,efgh,,,,);
63
64 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
65 --error ER_ACCESS_DENIED_ERROR
66 connect(fail_con_u1, localhost, u3,,,,,);
67 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
68 --error ER_ACCESS_DENIED_ERROR
69 connect(fail_con_u1, localhost, u2,haha,,,,);
70 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
71 --error ER_ACCESS_DENIED_ERROR
72 connect(fail_con_u1, localhost, u3,efgh,,,,);
73
74 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
75 --error ER_ACCESS_DENIED_ERROR
76 connect(fail_con_u1, localhost, u2,,,,,);
77 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
78 --error ER_ACCESS_DENIED_ERROR
79 connect(fail_con_u1, localhost, u1,haha,,,,);
80 --replace_result $MASTER_MYSOCK SOURCE_SOCKET $MASTER_MYPORT SOURCE_PORT
81 --error ER_ACCESS_DENIED_ERROR
82 connect(fail_con_u1, localhost, u3,efgh,,,,);
83
84 enable_result_log;
85
86 --echo # Following attempts will experience delay in server respose
87
88 # Trying with invalid passwords
89
90 --source ../inc/set_before_marker.inc
91 let $USER=u1;
92 let $PASSWORD=hoho;
93 let $SUCCESS=0;
94 let $DELAY_STATS=1;
95 --source ../inc/check_connection_delay.inc
96
97 let $SERVER_RESPONSE_TIME= 2;
98 --source ../inc/set_after_marker.inc
99
100 --source ../inc/set_before_marker.inc
101 let $USER=u2;
102 let $PASSWORD=hoho;
103 let $SUCCESS=0;
104 let $DELAY_STATS=2;
105 --source ../inc/check_connection_delay.inc
106
107 let $SERVER_RESPONSE_TIME= 2;
108 --source ../inc/set_after_marker.inc
109
110 --source ../inc/set_before_marker.inc
111 let $USER=u3;
112 let $PASSWORD=hoho;
113 let $SUCCESS=0;
114 let $DELAY_STATS=3;
115 --source ../inc/check_connection_delay.inc
116
117 let $SERVER_RESPONSE_TIME= 2;
118 --source ../inc/set_after_marker.inc
119
120 # Trying with valid passwords
121 # Even though u1@localhost, u2@localhost and u3@localhost are
122 # proxying same user - proxied@localhost, we will not use
123 # proxied@localhost for recording failed attempts information.
124 # Rather, we will rely on proxying users' data.
125 # So each of the following should get delay of 2 seconds
126 # or more.
127
128 --source ../inc/set_before_marker.inc
129 let $USER=u3;
130 let $PASSWORD=proxied;
131 let $SUCCESS=1;
132 let $DELAY_STATS=4;
133 --source ../inc/check_connection_delay.inc
134
135 let $SERVER_RESPONSE_TIME= 2;
136 --source ../inc/set_after_marker.inc
137
138 --source ../inc/set_before_marker.inc
139 let $USER=u2;
140 let $PASSWORD=proxied;
141 let $SUCCESS=1;
142 let $DELAY_STATS=5;
143 --source ../inc/check_connection_delay.inc
144
145 let $SERVER_RESPONSE_TIME= 2;
146 --source ../inc/set_after_marker.inc
147
148 --source ../inc/set_before_marker.inc
149 let $USER=u1;
150 let $PASSWORD=proxied;
151 let $SUCCESS=1;
152 let $DELAY_STATS=6;
153 --source ../inc/check_connection_delay.inc
154
155 let $SERVER_RESPONSE_TIME= 2;
156 --source ../inc/set_after_marker.inc
157
158
159 --echo # Following attempts will not experience any delay in server respose
160
161 let $USER=u1;
162 let $PASSWORD=hoho;
163 let $SUCCESS=0;
164 let $DELAY_STATS=6;
165 --source ../inc/check_connection_delay.inc
166
167 let $USER=u2;
168 let $PASSWORD=hoho;
169 let $SUCCESS=0;
170 let $DELAY_STATS=6;
171 --source ../inc/check_connection_delay.inc
172
173 let $USER=u3;
174 let $PASSWORD=hoho;
175 let $SUCCESS=0;
176 let $DELAY_STATS=6;
177 --source ../inc/check_connection_delay.inc
178
179 let $USER=u1;
180 let $PASSWORD=proxied;
181 let $SUCCESS=1;
182 let $DELAY_STATS=6;
183 --source ../inc/check_connection_delay.inc
184
185 let $USER=u2;
186 let $PASSWORD=proxied;
187 let $SUCCESS=1;
188 let $DELAY_STATS=6;
189 --source ../inc/check_connection_delay.inc
190
191 let $USER=u3;
192 let $PASSWORD=proxied;
193 let $SUCCESS=1;
194 let $DELAY_STATS=6;
195 --source ../inc/check_connection_delay.inc
196
197 --echo #-----------------------------------------------------------------------
198 --echo # Cleanup
199
200 connection default;
201
202 # Restore original values of connection_control variables
203 SET @@global.connection_control_failed_connections_threshold = @saved_connections_threshold;
204 SET @@global.connection_control_max_connection_delay = @saved_max_delay;
205 SET @@global.connection_control_min_connection_delay = @saved_min_delay;
206 SET @@global.connection_control_exempt_unknown_users= @saved_exempt;
207
208 --echo # Remove user accounts
209 --source ../inc/cleanup_proxy_accounts.inc
210 --echo # Uninstall connection_control plugin
211 --source ../inc/uninstall_connection_control_plugin.inc
212
213 # Wait till all disconnects are completed.
214 --source include/wait_until_count_sessions.inc
215 --echo #-----------------------------------------------------------------------