221 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
			
		
		
	
	
			221 lines
		
	
	
		
			7.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
| ## UNIX Socket connections
 | |
| 
 | |
| ## Preamble
 | |
| --source include/not_windows.inc
 | |
| --source ../include/have_performance_schema_threads.inc
 | |
| --source include/xplugin_preamble.inc
 | |
| --source include/xplugin_create_user.inc
 | |
| 
 | |
| call mtr.add_suppression("Maximum number of authentication attempts reached");
 | |
| call mtr.add_suppression("Access denied for user .*");
 | |
| 
 | |
| CREATE USER user_127_0_0_1@127.0.0.1 IDENTIFIED WITH 'mysql_native_password' BY '';
 | |
| CREATE USER user_8_8_8_8@8.8.8.8 IDENTIFIED WITH 'mysql_native_password' BY '';
 | |
| CREATE USER user_all@'%' IDENTIFIED WITH 'mysql_native_password' BY '';
 | |
| CREATE USER user_localhost@localhost IDENTIFIED WITH 'mysql_native_password' BY '';
 | |
| CREATE USER user_localhost_8_8_8_8@localhost IDENTIFIED WITH 'mysql_native_password' BY '';
 | |
| CREATE USER user_localhost_8_8_8_8@8.8.8.8 IDENTIFIED WITH 'mysql_native_password' BY '';
 | |
| CREATE USER user_requires_ssl IDENTIFIED WITH 'mysql_native_password' BY '' REQUIRE SSL;
 | |
| 
 | |
| GRANT ALL ON *.* TO user_127_0_0_1@127.0.0.1;
 | |
| GRANT ALL ON *.* TO user_8_8_8_8@8.8.8.8;
 | |
| GRANT ALL ON *.* TO user_all@'%';
 | |
| GRANT ALL ON *.* TO user_localhost@localhost;
 | |
| GRANT ALL ON *.* TO user_localhost_8_8_8_8@8.8.8.8;
 | |
| GRANT ALL ON *.* TO user_localhost_8_8_8_8@localhost;
 | |
| GRANT ALL ON *.* TO user_requires_ssl;
 | |
| 
 | |
| CREATE TABLE `city` (
 | |
|   `ID` int(11) NOT NULL auto_increment,
 | |
|   `Name` char(35) NOT NULL default '',
 | |
|   `CountryCode` char(3) NOT NULL default '',
 | |
|   `District` char(20) NOT NULL default '',
 | |
|   `Population` int(11) NOT NULL default '0',
 | |
|   PRIMARY KEY  (`ID`)
 | |
| );
 | |
| INSERT INTO `city` VALUES (1,'Kabul','AFG','Kabol',1780);
 | |
| INSERT INTO `city` VALUES (2,'Qandahar','AFG','Qandahar',237);
 | |
| INSERT INTO `city` VALUES (3,'Herat','AFG','Herat',186);
 | |
| INSERT INTO `city` VALUES (4,'Mazar-e-Sharif','AFG','Balkh',127);
 | |
| INSERT INTO `city` VALUES (5,'Amsterdam','NLD','Noord-Holland',731);
 | |
| INSERT INTO `city` VALUES (6,'Rotterdam','NLD','Zuid-Holland',593);
 | |
| 
 | |
| call mtr.add_suppression("Plugin mysqlx reported: '1.1: Unsuccessful login attempt: Invalid user or password'");
 | |
| call mtr.add_suppression("Plugin mysqlx reported: '2.1: Unsuccessful login attempt: Invalid user or password'");
 | |
| 
 | |
| ## Test starts here
 | |
| --write_file $MYSQL_TMP_DIR/basic_connection.tmp
 | |
| ## Test data
 | |
| 
 | |
| # Test plan 1.1.4.1
 | |
| Mysqlx.Sql.StmtExecute {
 | |
|   stmt: "ping"
 | |
|   namespace: "mysqlx"
 | |
| }
 | |
