| 1 |
################################################################################ |
| 2 |
# Base test to verify the basic SSL options functioning and their manipulation |
| 3 |
# |
| 4 |
# Basically, it tests those options that require openssl. |
| 5 |
# |
| 6 |
# The rest of the tests are done in group_replication_ssl_options |
| 7 |
# test file. |
| 8 |
# |
| 9 |
# Test: |
| 10 |
# 0. The test requires two servers: M1 and M2. |
| 11 |
# 1. Set ssl related global variables and do initial setup. |
| 12 |
# 2. Setup the first member (M1) with a recovery user that requires SSL. |
| 13 |
# 3. Add some data and bootstrap start a group on M1. |
| 14 |
# 4. Configure joining member (M2) to use SSL options on recovery. Engage |
| 15 |
# recovery using the CRL options set. Start GR on M2. |
| 16 |
# 5. Check the data is there on M2. |
| 17 |
# 6. Clean up. |
| 18 |
################################################################################ |
| 19 |
|
| 20 |
--source include/have_group_replication_xcom_communication_stack.inc |
| 21 |
--source include/have_group_replication_plugin.inc |
| 22 |
--let $rpl_skip_group_replication_start= 1 |
| 23 |
--source include/group_replication.inc |
| 24 |
|
| 25 |
## |
| 26 |
## Global variables and initial setup |
| 27 |
## |
| 28 |
|
| 29 |
--let $tmpdir_name=`SELECT UUID()` |
| 30 |
--let $tmpdir=$MYSQLTEST_VARDIR/tmp/$tmpdir_name |
| 31 |
--let $CERTDIR_LOCATION=$tmpdir/certs |
| 32 |
--let $CADIR_LOCATION=$tmpdir/certs/cacerts |
| 33 |
--let $CRLDIR_LOCATION=$tmpdir/certs/crldir |
| 34 |
|
| 35 |
--error 0, 1 |
| 36 |
--rmdir $CADIR_LOCATION |
| 37 |
--error 0, 1 |
| 38 |
--rmdir $CERTDIR_LOCATION |
| 39 |
--error 0, 1 |
| 40 |
--rmdir $CRLDIR_LOCATION |
| 41 |
--error 0, 1 |
| 42 |
--rmdir $tmpdir |
| 43 |
|
| 44 |
--mkdir $tmpdir |
| 45 |
--mkdir $CERTDIR_LOCATION |
| 46 |
--mkdir $CADIR_LOCATION |
| 47 |
--mkdir $CRLDIR_LOCATION |
| 48 |
|
| 49 |
--copy_file $MYSQL_TEST_DIR/std_data/crl-ca-cert.pem $CADIR_LOCATION/crl-ca-cert.pem |
| 50 |
--copy_file $MYSQL_TEST_DIR/std_data/crl-client-cert.pem $CERTDIR_LOCATION/crl-client-cert.pem |
| 51 |
--copy_file $MYSQL_TEST_DIR/std_data/crl-client-key.pem $CERTDIR_LOCATION/crl-client-key.pem |
| 52 |
--copy_file $MYSQL_TEST_DIR/std_data/crl-client-revoked.crl $CRLDIR_LOCATION/crl-client-revoked.crl |
| 53 |
|
| 54 |
## |
| 55 |
## End of setup |
| 56 |
## |
| 57 |
|
| 58 |
--echo # |
| 59 |
--echo # Setup the first member with a recovery user that requires SSL |
| 60 |
--echo # |
| 61 |
|
| 62 |
--connection server1 |
| 63 |
--echo server1 |
| 64 |
|
| 65 |
# create a user for replication that requires ssl encryption |
| 66 |
set session sql_log_bin=0; |
| 67 |
CREATE USER 'rec_ssl_user'@'%' REQUIRE SSL; |
| 68 |
GRANT replication slave ON *.* TO 'rec_ssl_user'@'%'; |
| 69 |
set session sql_log_bin=1; |
| 70 |
|
| 71 |
--echo # |
| 72 |
--echo # Add some data and start the first member |
| 73 |
--echo # |
| 74 |
|
| 75 |
CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB; |
| 76 |
INSERT INTO t1 VALUES (1); |
| 77 |
|
| 78 |
--source include/start_and_bootstrap_group_replication.inc |
| 79 |
|
| 80 |
--connection server2 |
| 81 |
--echo server2 |
| 82 |
|
| 83 |
--let $conf_rec_use_ssl= `SELECT @@GLOBAL.group_replication_recovery_use_ssl;` |
| 84 |
|
| 85 |
--let $conf_rec_ssl_ca= `SELECT @@GLOBAL.group_replication_recovery_ssl_ca;` |
| 86 |
--let $conf_rec_ssl_capath= `SELECT @@GLOBAL.group_replication_recovery_ssl_capath;` |
| 87 |
--let $conf_rec_ssl_cert= `SELECT @@GLOBAL.group_replication_recovery_ssl_cert;` |
| 88 |
--let $conf_rec_ssl_key= `SELECT @@GLOBAL.group_replication_recovery_ssl_key;` |
| 89 |
--let $conf_rec_ssl_crl= `SELECT @@GLOBAL.group_replication_recovery_ssl_crl;` |
| 90 |
--let $conf_rec_ssl_crlpath= `SELECT @@GLOBAL.group_replication_recovery_ssl_crlpath;` |
| 91 |
|
| 92 |
## |
| 93 |
## Engage recovery using the CRL options set |
| 94 |
## |
| 95 |
|
| 96 |
SET GLOBAL group_replication_recovery_use_ssl=1; |
| 97 |
|
| 98 |
--replace_result $tmpdir TMPDIR |
| 99 |
--eval SET GLOBAL group_replication_recovery_ssl_ca= '$CADIR_LOCATION/crl-ca-cert.pem' |
| 100 |
|
| 101 |
--replace_result $tmpdir TMPDIR |
| 102 |
--eval SET GLOBAL group_replication_recovery_ssl_capath= '' |
| 103 |
|
| 104 |
--replace_result $tmpdir TMPDIR |
| 105 |
--eval SET GLOBAL group_replication_recovery_ssl_cert= '$CERTDIR_LOCATION/crl-client-cert.pem' |
| 106 |
|
| 107 |
--replace_result $tmpdir TMPDIR |
| 108 |
--eval SET GLOBAL group_replication_recovery_ssl_key= '$CERTDIR_LOCATION/crl-client-key.pem' |
| 109 |
|
| 110 |
--replace_result $tmpdir TMPDIR |
| 111 |
--eval SET GLOBAL group_replication_recovery_ssl_crl= '$CRLDIR_LOCATION/crl-client-revoked.crl' |
| 112 |
|
| 113 |
--replace_result $tmpdir TMPDIR |
| 114 |
--eval SET GLOBAL group_replication_recovery_ssl_crlpath= '$CRLDIR_LOCATION' |
| 115 |
|
| 116 |
--source include/start_group_replication.inc |
| 117 |
|
| 118 |
--echo # |
| 119 |
--echo # Check the data is there |
| 120 |
--echo # |
| 121 |
|
| 122 |
--source include/rpl_sync.inc |
| 123 |
|
| 124 |
--let $assert_text= On the recovered member, the table should exist and have 1 elements; |
| 125 |
--let $assert_cond= [SELECT COUNT(*) FROM t1] = 1; |
| 126 |
--source include/assert.inc |
| 127 |
|
| 128 |
--echo # |
| 129 |
--echo # Clean up |
| 130 |
--echo # |
| 131 |
|
| 132 |
# No need to print this to the result file |
| 133 |
|
| 134 |
--disable_query_log |
| 135 |
--eval SET @@GLOBAL.group_replication_recovery_use_ssl= $conf_rec_use_ssl |
| 136 |
|
| 137 |
--eval SET @@GLOBAL.group_replication_recovery_ssl_ca= "$conf_rec_ssl_ca" |
| 138 |
--eval SET @@GLOBAL.group_replication_recovery_ssl_capath= "$conf_rec_ssl_capath" |
| 139 |
--eval SET @@GLOBAL.group_replication_recovery_ssl_cert= "$conf_rec_ssl_cert" |
| 140 |
--eval SET @@GLOBAL.group_replication_recovery_ssl_key= "$conf_rec_ssl_key" |
| 141 |
--eval SET @@GLOBAL.group_replication_recovery_ssl_crl= "$conf_rec_ssl_crl" |
| 142 |
--eval SET @@GLOBAL.group_replication_recovery_ssl_crlpath= "$conf_rec_ssl_crlpath" |
| 143 |
--enable_query_log |
| 144 |
|
| 145 |
--connection server1 |
| 146 |
--echo server1 |
| 147 |
|
| 148 |
set session sql_log_bin=0; |
| 149 |
DROP USER 'rec_ssl_user'; |
| 150 |
set session sql_log_bin=1; |
| 151 |
|
| 152 |
DROP TABLE t1; |
| 153 |
|
| 154 |
# |
| 155 |
# Finally remove the temporary directory |
| 156 |
# |
| 157 |
--force-rmdir $tmpdir |
| 158 |
|
| 159 |
--source include/group_replication_end.inc |