| 1 |
# Connection delay tests for valid user accounts |
| 2 |
|
| 3 |
# ---------------------------------------------------------------------- |
| 4 |
|
| 5 |
# Setup |
| 6 |
# Install connection_control plugin |
| 7 |
INSTALL PLUGIN connection_control SONAME 'CONNECTION_CONTROL_LIB'; |
| 8 |
INSTALL PLUGIN connection_control_failed_login_attempts SONAME 'CONNECTION_CONTROL_LIB'; |
| 9 |
# Create user accounts for testing |
| 10 |
CREATE USER u1@localhost IDENTIFIED BY 'abcd'; |
| 11 |
CREATE USER u2@localhost IDENTIFIED BY 'abcd'; |
| 12 |
CREATE USER u3@localhost IDENTIFIED BY 'abcd'; |
| 13 |
# Save original values of connection_control variables |
| 14 |
SET @saved_connections_threshold = @@global.connection_control_failed_connections_threshold; |
| 15 |
SET @saved_max_delay= @@global.connection_control_max_connection_delay; |
| 16 |
# Set small threshold |
| 17 |
SET @@global.connection_control_failed_connections_threshold = 1; |
| 18 |
# Set small max delay |
| 19 |
SET @@global.connection_control_max_connection_delay = 1000; |
| 20 |
|
| 21 |
# ---------------------------------------------------------------------- |
| 22 |
|
| 23 |
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET); |
| 24 |
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO) |
| 25 |
connect(localhost,u3,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 26 |
ERROR 28000: Access denied for user 'u3'@'localhost' (using password: YES) |
| 27 |
connect(localhost,u2,efgh,test,MASTER_PORT,MASTER_SOCKET); |
| 28 |
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: YES) |
| 29 |
# Check Connection_control_delay_generated - Should be 0 |
| 30 |
SHOW STATUS LIKE 'Connection_control_delay_generated'; |
| 31 |
Variable_name Value |
| 32 |
Connection_control_delay_generated 0 |
| 33 |
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET); |
| 34 |
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO) |
| 35 |
connect(localhost,u2,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 36 |
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: YES) |
| 37 |
connect(localhost,u3,efgh,test,MASTER_PORT,MASTER_SOCKET); |
| 38 |
ERROR 28000: Access denied for user 'u3'@'localhost' (using password: YES) |
| 39 |
connect(localhost,u2,,test,MASTER_PORT,MASTER_SOCKET); |
| 40 |
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: NO) |
| 41 |
connect(localhost,u1,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 42 |
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: YES) |
| 43 |
connect(localhost,u3,efgh,test,MASTER_PORT,MASTER_SOCKET); |
| 44 |
ERROR 28000: Access denied for user 'u3'@'localhost' (using password: YES) |
| 45 |
# Check Connection_control_delay_generated - Should be 6 |
| 46 |
SHOW STATUS LIKE 'Connection_control_delay_generated'; |
| 47 |
Variable_name Value |
| 48 |
Connection_control_delay_generated 6 |
| 49 |
connect(localhost,u2,,test,MASTER_PORT,MASTER_SOCKET); |
| 50 |
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: NO) |
| 51 |
connect(localhost,u1,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 52 |
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: YES) |
| 53 |
connect(localhost,u3,efgh,test,MASTER_PORT,MASTER_SOCKET); |
| 54 |
ERROR 28000: Access denied for user 'u3'@'localhost' (using password: YES) |
| 55 |
# Check Connection_control_delay_generated - Should be 9 |
| 56 |
SHOW STATUS LIKE 'Connection_control_delay_generated'; |
| 57 |
Variable_name Value |
| 58 |
Connection_control_delay_generated 9 |
| 59 |
# Successful connection but delays would still be generated |
| 60 |
# Should be 12 |
| 61 |
SHOW STATUS LIKE 'Connection_control_delay_generated'; |
| 62 |
Variable_name Value |
| 63 |
Connection_control_delay_generated 12 |
| 64 |
# Setting failed connection threshold should reset delay statistics |
| 65 |
SET @@global.connection_control_failed_connections_threshold = 1; |
| 66 |
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET); |
| 67 |
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO) |
| 68 |
connect(localhost,u3,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 69 |
ERROR 28000: Access denied for user 'u3'@'localhost' (using password: YES) |
| 70 |
connect(localhost,u2,efgh,test,MASTER_PORT,MASTER_SOCKET); |
| 71 |
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: YES) |
| 72 |
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET); |
| 73 |
ERROR 28000: Access denied for user 'u1'@'localhost' (using password: NO) |
| 74 |
connect(localhost,u3,haha,test,MASTER_PORT,MASTER_SOCKET); |
| 75 |
ERROR 28000: Access denied for user 'u3'@'localhost' (using password: YES) |
| 76 |
connect(localhost,u2,efgh,test,MASTER_PORT,MASTER_SOCKET); |
| 77 |
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: YES) |
| 78 |
# Check Connection_control_delay_generated - Should be 3 |
| 79 |
SHOW STATUS LIKE 'Connection_control_delay_generated'; |
| 80 |
Variable_name Value |
| 81 |
Connection_control_delay_generated 3 |
| 82 |
|
| 83 |
# ---------------------------------------------------------------------- |
| 84 |
|
| 85 |
# Cleanup |
| 86 |
# Restore original values of conenction_control variables |
| 87 |
SET @@global.connection_control_max_connection_delay= @saved_max_delay; |
| 88 |
SET @@global.connection_control_failed_connections_threshold = @saved_connections_threshold; |
| 89 |
# Remove user accounts created for the test |
| 90 |
DROP USER u1@localhost; |
| 91 |
DROP USER u2@localhost; |
| 92 |
DROP USER u3@localhost; |
| 93 |
# Uninstall connection_control plugin |
| 94 |
UNINSTALL PLUGIN connection_control; |
| 95 |
UNINSTALL PLUGIN connection_control_failed_login_attempts; |
| 96 |
|
| 97 |
# ---------------------------------------------------------------------- |