Debian Codegraph @

mysql-test/suite/auth_sec/t/require_secure_transport_windows.test

raw
1 --source include/windows.inc
2
3 let $shm_name= query_get_value("SHOW GLOBAL VARIABLES LIKE 'shared_memory_base_name'", Value, 1);
4
5 CREATE USER 'user_tcp'@'127.0.0.1';
6 GRANT ALL PRIVILEGES ON *.* TO 'user_tcp'@'127.0.0.1';
7 CREATE USER 'user_ssl'@'127.0.0.1';
8 GRANT ALL PRIVILEGES ON *.* TO 'user_ssl'@'127.0.0.1';
9 CREATE USER 'user_requiressl'@'localhost' REQUIRE SSL;
10 GRANT ALL PRIVILEGES ON *.* TO 'user_requiressl'@'localhost';
11
12 --disable_query_log
13 connect(pipe_con1,localhost,root,,,,,PIPE);
14 connection default;
15 disconnect pipe_con1;
16 connect(memory_con,localhost,root,,,,$shm_name,SHM);
17 connection default;
18 disconnect memory_con;
19 --enable_query_log
20
21 --echo
22 --echo # Connection type testing for TCP/IP protocol
23 --echo
24 --exec $MYSQL --host=127.0.0.1 --user=user_tcp --ssl-mode=DISABLED --protocol=TCP -e "select 1;"
25 #
26 --echo # Testing TCP/IP connections over SSL/TLS
27 #
28 --exec $MYSQL --host=127.0.0.1 --user=user_ssl --protocol=TCP --ssl-mode=REQUIRED -e "select 2;"
29 --echo
30 --echo # Testing TCP/IP connections over SSL/TLS having user with REQUIRE SSL clause
31 #
32 --exec $MYSQL --host=127.0.0.1 --user=user_requiressl --protocol=TCP -e "select 2.5;"
33 --echo
34 SET @@global.require_secure_transport = ON;
35
36 --disable_query_log
37 --Error ER_SECURE_TRANSPORT_REQUIRED
38 connect(pipe_con2,localhost,root,,,,,PIPE);
39 connection default;
40 connect(memory_con1,localhost,root,,,,$shm_name,SHM);
41 connection default;
42 disconnect memory_con1;
43 --enable_query_log
44
45 --echo
46 --echo # Connection type testing for TCP/IP protocol, secure transport required.
47 --echo
48 --error 1
49 --exec $MYSQL --host=127.0.0.1 --user=user_tcp --ssl-mode=DISABLED --protocol=TCP -e "select 3;"
50 #
51 --echo # Testing TCP/IP connections over SSL/TLS, secure transport required.
52 #
53 --exec $MYSQL --host=127.0.0.1 --user=user_ssl --protocol=TCP --ssl-mode=REQUIRED -e "select 4;"
54 --echo
55 #
56 --echo # Testing TCP/IP connections over SSL/TLS with an user created with REQUIRE SSL
57 #
58 --exec $MYSQL --host=127.0.0.1 --user=user_requiressl --protocol=TCP -e "select 4.5;"
59 --echo
60
61 --echo # Shutdown server
62 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
63 --shutdown_server
64 --source include/wait_until_disconnected.inc
65
66 --echo # Ensure that server does not start and aborts when there is no
67 --echo # SHM support, --require-secure-transport=on and ssl is disabled
68 let server_log= $MYSQLTEST_VARDIR/log/mysqld.1.err;
69 # $server_log has to be processed by include/search_pattern.inc which
70 # contains Perl code requiring that the environment variable SEARCH_FILE points
71 # to this file.
72 let SEARCH_FILE= $server_log;
73 --error 1
74 --exec $MYSQLD_CMD --loose-enable-named-pipe --loose-shared-memory=0 --require-secure-transport=on --skip-ssl --loose-console > $server_log 2>&1
75 let SEARCH_PATTERN= Server is started with --require-secure-transport=ON but no secure transports;
76 --source include/search_pattern.inc
77 let SEARCH_PATTERN= Aborting;
78 --source include/search_pattern.inc
79
80 --echo # Now start server normally without ssl support, with MEM and require-secure-transport=on
81 --exec echo "restart:--loose-enable-named-pipe --loose-shared-memory=1 --shared_memory_base_name=server_inst_sh_mem --require-secure-transport=on --skip-ssl" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
82 --enable_reconnect
83 --source include/wait_until_connected_again.inc
84
85 --echo # Connection type testing for TCP/IP protocol, secure transport required, should fail
86 --error 1
87 --exec $MYSQL --host=127.0.0.1 --user=user_tcp --ssl-mode=DISABLED --protocol=TCP -e "select 5;"
88
89 --disable_query_log
90 --Error ER_SECURE_TRANSPORT_REQUIRED
91 connect(pipe_con3,localhost,root,,,,,PIPE);
92 connect(memory_con2,localhost,root,,,,server_inst_sh_mem,SHM);
93 SET @@global.require_secure_transport = Off;
94 disconnect memory_con2;
95 --enable_query_log
96
97 connection default;
98 --echo # Rebooting to start without ssl support and require-secure-transport=off, disabled SHM
99 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
100 --shutdown_server
101 --source include/wait_until_disconnected.inc
102 --exec echo "restart:--loose-enable-named-pipe --loose-shared-memory=0 --require-secure-transport=off --skip-ssl" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
103 --enable_reconnect
104 --source include/wait_until_connected_again.inc
105
106 --echo # Change the dynamic variable from OFF to ON. it should throw error
107 --error ER_NO_SECURE_TRANSPORTS_CONFIGURED
108 SET @@global.require_secure_transport = ON;
109
110 --echo # TCP/IP connection should succeed
111 --exec $MYSQL --host=127.0.0.1 --user=user_tcp --protocol=TCP -e "select 6"
112 connect(pipe_con4,localhost,root,,,,,PIPE);
113 disconnect pipe_con4;
114 --disable_query_log
115 --replace_regex /client could not create request event \([0-9]+\)/client could not create request event (Errcode)/
116 --error 2038
117 connect(memory_con3,localhost,root,,,,$shm_name,SHM);
118 --enable_query_log
119
120 connection default;
121 --echo # Rebooting to start ssl support and require-secure-transport=off, disabled with SHM
122 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
123 --shutdown_server
124 --source include/wait_until_disconnected.inc
125 --exec echo "restart:--loose-enable-named-pipe --loose-shared-memory=0 --require-secure-transport=off" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
126 --enable_reconnect
127 --source include/wait_until_connected_again.inc
128
129 --echo # Change the dynamic variable from OFF to ON. it should not throw error
130 SET @@global.require_secure_transport = ON;
131
132 --echo # Connection type testing for TCP/IP protocol, secure transport required, should fail.
133 --error 1
134 --exec $MYSQL --host=127.0.0.1 --user=user_tcp --ssl-mode=DISABLED --protocol=TCP -e "select 7;"
135
136 --echo #Cleanup
137 connection default;
138 DROP USER 'user_tcp'@'127.0.0.1', 'user_ssl'@'127.0.0.1', 'user_requiressl'@'localhost';
139 SET @@global.require_secure_transport = OFF;
140
141 --let $restart_parameters = restart:
142 --source include/restart_mysqld_no_echo.inc
143
144