| 1 |
## UNIX Socket connections |
| 2 |
|
| 3 |
## Preamble |
| 4 |
--source include/not_windows.inc |
| 5 |
--source ../include/have_performance_schema_threads.inc |
| 6 |
--source include/xplugin_preamble.inc |
| 7 |
--source include/xplugin_create_user.inc |
| 8 |
|
| 9 |
call mtr.add_suppression("Maximum number of authentication attempts reached"); |
| 10 |
call mtr.add_suppression("Access denied for user .*"); |
| 11 |
|
| 12 |
CREATE USER [email protected] IDENTIFIED WITH 'mysql_native_password' BY ''; |
| 13 |
CREATE USER [email protected] IDENTIFIED WITH 'mysql_native_password' BY ''; |
| 14 |
CREATE USER user_all@'%' IDENTIFIED WITH 'mysql_native_password' BY ''; |
| 15 |
CREATE USER user_localhost@localhost IDENTIFIED WITH 'mysql_native_password' BY ''; |
| 16 |
CREATE USER user_localhost_8_8_8_8@localhost IDENTIFIED WITH 'mysql_native_password' BY ''; |
| 17 |
CREATE USER [email protected] IDENTIFIED WITH 'mysql_native_password' BY ''; |
| 18 |
CREATE USER user_requires_ssl IDENTIFIED WITH 'mysql_native_password' BY '' REQUIRE SSL; |
| 19 |
|
| 20 |
GRANT ALL ON *.* TO [email protected]; |
| 21 |
GRANT ALL ON *.* TO [email protected]; |
| 22 |
GRANT ALL ON *.* TO user_all@'%'; |
| 23 |
GRANT ALL ON *.* TO user_localhost@localhost; |
| 24 |
GRANT ALL ON *.* TO [email protected]; |
| 25 |
GRANT ALL ON *.* TO user_localhost_8_8_8_8@localhost; |
| 26 |
GRANT ALL ON *.* TO user_requires_ssl; |
| 27 |
|
| 28 |
CREATE TABLE `city` ( |
| 29 |
`ID` int(11) NOT NULL auto_increment, |
| 30 |
`Name` char(35) NOT NULL default '', |
| 31 |
`CountryCode` char(3) NOT NULL default '', |
| 32 |
`District` char(20) NOT NULL default '', |
| 33 |
`Population` int(11) NOT NULL default '0', |
| 34 |
PRIMARY KEY (`ID`) |
| 35 |
); |
| 36 |
INSERT INTO `city` VALUES (1,'Kabul','AFG','Kabol',1780); |
| 37 |
INSERT INTO `city` VALUES (2,'Qandahar','AFG','Qandahar',237); |
| 38 |
INSERT INTO `city` VALUES (3,'Herat','AFG','Herat',186); |
| 39 |
INSERT INTO `city` VALUES (4,'Mazar-e-Sharif','AFG','Balkh',127); |
| 40 |
INSERT INTO `city` VALUES (5,'Amsterdam','NLD','Noord-Holland',731); |
| 41 |
INSERT INTO `city` VALUES (6,'Rotterdam','NLD','Zuid-Holland',593); |
| 42 |
|
| 43 |
call mtr.add_suppression("Plugin mysqlx reported: '1.1: Unsuccessful login attempt: Invalid user or password'"); |
| 44 |
call mtr.add_suppression("Plugin mysqlx reported: '2.1: Unsuccessful login attempt: Invalid user or password'"); |
| 45 |
|
| 46 |
## Test starts here |
| 47 |
--write_file $MYSQL_TMP_DIR/basic_connection.xpl |
| 48 |
## Test data |
| 49 |
|
| 50 |
# Test plan 1.1.4.1 |
| 51 |
Mysqlx.Sql.StmtExecute { |
| 52 |
stmt: "ping" |
| 53 |
namespace: "mysqlx" |
| 54 |
} |
| 55 |
|
| 56 |
## expect Mysqlx.Sql.StmtExecuteOk |
| 57 |
-->recvresult |
| 58 |
|
| 59 |
-->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query' and PROCESSLIST_ID=connection_id(); |
| 60 |
-->recvresult |
| 61 |
|
| 62 |
Mysqlx.Crud.Find { |
| 63 |
collection { |
| 64 |
name: "city" |
| 65 |
schema: "test" |
| 66 |
} |
| 67 |
data_model: TABLE |
| 68 |
criteria { |
| 69 |
type: OPERATOR |
| 70 |
operator { |
| 71 |
name: "<" |
| 72 |
param { |
| 73 |
type: IDENT |
| 74 |
identifier { |
| 75 |
name: "Population" |
| 76 |
} |
| 77 |
} |
| 78 |
param { |
| 79 |
type: LITERAL |
| 80 |
literal { |
| 81 |
type: V_SINT |
| 82 |
v_signed_int: 250 |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
} |
| 87 |
} |
| 88 |
-->recvresult |
| 89 |
|
| 90 |
EOF |
| 91 |
|
| 92 |
# Server was started with UNIX socket support |
| 93 |
# Check if UNIX socket file and lock file exist |
| 94 |
--file_exists $MASTER_X_MYSOCK |
| 95 |
--file_exists $MASTER_X_MYSOCK.lock |
| 96 |
|
| 97 |
--exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR --socket=$MASTER_X_MYSOCK -uuser_127_0_0_1 --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl 2>&1 |
| 98 |
|
| 99 |
--exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR --socket=$MASTER_X_MYSOCK -uuser_8_8_8_8 --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl 2>&1 |
| 100 |
|
| 101 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_all --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl 2>&1 |
| 102 |
|
| 103 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_localhost --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl 2>&1 |
| 104 |
|
| 105 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_localhost_8_8_8_8 --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl 2>&1 |
| 106 |
|
| 107 |
--exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR --socket=$MASTER_X_MYSOCK -uuser_requires_ssl --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl 2>&1 |
| 108 |
|
| 109 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_requires_ssl --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl --ssl-mode=REQUIRED 2>&1 |
| 110 |
|
| 111 |
--echo Check if mysqlx_socket has correct value |
| 112 |
--disable_query_log |
| 113 |
--eval select @@mysqlx_socket like "$MASTER_X_MYSOCK" as 'result'; |
| 114 |
--enable_query_log |
| 115 |
|
| 116 |
--write_file $MYSQL_TMP_DIR/parallel_connections.xpl |
| 117 |
## Test data |
| 118 |
|
| 119 |
#Ensure that each of following uses UNIX Socket |
| 120 |
-->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query' and PROCESSLIST_ID=connection_id(); |
| 121 |
-->recvresult |
| 122 |
|
| 123 |
-->newsession session2 x_root |
| 124 |
-->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query' and PROCESSLIST_ID=connection_id(); |
| 125 |
-->recvresult |
| 126 |
|
| 127 |
-->newsession session3 x_root |
| 128 |
-->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query' and PROCESSLIST_ID=connection_id(); |
| 129 |
-->recvresult |
| 130 |
|
| 131 |
#Do query in parallel |
| 132 |
-->setsession session3 |
| 133 |
-->stmtsql select '3_1'; |
| 134 |
-->setsession session2 |
| 135 |
-->stmtsql select '2_1'; |
| 136 |
-->setsession |
| 137 |
-->stmtsql select '1_1'; |
| 138 |
|
| 139 |
-->setsession session2 |
| 140 |
#-->stmtsql select '2_1'; |
| 141 |
-->recvresult |
| 142 |
|
| 143 |
-->setsession session3 |
| 144 |
#-->stmtsql select '3_1'; |
| 145 |
-->recvresult |
| 146 |
|
| 147 |
-->setsession |
| 148 |
#-->stmtsql select '1_1'; |
| 149 |
-->recvresult |
| 150 |
|
| 151 |
EOF |
| 152 |
|
| 153 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/parallel_connections.xpl 2>&1 |
| 154 |
|
| 155 |
|
| 156 |
--write_file $MYSQL_TMP_DIR/plain_connection.xpl |
| 157 |
-->import connection.macro |
| 158 |
-->callmacro Verify_its_xprotocol_connection |
| 159 |
|
| 160 |
-->echo # |
| 161 |
-->echo # Match capabilities with the result file, |
| 162 |
-->echo # must contain PLAIN and MYSQL41 |
| 163 |
-->echo # |
| 164 |
Mysqlx.Connection.CapabilitiesGet { |
| 165 |
} |
| 166 |
-->recv capabilities[1].value.array |
| 167 |
|
| 168 |
-->echo # |
| 169 |
-->echo # Do plain authentication (must be available) |
| 170 |
-->echo # |
| 171 |
Mysqlx.Session.AuthenticateStart { |
| 172 |
mech_name: "PLAIN" |
| 173 |
auth_data: "\0x_root\0" |
| 174 |
} |
| 175 |
-->recvuntil Mysqlx.Session.AuthenticateOk do_not_show_intermediate |
| 176 |
EOF |
| 177 |
|
| 178 |
--exec $MYSQLXTEST -q -n --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/plain_connection.xpl 2>&1 |
| 179 |
|
| 180 |
|
| 181 |
--echo # |
| 182 |
--echo # Lets confirm that user can connect through UNIX socket connection is secure one |
| 183 |
--echo # |
| 184 |
SET GLOBAL require_secure_transport:=1; |
| 185 |
--exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/basic_connection.xpl 2>&1 |
| 186 |
--exec $MYSQLXTEST -q -n --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/plain_connection.xpl 2>&1 |
| 187 |
SET GLOBAL require_secure_transport:=0; |
| 188 |
|
| 189 |
# |
| 190 |
--write_file $MYSQL_TMP_DIR/check_unixsocket.xpl |
| 191 |
-->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query' and PROCESSLIST_ID=connection_id(); |
| 192 |
-->recvresult |
| 193 |
EOF |
| 194 |
|
| 195 |
# Command line option --mysqlx-socket |
| 196 |
--replace_regex /mysqlx-socket=.*sock/mysqlx-socket=SOCKET/ |
| 197 |
let $restart_parameters = restart: --mysqlx-socket=$MYSQL_TMP_DIR/valid_mysqlx.sock; |
| 198 |
--source include/restart_mysqld.inc |
| 199 |
|
| 200 |
# MySQL Server was started with new UNIX socket file for X Plugin |
| 201 |
# Check if old UNIX socket file was removed and lockfile |
| 202 |
--error 1 |
| 203 |
--file_exists $MASTER_X_MYSOCK |
| 204 |
--error 1 |
| 205 |
--file_exists $MASTER_X_MYSOCK.lock |
| 206 |
|
| 207 |
# Check if the X Plugin is accessible through new file |
| 208 |
--exec $MYSQLXTEST --socket=$MYSQL_TMP_DIR/valid_mysqlx.sock -ux_root --password='' --file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1 |
| 209 |
|
| 210 |
# Connect through unixsocket using PLAIN authentication |
| 211 |
--exec $MYSQLXTEST --plain-auth --socket=$MYSQL_TMP_DIR/valid_mysqlx.sock -uroot --password='' --file=$MYSQL_TMP_DIR/check_unixsocket.xpl 2>&1 |
| 212 |
|
| 213 |
## Cleanup |
| 214 |
--let $restart_parameters = restart: |
| 215 |
--source include/restart_mysqld.inc |
| 216 |
|
| 217 |
DROP TABLE `city`; |
| 218 |
|
| 219 |
DROP USER [email protected]; |
| 220 |
DROP USER [email protected]; |
| 221 |
DROP USER user_all@'%'; |
| 222 |
DROP USER user_localhost@localhost; |
| 223 |
DROP USER user_localhost_8_8_8_8@localhost; |
| 224 |
DROP USER [email protected]; |
| 225 |
DROP USER user_requires_ssl; |
| 226 |
|
| 227 |
--source ../include/xplugin_cleanup.inc |