| 
 | |
| ## expect Mysqlx.Sql.StmtExecuteOk
 | |
| -->recvresult
 | |
| 
 | |
| -->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query';
 | |
| -->recvresult
 | |
| 
 | |
| Mysqlx.Crud.Find {
 | |
|   collection {
 | |
|     name: "city"
 | |
|     schema: "test"
 | |
|   }
 | |
|   data_model: TABLE
 | |
|   criteria {
 | |
|     type: OPERATOR
 | |
|     operator {
 | |
|       name: "<"
 | |
|       param {
 | |
|         type: IDENT
 | |
|         identifier {
 | |
|           name: "Population"
 | |
|         }
 | |
|       }
 | |
|       param {
 | |
|         type: LITERAL
 | |
|         literal {
 | |
|           type: V_SINT
 | |
|           v_signed_int: 250
 | |
|         }
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| }
 | |
| -->recvresult
 | |
| 
 | |
| EOF
 | |
| 
 | |
| # Server was started with UNIX socket support
 | |
| # Check if UNIX socket file and lock file exist
 | |
| --file_exists $MASTER_X_MYSOCK
 | |
| --file_exists $MASTER_X_MYSOCK.lock
 | |
| 
 | |
| --exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR --socket=$MASTER_X_MYSOCK -uuser_127_0_0_1 --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp 2>&1
 | |
| 
 | |
| --exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR --socket=$MASTER_X_MYSOCK -uuser_8_8_8_8 --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp 2>&1
 | |
| 
 | |
| --exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_all --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp 2>&1
 | |
| 
 | |
| --exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_localhost --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp 2>&1
 | |
| 
 | |
| --exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_localhost_8_8_8_8 --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp 2>&1
 | |
| 
 | |
| --exec $MYSQLXTEST --expect-error ER_ACCESS_DENIED_ERROR --socket=$MASTER_X_MYSOCK -uuser_requires_ssl --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp 2>&1
 | |
| 
 | |
| --exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -uuser_requires_ssl --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp --ssl-mode=REQUIRED 2>&1
 | |
| 
 | |
| --echo Check if mysqlx_socket has correct value
 | |
| --disable_query_log
 | |
| --eval select @@mysqlx_socket like "$MASTER_X_MYSOCK" as 'result';
 | |
| --enable_query_log
 | |
| 
 | |
| --write_file $MYSQL_TMP_DIR/parallel_connections.tmp
 | |
| ## Test data
 | |
| 
 | |
| #Ensure that each of following uses UNIX Socket
 | |
| -->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query';
 | |
| -->recvresult
 | |
| 
 | |
| -->newsession session2	x_root
 | |
| -->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query';
 | |
| -->recvresult
 | |
| 
 | |
| -->newsession session3	x_root
 | |
| -->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query';
 | |
| -->recvresult
 | |
| 
 | |
| #Do query in parallel
 | |
| -->setsession session3
 | |
| -->stmtsql select '3_1';
 | |
| -->setsession session2
 | |
| -->stmtsql select '2_1';
 | |
| -->setsession
 | |
| -->stmtsql select '1_1';
 | |
| 
 | |
| -->setsession session2
 | |
| #-->stmtsql select '2_1';
 | |
| -->recvresult
 | |
| 
 | |
| -->setsession session3
 | |
| #-->stmtsql select '3_1';
 | |
| -->recvresult
 | |
| 
 | |
| -->setsession
 | |
| #-->stmtsql select '1_1';
 | |
| -->recvresult
 | |
| 
 | |
| EOF
 | |
| 
 | |
| --exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/parallel_connections.tmp 2>&1
 | |
| 
 | |
| 
 | |
| --write_file $MYSQL_TMP_DIR/plain_connection.tmp
 | |
| -->import connection.macro
 | |
| -->callmacro Verify_its_xprotocol_connection
 | |
| 
 | |
| -->echo #
 | |
| -->echo # Match capabilities with the result file,
 | |
| -->echo # must contain PLAIN and MYSQL41
 | |
| -->echo #
 | |
| Mysqlx.Connection.CapabilitiesGet {
 | |
| }
 | |
| -->recv capabilities[1].value.array
 | |
| 
 | |
| -->echo #
 | |
| -->echo # Do plain authentication (must be available)
 | |
| -->echo #
 | |
| Mysqlx.Session.AuthenticateStart {
 | |
|     mech_name: "PLAIN"
 | |
|     auth_data: "\0x_root\0"
 | |
| }
 | |
| -->recvuntil Mysqlx.Session.AuthenticateOk do_not_show_intermediate
 | |
| EOF
 | |
| 
 | |
| --exec $MYSQLXTEST -q -n --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/plain_connection.tmp 2>&1
 | |
| 
 | |
| 
 | |
| --echo #
 | |
| --echo # Lets confirm that user can connect through UNIX socket connection is secure one
 | |
| --echo #
 | |
| SET GLOBAL require_secure_transport:=1;
 | |
| --exec $MYSQLXTEST --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/basic_connection.tmp 2>&1
 | |
| --exec $MYSQLXTEST -q -n --socket=$MASTER_X_MYSOCK -ux_root --password='' --file=$MYSQL_TMP_DIR/plain_connection.tmp 2>&1
 | |
| SET GLOBAL require_secure_transport:=0;
 | |
| 
 | |
| #
 | |
| --write_file $MYSQL_TMP_DIR/check_unixsocket.tmp
 | |
| -->stmtsql SELECT CONNECTION_TYPE from performance_schema.threads where processlist_command='Query';
 | |
| -->recvresult
 | |
| EOF
 | |
| 
 | |
| # Command line option --mysqlx-socket
 | |
| --replace_regex /mysqlx-socket=.*sock/mysqlx-socket=SOCKET/
 | |
| let $restart_parameters = restart: --mysqlx-socket=$MYSQL_TMP_DIR/valid_mysqlx.sock;
 | |
| --source include/restart_mysqld.inc
 | |
| 
 | |
| # MySQL Server was started with new UNIX socket file for X Plugin
 | |
| # Check if old UNIX socket file was removed and lockfile
 | |
| --error 1
 | |
| --file_exists $MASTER_X_MYSOCK
 | |
| --error 1
 | |
| --file_exists $MASTER_X_MYSOCK.lock
 | |
| 
 | |
| # Check if the X Plugin is accessible through new file
 | |
| --exec $MYSQLXTEST --socket=$MYSQL_TMP_DIR/valid_mysqlx.sock -ux_root --password='' --file=$MYSQL_TMP_DIR/check_unixsocket.tmp 2>&1
 | |
| 
 | |
| # Connect through unixsocket using PLAIN authentication
 | |
| --exec $MYSQLXTEST --plain-auth --socket=$MYSQL_TMP_DIR/valid_mysqlx.sock -uroot --password='' --file=$MYSQL_TMP_DIR/check_unixsocket.tmp 2>&1
 | |
| 
 | |
| ## Cleanup
 | |
| DROP TABLE `city`;
 | |
| DROP USER user_127_0_0_1@127.0.0.1,user_8_8_8_8@8.8.8.8, user_all@'%', user_localhost@localhost, user_localhost_8_8_8_8@8.8.8.8, user_localhost_8_8_8_8@localhost;
 | |
| --remove_file $MYSQL_TMP_DIR/basic_connection.tmp
 | |
| --remove_file $MYSQL_TMP_DIR/parallel_connections.tmp
 | |
| --remove_file $MYSQL_TMP_DIR/plain_connection.tmp
 | |
| --remove_file $MYSQL_TMP_DIR/check_unixsocket.tmp
 | |
| --source include/xplugin_drop_user.inc
 |