Debian Codegraph @

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

raw
1 --source include/not_windows.inc
2
3
4 CREATE USER 'user_tcp'@'127.0.0.1';
5 GRANT ALL PRIVILEGES ON *.* TO 'user_tcp'@'127.0.0.1';
6 CREATE USER 'user_ssl'@'127.0.0.1';
7 GRANT ALL PRIVILEGES ON *.* TO 'user_ssl'@'127.0.0.1';
8 CREATE USER 'user_requiressl'@'localhost' REQUIRE SSL;
9 GRANT ALL PRIVILEGES ON *.* TO 'user_requiressl'@'localhost';
10
11 --disable_query_log
12 connect(sock_con1,localhost,root,,,,,);
13 connection default;
14 disconnect sock_con1;
15
16 --echo # Socket connection is not possible for user
17 --echo # created with REQUIRE SSL unless we pass SSL explicitly
18 --error 1045
19 connect(sock_con2,localhost,user_requiressl,,,,,);
20
21 connect(sock_con3,localhost,user_requiressl,,,,,SSL);
22 --enable_query_log
23
24
25 --echo
26 --echo # Connection type testing for TCP/IP protocol
27 --echo
28 --exec $MYSQL --host=127.0.0.1 --user=user_tcp --ssl-mode=DISABLED --protocol=TCP -e "select 1;"
29 #
30 --echo # Testing TCP/IP connections over SSL/TLS
31 #
32 --exec $MYSQL --host=127.0.0.1 --user=user_ssl --protocol=TCP --ssl-mode=REQUIRED -e "select 2;"
33 --echo
34 --echo # Testing TCP/IP connections over SSL/TLS having user with REQUIRE SSL clause
35 #
36 --exec $MYSQL --host=127.0.0.1 --user=user_requiressl --protocol=TCP -e "select 2.5;"
37 --echo
38
39 SET @@global.require_secure_transport = ON;
40
41 --disable_query_log
42 connect(sock_con4,localhost,root,,,,,);
43 connection default;
44 disconnect sock_con4;
45 --enable_query_log
46
47 --echo
48 --echo # Connection type testing for TCP/IP protocol, secure transport required.
49 --echo
50 --error 1
51 --exec $MYSQL --host=127.0.0.1 --user=user_tcp --ssl-mode=DISABLED --protocol=TCP -e "select 3;"
52 #
53 --echo # Testing TCP/IP connections over SSL/TLS, secure transport required.
54 #
55 --exec $MYSQL --host=127.0.0.1 --user=user_ssl --protocol=TCP --ssl-mode=REQUIRED -e "select 4;"
56 --echo
57 #
58 --echo # Testing TCP/IP connections over SSL/TLS with an user created with REQUIRE SSL
59 #
60 --exec $MYSQL --host=127.0.0.1 --user=user_requiressl --protocol=TCP -e "select 4.5;"
61 --echo
62
63 --echo # Rebooting to start without ssl and require-secure-transport=on
64
65 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
66 --shutdown_server
67 --source include/wait_until_disconnected.inc
68
69 --exec echo "restart:--skip-ssl --require-secure-transport=on" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
70 --enable_reconnect
71 --source include/wait_until_connected_again.inc
72
73 --echo # Insecure connection is not possible with TCP
74 --error 1
75 --exec $MYSQL --host=127.0.0.1 --user=user_ssl --protocol=TCP -e "select 6;"
76
77 --error 1
78 --exec $MYSQL --host=127.0.0.1 --user=user_requiressl --protocol=TCP -e "select 7;"
79
80 --echo # Socket connection is possible as it is treated as secure
81 --disable_query_log
82 connect(sock_con5,localhost,root,,,,,);
83 connection default;
84 disconnect sock_con5;
85
86 --echo # Even socket connection is not possible for users created with REQUIRE SSL clause
87 --error 1045
88 connect(sock_con6,localhost,user_requiressl,,,,,);
89 connection default;
90
91 --error 2026
92 connect(sock_con7,localhost,user_requiressl,,,,,SSL);
93 connection default;
94 --enable_query_log
95
96 --echo #Cleanup
97 DROP USER 'user_tcp'@'127.0.0.1', 'user_ssl'@'127.0.0.1', 'user_requiressl'@'localhost';
98 SET @@global.require_secure_transport = OFF;
99
100
101 # Restore default settings in opt file and clean up
102 --let $restart_parameters = restart:
103 --source include/restart_mysqld.inc