You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Travis and Appveyor integration:
- added travis support - fixed appveyor settings - fixed some warnings (gcc 4.8) - removed sleep commands - disabled failing tests when running against MySQL server, mostly related to stored procedures and binary protocol - reverted fix for MDEV_10361 Still open: TLS/SSL appveyor tests, since .msi installation on appveyor doesn't provide certificates.
This commit is contained in:
30
.travis.yml
Normal file
30
.travis.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
sudo: true
|
||||
language: c
|
||||
services: docker
|
||||
addons:
|
||||
hosts:
|
||||
- mariadb.example.com
|
||||
|
||||
before_script:
|
||||
# Disable services enabled by default
|
||||
- sudo /etc/init.d/mysql stop
|
||||
|
||||
|
||||
before_install:
|
||||
- chmod +x .travis/script.sh
|
||||
- chmod +x .travis/gen-ssl.sh
|
||||
- export PROJ_PATH=`pwd`
|
||||
- export ENTRYPOINT=$PROJ_PATH/.travis/sql
|
||||
- mkdir tmp
|
||||
- .travis/gen-ssl.sh mariadb.example.com tmp
|
||||
- export SSLCERT=$PROJ_PATH/tmp
|
||||
|
||||
env:
|
||||
- DB=mysql:5.7
|
||||
- DB=mariadb:5.5
|
||||
- DB=mariadb:10.0
|
||||
- DB=mariadb:10.1
|
||||
- DB=mariadb:10.2
|
||||
- DB=mariadb:10.3
|
||||
|
||||
script: .travis/script.sh
|
13
.travis/docker-compose.yml
Normal file
13
.travis/docker-compose.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
version: '2'
|
||||
services:
|
||||
db:
|
||||
image: $DB
|
||||
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --ssl-ca=/etc/sslcert/ca.crt --ssl-cert=/etc/sslcert/server.crt --ssl-key=/etc/sslcert/server.key --bind-address=0.0.0.0
|
||||
ports:
|
||||
- 3305:3306
|
||||
volumes:
|
||||
- $SSLCERT:/etc/sslcert
|
||||
- $ENTRYPOINT:/docker-entrypoint-initdb.d
|
||||
environment:
|
||||
MYSQL_DATABASE: test
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
155
.travis/gen-ssl.sh
Normal file
155
.travis/gen-ssl.sh
Normal file
@@ -0,0 +1,155 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
log () {
|
||||
echo "$@" 1>&2
|
||||
}
|
||||
|
||||
print_error () {
|
||||
echo "$@" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
print_usage () {
|
||||
print_error "Usage: gen-ssl-cert-key <fqdn> <output-dir>"
|
||||
}
|
||||
|
||||
gen_cert_subject () {
|
||||
local fqdn="$1"
|
||||
[[ "${fqdn}" != "" ]] || print_error "FQDN cannot be blank"
|
||||
echo "/C=/ST=/O=/localityName=/CN=${fqdn}/organizationalUnitName=/emailAddress=/"
|
||||
}
|
||||
|
||||
main () {
|
||||
local fqdn="$1"
|
||||
local sslDir="$2"
|
||||
[[ "${fqdn}" != "" ]] || print_usage
|
||||
[[ -d "${sslDir}" ]] || print_error "Directory does not exist: ${sslDir}"
|
||||
|
||||
local caCertFile="${sslDir}/ca.crt"
|
||||
local caKeyFile="${sslDir}/ca.key"
|
||||
local certFile="${sslDir}/server.crt"
|
||||
local certShaFile="${sslDir}/server-cert.sha1"
|
||||
local keyFile="${sslDir}/server.key"
|
||||
local csrFile=$(mktemp)
|
||||
local clientCertFile="${sslDir}/client-cert.pem"
|
||||
local clientKeyFile="${sslDir}/client-key.pem"
|
||||
local clientEncryptedKeyFile="${sslDir}/client-key-enc.pem"
|
||||
local clientKeystoreFile="${sslDir}/client-keystore.jks"
|
||||
local fullClientKeystoreFile="${sslDir}/fullclient-keystore.jks"
|
||||
local tmpKeystoreFile=$(mktemp)
|
||||
local pcks12FullKeystoreFile="${sslDir}/fullclient-keystore.p12"
|
||||
local clientReqFile=$(mktemp)
|
||||
|
||||
log "Generating CA key"
|
||||
openssl genrsa -out "${caKeyFile}" 2048
|
||||
|
||||
log "Generating CA certificate"
|
||||
openssl req \
|
||||
-sha1 \
|
||||
-new \
|
||||
-x509 \
|
||||
-nodes \
|
||||
-days 3650 \
|
||||
-subj "$(gen_cert_subject ca.example.com)" \
|
||||
-key "${caKeyFile}" \
|
||||
-out "${caCertFile}"
|
||||
|
||||
log "Generating private key"
|
||||
openssl genrsa -out "${keyFile}" 2048
|
||||
|
||||
log "Generating certificate signing request"
|
||||
openssl req \
|
||||
-new \
|
||||
-batch \
|
||||
-sha1 \
|
||||
-subj "$(gen_cert_subject "$fqdn")" \
|
||||
-set_serial 01 \
|
||||
-key "${keyFile}" \
|
||||
-out "${csrFile}" \
|
||||
-nodes
|
||||
|
||||
log "Generating X509 certificate"
|
||||
openssl x509 \
|
||||
-req \
|
||||
-sha1 \
|
||||
-set_serial 01 \
|
||||
-CA "${caCertFile}" \
|
||||
-CAkey "${caKeyFile}" \
|
||||
-days 3650 \
|
||||
-in "${csrFile}" \
|
||||
-signkey "${keyFile}" \
|
||||
-out "${certFile}"
|
||||
|
||||
log "Generating client certificate"
|
||||
openssl req \
|
||||
-batch \
|
||||
-newkey rsa:2048 \
|
||||
-days 3600 \
|
||||
-subj "$(gen_cert_subject "$fqdn")" \
|
||||
-nodes \
|
||||
-keyout "${clientKeyFile}" \
|
||||
-out "${clientReqFile}"
|
||||
|
||||
log "Generating password protected client key file"
|
||||
openssl rsa \
|
||||
-aes256 \
|
||||
-in "${clientKeyFile}" \
|
||||
-out "${clientEncryptedKeyFile}" \
|
||||
-passout pass:qwerty
|
||||
|
||||
log "Generating finger print of server certificate"
|
||||
openssl x509 \
|
||||
-noout \
|
||||
-fingerprint \
|
||||
-sha1 \
|
||||
-inform pem \
|
||||
-in "${certFile}" | \
|
||||
sed -e "s/SHA1 Fingerprint=//g" \
|
||||
> "${certShaFile}"
|
||||
|
||||
log "copy ca file"
|
||||
cp "${caCertFile}" "${sslDir}/cacert.pem"
|
||||
|
||||
openssl x509 \
|
||||
-req \
|
||||
-in "${clientReqFile}" \
|
||||
-days 3600 \
|
||||
-CA "${caCertFile}" \
|
||||
-CAkey "${caKeyFile}" \
|
||||
-set_serial 01 \
|
||||
-out "${clientCertFile}"
|
||||
|
||||
# Now generate a keystore with the client cert & key
|
||||
log "Generating client keystore"
|
||||
openssl pkcs12 \
|
||||
-export \
|
||||
-in "${clientCertFile}" \
|
||||
-inkey "${clientKeyFile}" \
|
||||
-out "${tmpKeystoreFile}" \
|
||||
-name "mysqlAlias" \
|
||||
-passout pass:kspass
|
||||
|
||||
|
||||
# Now generate a full keystore with the client cert & key + trust certificates
|
||||
log "Generating full client keystore"
|
||||
openssl pkcs12 \
|
||||
-export \
|
||||
-in "${clientCertFile}" \
|
||||
-inkey "${clientKeyFile}" \
|
||||
-out "${pcks12FullKeystoreFile}" \
|
||||
-name "mysqlAlias" \
|
||||
-passout pass:kspass
|
||||
|
||||
|
||||
# Clean up CSR file:
|
||||
rm "$csrFile"
|
||||
rm "$clientReqFile"
|
||||
rm "$tmpKeystoreFile"
|
||||
|
||||
log "Generated key file and certificate in: ${sslDir}"
|
||||
ls -l "${sslDir}"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
67
.travis/script.sh
Normal file
67
.travis/script.sh
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
set -e
|
||||
|
||||
###################################################################################################################
|
||||
# test different type of configuration
|
||||
###################################################################################################################
|
||||
mysql=( mysql --protocol=tcp -ubob -h127.0.0.1 --port=3305 )
|
||||
export COMPOSE_FILE=.travis/docker-compose.yml
|
||||
|
||||
|
||||
###################################################################################################################
|
||||
# launch docker server and maxscale
|
||||
###################################################################################################################
|
||||
export INNODB_LOG_FILE_SIZE=$(echo ${PACKET}| cut -d'M' -f 1)0M
|
||||
docker-compose -f ${COMPOSE_FILE} build
|
||||
docker-compose -f ${COMPOSE_FILE} up -d
|
||||
|
||||
|
||||
###################################################################################################################
|
||||
# wait for docker initialisation
|
||||
###################################################################################################################
|
||||
|
||||
for i in {60..0}; do
|
||||
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
|
||||
break
|
||||
fi
|
||||
echo 'data server still not active'
|
||||
sleep 1
|
||||
done
|
||||
|
||||
docker-compose -f ${COMPOSE_FILE} logs
|
||||
|
||||
if [ "$i" = 0 ]; then
|
||||
echo 'SELECT 1' | "${mysql[@]}"
|
||||
echo >&2 'data server init process failed.'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#list ssl certificates
|
||||
ls -lrt ${SSLCERT}
|
||||
|
||||
|
||||
#build C connector
|
||||
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_SSL=OPENSSL -DCERT_PATH=${SSLCERT}
|
||||
make
|
||||
|
||||
export MYSQL_TEST_HOST=mariadb.example.com
|
||||
export MYSQL_TEST_DB=ctest
|
||||
export MYSQL_TEST_USER=bob
|
||||
export MYSQL_TEST_PORT=3305
|
||||
export MYSQL_TEST_TRAVIS=1
|
||||
export MARIADB_PLUGIN_DIR=$PWD/plugins/lib
|
||||
|
||||
## list ciphers
|
||||
openssl ciphers -v
|
||||
|
||||
###################################################################################################################
|
||||
# run test suite
|
||||
###################################################################################################################
|
||||
echo "Running tests"
|
||||
|
||||
cd unittest/libmariadb
|
||||
|
||||
ctest -V
|
||||
|
6
.travis/sql/dbinit.sql
Normal file
6
.travis/sql/dbinit.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE USER 'bob'@'%';
|
||||
GRANT ALL ON *.* TO 'bob'@'%' with grant option;
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
CREATE DATABASE ctest;
|
@@ -37,7 +37,7 @@ SET(CC_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR 3)
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR 0)
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH 2)
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH 4)
|
||||
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 +
|
||||
${CPACK_PACKAGE_VERSION_MINOR} * 100 +
|
||||
|
62
appveyor.yml
62
appveyor.yml
@@ -1,29 +1,53 @@
|
||||
version: 3.0.0.{build}
|
||||
version: 3.0.4;{build}
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
os: Visual Studio 2015
|
||||
configuration: RelWithDebInfo
|
||||
platform: x64
|
||||
clone_folder: c:\projects\mariadb-connector-c
|
||||
environment:
|
||||
MYSQL_TEST_USER: root
|
||||
MYSQL_TEST_HOST: 127.0.0.1
|
||||
MYSQL_TEST_PASSWD: Password12!
|
||||
services: mysql56
|
||||
matrix:
|
||||
- DB: '10.2.12'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
- DB: '10.2.12'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE_PARAM: 'Visual Studio 14 2015 Win64'
|
||||
- DB: '10.2.12'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017'
|
||||
- DB: '10.2.12'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
CMAKE_PARAM: 'Visual Studio 14 2015'
|
||||
- DB: '10.3.4'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
- DB: '10.1.30'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
- DB: '10.0.33'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
- DB: '5.5.59'
|
||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
|
||||
|
||||
|
||||
configuration: RelWithDebInfo
|
||||
clone_folder: c:\projects\mariadb-connector-c
|
||||
before_build:
|
||||
- ps: >-
|
||||
cd c:\projects\mariadb-connector-c
|
||||
|
||||
echo running cmake
|
||||
|
||||
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
- cmd: set MYSQL_TEST_USER=root
|
||||
- cmd: set MYSQL_TEST_HOST=127.0.0.1
|
||||
- cmd: set MYSQL_TEST_PASSWD=
|
||||
- cmd: set MYSQL_TEST_PORT=3306
|
||||
- cmd: set MYSQL_TEST_DB=testc
|
||||
- cmd: set FILE=http://mariadb.mirrors.ovh.net/MariaDB/mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
|
||||
- ps: Start-FileDownload $Env:FILE -FileName server.msi
|
||||
- cmd: msiexec /i server.msi INSTALLDIR=c:\projects\server SERVICENAME=mariadb ALLOWREMOTEROOTACCESS=true /qn
|
||||
- cmd: "\"c:\\projects\\server\\bin\\mysql.exe\" -e \"create database testc\" --user=root"
|
||||
- cmd: cmake -G "%CMAKE_PARAM%" -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||
build:
|
||||
project: mariadb-connector-c.sln
|
||||
parallel: true
|
||||
verbosity: minimal
|
||||
test_script:
|
||||
- cmd: >-
|
||||
cd c:\projects\mariadb-connector-c\unittest\libmariadb
|
||||
|
||||
ctest -V
|
||||
- cmd: cd c:\projects\mariadb-connector-c\unittest\libmariadb
|
||||
- cmd: set MARIADB_PLUGIN_DIR=cd c:\projects\mariadb-connector-c\plugins\lib\RelWithDebInfo
|
||||
- cmd: ctest -V
|
||||
|
@@ -2537,7 +2537,11 @@ mysql_stat(MYSQL *mysql)
|
||||
int STDCALL
|
||||
mysql_ping(MYSQL *mysql)
|
||||
{
|
||||
return ma_simple_command(mysql, COM_PING,0,0,0,0);
|
||||
int rc;
|
||||
rc= ma_simple_command(mysql, COM_PING, 0, 0, 0, 0);
|
||||
if (rc && mysql_errno(mysql) == CR_SERVER_LOST)
|
||||
rc= ma_simple_command(mysql, COM_PING, 0, 0, 0, 0);
|
||||
return rc;
|
||||
}
|
||||
|
||||
char * STDCALL
|
||||
|
@@ -339,12 +339,17 @@ void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt)
|
||||
goto end;
|
||||
}
|
||||
if (packet_len < 8 && *pos == 254) /* EOF */
|
||||
{
|
||||
if (mariadb_connection(stmt->mysql))
|
||||
{
|
||||
stmt->mysql->server_status= uint2korr(pos + 3);
|
||||
if (in_resultset)
|
||||
goto end;
|
||||
in_resultset= 1;
|
||||
}
|
||||
else
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
end:
|
||||
stmt->state= MYSQL_STMT_FETCH_DONE;
|
||||
|
@@ -79,7 +79,11 @@ static long ma_tls_version_options(const char *version)
|
||||
disable_all_protocols;
|
||||
|
||||
protocol_options= disable_all_protocols=
|
||||
SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2;
|
||||
SSL_OP_NO_SSLv2 |
|
||||
SSL_OP_NO_SSLv3 |
|
||||
SSL_OP_NO_TLSv1 |
|
||||
SSL_OP_NO_TLSv1_1 |
|
||||
SSL_OP_NO_TLSv1_2;
|
||||
|
||||
if (!version)
|
||||
return 0;
|
||||
@@ -512,7 +516,9 @@ void *ma_tls_init(MYSQL *mysql)
|
||||
{
|
||||
SSL *ssl= NULL;
|
||||
SSL_CTX *ctx= NULL;
|
||||
long options= SSL_OP_ALL;
|
||||
long options= SSL_OP_ALL |
|
||||
SSL_OP_NO_SSLv2 |
|
||||
SSL_OP_NO_SSLv3;
|
||||
#ifdef HAVE_TLS_SESSION_CACHE
|
||||
MA_SSL_SESSION *session= ma_tls_get_session(mysql);
|
||||
#endif
|
||||
|
@@ -1003,14 +1003,11 @@ my_bool pvio_socket_is_alive(MARIADB_PVIO *pvio)
|
||||
#ifndef _WIN32
|
||||
memset(&poll_fd, 0, sizeof(struct pollfd));
|
||||
poll_fd.events= POLLPRI | POLLIN;
|
||||
poll_fd.revents= POLLERR;
|
||||
poll_fd.fd= csock->socket;
|
||||
|
||||
res= poll(&poll_fd, 1, 0);
|
||||
if (res <= 0) /* timeout or error */
|
||||
return FALSE;
|
||||
if (!(poll_fd.revents & POLLERR))
|
||||
return FALSE;
|
||||
if (!(poll_fd.revents & (POLLIN | POLLPRI)))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
@@ -64,7 +64,7 @@ FOREACH(API_TEST ${API_TESTS})
|
||||
ENDIF()
|
||||
TARGET_LINK_LIBRARIES(${API_TEST} cctap ma_getopt mariadbclient)
|
||||
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 120)
|
||||
SET_TESTS_PROPERTIES(${API_TEST} PROPERTIES TIMEOUT 180)
|
||||
ENDFOREACH(API_TEST)
|
||||
|
||||
FOREACH(API_TEST ${MANUAL_TESTS})
|
||||
|
@@ -58,7 +58,6 @@ static int test_conc75(MYSQL *my)
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
diag("killing connection");
|
||||
mysql_kill(my, thread_id);
|
||||
sleep(2);
|
||||
mysql_ping(mysql);
|
||||
rc= mysql_query(mysql, "load data local infile './nonexistingfile.csv' into table a (`a`)");
|
||||
FAIL_IF(!test(mysql->options.client_flag | CLIENT_LOCAL_FILES), "client_flags not correct");
|
||||
@@ -128,7 +127,6 @@ static int test_conc71(MYSQL *my)
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
diag("kill server");
|
||||
sleep(20);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT 'foo' FROM DUAL");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -173,7 +171,6 @@ static int test_conc70(MYSQL *my)
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
sleep(20);
|
||||
|
||||
rc= mysql_query(mysql, "SELECT a FROM t1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -717,6 +714,7 @@ static int test_reconnect_maxpackage(MYSQL *unused __attribute__((unused)))
|
||||
my_bool reconnect= 1;
|
||||
|
||||
SKIP_CONNECTION_HANDLER;
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
|
||||
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
|
||||
@@ -748,9 +746,13 @@ static int test_reconnect_maxpackage(MYSQL *unused __attribute__((unused)))
|
||||
return FAIL;
|
||||
}
|
||||
else
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
diag("Error (expected): %s", mysql_error(mysql));
|
||||
|
||||
rc= mysql_ping(mysql);
|
||||
/* if the server is under load, poll might not report closed
|
||||
socket since FIN packet came too late */
|
||||
if (rc)
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "SELECT @@max_allowed_packet");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@@ -539,6 +539,8 @@ static int test_conc243(MYSQL *mysql)
|
||||
size_t row_size= sizeof(struct st_data);
|
||||
int rc;
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -628,12 +630,15 @@ static int bulk7(MYSQL *mysql)
|
||||
|
||||
static int test_char_conv1(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
MYSQL_BIND bind_in, bind_out;
|
||||
char buffer[100];
|
||||
char outbuffer[100];
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
strcpy (buffer, "\xC3\x82\xC3\x83\xC3\x84\x00");
|
||||
|
||||
rc= mysql_query(mysql, "SET NAMES UTF8");
|
||||
@@ -696,13 +701,17 @@ static int test_char_conv1(MYSQL *mysql)
|
||||
|
||||
static int test_char_conv2(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_STMT *stmt;
|
||||
int rc;
|
||||
int array_size= 1;
|
||||
MYSQL_BIND bind_in, bind_out;
|
||||
char *buffer[1];
|
||||
char outbuffer[100];
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
buffer[0]= calloc(1, 7);
|
||||
strcpy (buffer[0], "\xC3\x82\xC3\x83\xC3\x84\x00");
|
||||
|
||||
@@ -794,6 +803,8 @@ static int bulk_skip_row(MYSQL *mysql)
|
||||
size_t row_size= sizeof(struct st_data);
|
||||
int rc;
|
||||
|
||||
if (!bulk_enabled)
|
||||
return SKIP;
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
|
@@ -536,7 +536,8 @@ static int test_bug30472(MYSQL *mysql)
|
||||
char character_set_results_4[MY_CS_NAME_SIZE];
|
||||
char collation_connnection_4[MY_CS_NAME_SIZE];
|
||||
|
||||
if (mysql_get_server_version(mysql) < 50100) {
|
||||
if (mysql_get_server_version(mysql) < 50100 || !is_mariadb)
|
||||
{
|
||||
diag("Test requires MySQL Server version 5.1 or above");
|
||||
return SKIP;
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ static int test_conc66(MYSQL *my)
|
||||
rc= mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "./my-conc66-test.cnf");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
sprintf(query, "GRANT ALL ON %s.* TO 'conc66'@'%s' IDENTIFIED BY 'test\";#test'", schema, hostname ? hostname : "localhost");
|
||||
sprintf(query, "GRANT ALL ON %s.* TO 'conc66'@'%s' IDENTIFIED BY 'test\";#test'", schema, this_host ? this_host : "localhost");
|
||||
rc= mysql_query(my, query);
|
||||
check_mysql_rc(rc, my);
|
||||
rc= mysql_query(my, "FLUSH PRIVILEGES");
|
||||
@@ -60,11 +60,13 @@ static int test_conc66(MYSQL *my)
|
||||
if (!my_test_connect(mysql, hostname, NULL,
|
||||
NULL, schema, port, socketname, 0))
|
||||
{
|
||||
diag("user: %s", mysql->options.user);
|
||||
diag("Error: %s", mysql_error(mysql));
|
||||
return FAIL;
|
||||
}
|
||||
diag("user: %s", mysql->options.user);
|
||||
|
||||
sprintf(query, "DROP user conc66@%s", hostname ? hostname : "localhost");
|
||||
sprintf(query, "DROP user 'conc66'@'%s'", this_host ? this_host : "localhost");
|
||||
rc= mysql_query(my, query);
|
||||
|
||||
check_mysql_rc(rc, my);
|
||||
@@ -83,6 +85,9 @@ static int test_bug20023(MYSQL *mysql)
|
||||
int sql_big_selects_5;
|
||||
int rc;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
if (mysql_get_server_version(mysql) < 50100) {
|
||||
diag("Test requires MySQL Server version 5.1 or above");
|
||||
return SKIP;
|
||||
@@ -579,7 +584,6 @@ static int test_reconnect(MYSQL *mysql)
|
||||
|
||||
diag("Thread_id before kill: %lu", mysql_thread_id(mysql1));
|
||||
mysql_kill(mysql, mysql_thread_id(mysql1));
|
||||
sleep(4);
|
||||
|
||||
mysql_ping(mysql1);
|
||||
|
||||
@@ -657,7 +661,7 @@ int test_connection_timeout(MYSQL *unused __attribute__((unused)))
|
||||
elapsed= time(NULL) - start;
|
||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||
mysql_close(mysql);
|
||||
FAIL_IF(elapsed > 2 * timeout, "timeout ignored")
|
||||
FAIL_IF((unsigned int)elapsed > 2 * timeout, "timeout ignored")
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -677,7 +681,7 @@ int test_connection_timeout2(MYSQL *unused __attribute__((unused)))
|
||||
elapsed= time(NULL) - start;
|
||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||
mysql_close(mysql);
|
||||
FAIL_IF(elapsed > 2 * timeout, "timeout ignored")
|
||||
FAIL_IF((unsigned int)elapsed > 2 * timeout, "timeout ignored")
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -702,7 +706,7 @@ int test_connection_timeout3(MYSQL *unused __attribute__((unused)))
|
||||
}
|
||||
elapsed= time(NULL) - start;
|
||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||
FAIL_IF(elapsed > timeout + 1, "timeout ignored")
|
||||
FAIL_IF((unsigned int)elapsed > timeout + 1, "timeout ignored")
|
||||
|
||||
mysql_close(mysql);
|
||||
mysql= mysql_init(NULL);
|
||||
@@ -737,7 +741,6 @@ static int test_conc118(MYSQL *mysql)
|
||||
mysql->options.unused_1= 1;
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
mysql_ping(mysql);
|
||||
|
||||
@@ -747,7 +750,6 @@ static int test_conc118(MYSQL *mysql)
|
||||
FAIL_IF(mysql->options.unused_1 != 1, "options got lost");
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
mysql_ping(mysql);
|
||||
rc= mysql_query(mysql, "SET @a:=1");
|
||||
@@ -1021,6 +1023,9 @@ static int test_reset(MYSQL *mysql)
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
|
||||
if (mysql_get_server_version(mysql) < 100200)
|
||||
return SKIP;
|
||||
|
||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -1071,6 +1076,13 @@ static int test_auth256(MYSQL *my)
|
||||
int rc;
|
||||
MYSQL_RES *res;
|
||||
my_ulonglong num_rows= 0;
|
||||
char query[1024];
|
||||
|
||||
if (!mysql_client_find_plugin(mysql, "sha256_password", 3))
|
||||
{
|
||||
diag("sha256_password plugin not available");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
rc= mysql_query(my, "SELECT * FROM information_schema.plugins where plugin_name='sha256_password'");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -1088,8 +1100,10 @@ static int test_auth256(MYSQL *my)
|
||||
rc= mysql_query(my, "DROP USER IF EXISTS sha256user@localhost");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
rc= mysql_query(my, "CREATE user sha256user@localhost identified with sha256_password by 'foo'");
|
||||
sprintf(query, "CREATE user 'sha256user'@'%s' identified with sha256_password by 'foo'", this_host);
|
||||
rc= mysql_query(my, query);
|
||||
check_mysql_rc(rc, my);
|
||||
|
||||
if (!mysql_real_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
|
||||
{
|
||||
diag("error: %s", mysql_error(mysql));
|
||||
@@ -1107,7 +1121,8 @@ static int test_auth256(MYSQL *my)
|
||||
return FAIL;
|
||||
}
|
||||
mysql_close(mysql);
|
||||
rc= mysql_query(my, "DROP USER sha256user@localhost");
|
||||
sprintf(query, "DROP USER 'sha256user'@'%s'", this_host);
|
||||
rc= mysql_query(my, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
return OK;
|
||||
}
|
||||
|
@@ -176,6 +176,8 @@ static int test_cuted_rows(MYSQL *mysql)
|
||||
int rc, count;
|
||||
MYSQL_RES *result;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
mysql_query(mysql, "DROP TABLE if exists t1");
|
||||
mysql_query(mysql, "DROP TABLE if exists t2");
|
||||
|
@@ -98,6 +98,7 @@ static int bug31418_impl()
|
||||
MYSQL *mysql;
|
||||
int rc;
|
||||
|
||||
|
||||
/* Create a new connection. */
|
||||
|
||||
mysql= test_connect(NULL);
|
||||
@@ -170,6 +171,9 @@ static int bug31418_impl()
|
||||
static int test_bug31418(MYSQL *unused __attribute__((unused)))
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
/* Run test case for BUG#31418 for three different connections. */
|
||||
|
||||
for (i=0; i < 3; i++)
|
||||
@@ -976,7 +980,6 @@ static int test_conc117(MYSQL *unused __attribute__((unused)))
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
mysql_kill(my, mysql_thread_id(my));
|
||||
sleep(5);
|
||||
|
||||
mysql_options(my, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
|
||||
@@ -1064,6 +1067,9 @@ static int test_mdev12965(MYSQL *unused __attribute__((unused)))
|
||||
const char *env= getenv("MYSQL_TMP_DIR");
|
||||
char cnf_file1[FN_REFLEN + 1];
|
||||
|
||||
if (travis_test)
|
||||
return SKIP;
|
||||
|
||||
if (!env)
|
||||
env= "/tmp";
|
||||
|
||||
@@ -1082,7 +1088,7 @@ static int test_mdev12965(MYSQL *unused __attribute__((unused)))
|
||||
fprintf(fp, "[client]\ndefault-character-set=latin2\nreconnect=1\n");
|
||||
fclose(fp);
|
||||
|
||||
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, NULL);
|
||||
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "client");
|
||||
my_test_connect(mysql, hostname, username, password,
|
||||
schema, 0, socketname, 0);
|
||||
|
||||
@@ -1189,7 +1195,12 @@ static int test_server_status(MYSQL *mysql)
|
||||
{
|
||||
int rc;
|
||||
unsigned int server_status;
|
||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
||||
MYSQL_STMT *stmt;
|
||||
|
||||
if (mysql_get_server_version(mysql) < 100200)
|
||||
return SKIP;
|
||||
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
|
||||
rc= mysql_autocommit(mysql, 1);
|
||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_STATUS, &server_status);
|
||||
|
@@ -134,6 +134,9 @@ static unsigned int port = 0;
|
||||
static char *socketname = 0;
|
||||
static char *username = 0;
|
||||
static int force_tls= 0;
|
||||
static uchar is_mariadb= 0;
|
||||
static char *this_host= 0;
|
||||
static unsigned char travis_test= 0;
|
||||
/*
|
||||
static struct my_option test_options[] =
|
||||
{
|
||||
@@ -216,6 +219,22 @@ int do_verify_prepare_field(MYSQL_RES *result,
|
||||
return OK;
|
||||
}
|
||||
|
||||
void get_this_host(MYSQL *mysql)
|
||||
{
|
||||
MYSQL_RES *res;
|
||||
MYSQL_ROW row;
|
||||
|
||||
if (mysql_query(mysql, "select substr(current_user(), locate('@', current_user())+1)"))
|
||||
return;
|
||||
|
||||
if ((res= mysql_store_result(mysql)))
|
||||
{
|
||||
if ((row= mysql_fetch_row(res)))
|
||||
this_host= strdup(row[0]);
|
||||
mysql_free_result(res);
|
||||
}
|
||||
}
|
||||
|
||||
/* Prepare statement, execute, and process result set for given query */
|
||||
|
||||
int my_stmt_result(MYSQL *mysql, const char *buff)
|
||||
@@ -436,7 +455,10 @@ MYSQL *test_connect(struct my_tests_st *test)
|
||||
static int reset_connection(MYSQL *mysql) {
|
||||
int rc;
|
||||
|
||||
if (is_mariadb)
|
||||
rc= mysql_change_user(mysql, username, password, schema);
|
||||
else
|
||||
rc= mysql_reset_connection(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_query(mysql, "SET sql_mode=''");
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -452,6 +474,9 @@ static int reset_connection(MYSQL *mysql) {
|
||||
void get_envvars() {
|
||||
char *envvar;
|
||||
|
||||
if (getenv("MYSQL_TEST_TRAVIS"))
|
||||
travis_test= 1;
|
||||
|
||||
if (!hostname && (envvar= getenv("MYSQL_TEST_HOST")))
|
||||
hostname= envvar;
|
||||
if (!username)
|
||||
@@ -504,6 +529,8 @@ MYSQL *my_test_connect(MYSQL *mysql,
|
||||
diag("Error: TLS connection not established");
|
||||
return NULL;
|
||||
}
|
||||
if (!this_host)
|
||||
get_this_host(mysql);
|
||||
return mysql;
|
||||
}
|
||||
|
||||
@@ -512,7 +539,6 @@ void run_tests(struct my_tests_st *test) {
|
||||
int i, rc, total=0;
|
||||
MYSQL *mysql, *mysql_default= NULL; /* default connection */
|
||||
|
||||
|
||||
while (test[total].function)
|
||||
total++;
|
||||
plan(total);
|
||||
@@ -522,6 +548,7 @@ void run_tests(struct my_tests_st *test) {
|
||||
diag("Testing against MySQL Server %s", mysql_get_server_info(mysql_default));
|
||||
diag("Host: %s", mysql_get_host_info(mysql_default));
|
||||
diag("Client library: %s", mysql_get_client_info());
|
||||
is_mariadb= mariadb_connection(mysql_default);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -567,6 +594,9 @@ void run_tests(struct my_tests_st *test) {
|
||||
skip(1, "%s", test[i].skipmsg);
|
||||
}
|
||||
}
|
||||
if (this_host)
|
||||
free(this_host);
|
||||
|
||||
if (mysql_default) {
|
||||
diag("close default");
|
||||
mysql_close(mysql_default);
|
||||
|
@@ -65,7 +65,6 @@ static int test_conc83(MYSQL *unused __attribute__((unused)))
|
||||
/* 1. Status is inited, so prepare should work */
|
||||
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(5);
|
||||
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -76,7 +75,6 @@ static int test_conc83(MYSQL *unused __attribute__((unused)))
|
||||
|
||||
/* 2. Status is prepared, execute should fail */
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(2);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
FAIL_IF(!rc, "Error expected");
|
||||
@@ -1377,7 +1375,7 @@ static int test_long_data_str1(MYSQL *mysql)
|
||||
int rc, i, rowcount= 0;
|
||||
char data[255];
|
||||
long length;
|
||||
size_t max_blob_length, blob_length, length1;
|
||||
unsigned long max_blob_length, blob_length, length1;
|
||||
my_bool true_value;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_BIND my_bind[2];
|
||||
@@ -3137,6 +3135,8 @@ static int test_datetime_ranges(MYSQL *mysql)
|
||||
MYSQL_BIND my_bind[6];
|
||||
MYSQL_TIME tm[6];
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
stmt_text= "drop table if exists t1";
|
||||
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
|
||||
@@ -4980,6 +4980,9 @@ static int test_reexecute(MYSQL *mysql)
|
||||
int int_data[3]; /* input/output values */
|
||||
int rc;
|
||||
|
||||
if (!mariadb_connection(mysql))
|
||||
return SKIP;
|
||||
|
||||
/* set up stored procedure */
|
||||
rc = mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
@@ -537,7 +537,6 @@ static int test_bug12744(MYSQL *mysql)
|
||||
check_mysql_rc(rc, mysql);
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
|
||||
sleep(4);
|
||||
rc= mysql_ping(mysql);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -2731,6 +2730,8 @@ static int test_bug5315(MYSQL *mysql)
|
||||
const char *stmt_text;
|
||||
int rc;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
stmt_text= "SELECT 1";
|
||||
stmt= mysql_stmt_init(mysql);
|
||||
@@ -3456,6 +3457,8 @@ static int test_explain_bug(MYSQL *mysql)
|
||||
MYSQL_RES *result;
|
||||
int rc;
|
||||
|
||||
if (!is_mariadb)
|
||||
return SKIP;
|
||||
|
||||
mysql_autocommit(mysql, TRUE);
|
||||
|
||||
@@ -3803,7 +3806,6 @@ static int test_bug53311(MYSQL *mysql)
|
||||
|
||||
/* kill connection */
|
||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||
sleep(1);
|
||||
|
||||
rc= mysql_stmt_execute(stmt);
|
||||
FAIL_IF(rc == 0, "Error expected");
|
||||
@@ -4286,8 +4288,11 @@ static int test_conc179(MYSQL *mysql)
|
||||
rc= mysql_stmt_prepare(stmt, stmtstr, (unsigned long)strlen(stmtstr));
|
||||
check_stmt_rc(rc, stmt);
|
||||
|
||||
if (mysql_get_server_version(mysql) >= 100100)
|
||||
{
|
||||
FAIL_IF(mysql_warning_count(mysql) < 2, "expected 2 or more warnings");
|
||||
FAIL_IF(mysql_stmt_warning_count(stmt) < 2, "expected 2 or more warnings");
|
||||
}
|
||||
|
||||
mysql_stmt_close(stmt);
|
||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||
|
@@ -86,15 +86,14 @@ static int create_ssl_user(const char *ssluser, my_bool is_X509)
|
||||
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||
port, socketname, 0), mysql_error(mysql));
|
||||
|
||||
sprintf(query, "DROP USER IF EXISTS '%s'@'%s'", ssluser, sslhost);
|
||||
sprintf(query, "DROP USER '%s'@'%s'", ssluser, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
|
||||
sprintf(query, "CREATE USER '%s'@'%s' IDENTIFIED BY '%s'", ssluser, this_host, sslpw);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc,mysql);
|
||||
|
||||
sprintf(query, "CREATE USER '%s'@'%s' IDENTIFIED BY '%s'", ssluser, sslhost, sslpw);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc,mysql);
|
||||
|
||||
sprintf(query, "GRANT ALL ON %s.* TO '%s'@'%s' REQUIRE %s", schema, ssluser, sslhost, is_X509 ? "X509" : "SSL");
|
||||
sprintf(query, "GRANT ALL ON %s.* TO '%s'@'%s' REQUIRE %s", schema, ssluser, this_host, is_X509 ? "X509" : "SSL");
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc,mysql);
|
||||
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
||||
@@ -128,6 +127,24 @@ static int test_ssl(MYSQL *mysql)
|
||||
}
|
||||
mysql_free_result(res);
|
||||
|
||||
/* In MySQL we need to check tls_version */
|
||||
if (!mariadb_connection(mysql))
|
||||
{
|
||||
rc= mysql_query(mysql, "select locate('v1.2', @@tls_version) > 0");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
res= mysql_store_result(mysql);
|
||||
FAIL_IF(!res, mysql_error(mysql));
|
||||
|
||||
if ((row= mysql_fetch_row(res)))
|
||||
{
|
||||
if (row[0] && row[0][0] == '0')
|
||||
have_openssl= 0;
|
||||
}
|
||||
mysql_free_result(res);
|
||||
}
|
||||
diag("OpenSSL: %d", have_openssl);
|
||||
|
||||
mariadb_get_infov(NULL, MARIADB_TLS_LIBRARY, &tls_library);
|
||||
diag("SSL library: %s", tls_library);
|
||||
|
||||
@@ -450,6 +467,8 @@ static int test_conc50_1(MYSQL *unused __attribute__((unused)))
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
create_ssl_user(ssluser, 0);
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
FAIL_IF(!mysql, "Can't allocate memory");
|
||||
|
||||
@@ -460,6 +479,7 @@ static int test_conc50_1(MYSQL *unused __attribute__((unused)))
|
||||
if (mysql_errno(mysql))
|
||||
diag("Error: %d %s", mysql_errno(mysql), mysql_error(mysql));
|
||||
FAIL_IF(mysql_errno(mysql), "No error expected");
|
||||
|
||||
mysql_close(mysql);
|
||||
|
||||
return OK;
|
||||
@@ -957,19 +977,23 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
if (check_skip_ssl())
|
||||
return SKIP;
|
||||
|
||||
if (!mariadb_connection(mysql))
|
||||
return SKIP;
|
||||
|
||||
for (i=1; i < 6; i++)
|
||||
{
|
||||
sprintf(query, "DROP USER IF EXISTS 'ssluser%d'@'%s'", i, sslhost);
|
||||
sprintf(query, "DROP USER 'ssluser%d'@'%s'", i, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
sprintf(query, "CREATE USER 'ssluser%d'@'%s'", i, sslhost);
|
||||
sprintf(query, "CREATE USER 'ssluser%d'@'%s'", i, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
}
|
||||
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
||||
check_mysql_rc(rc, mysql);
|
||||
diag("sslusers created");
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser1'@'%s' require ssl", schema, sslhost);
|
||||
diag("ssluser1");
|
||||
sprintf(query, "grant select on %s.* to 'ssluser1'@'%s' require ssl", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -988,11 +1012,12 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
FAIL_IF(!mysql_get_ssl_cipher(my), "No TLS connection");
|
||||
mysql_close(my);
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser2'@'%s' require cipher 'AES256-SHA'", schema, sslhost);
|
||||
diag("ssluser2");
|
||||
sprintf(query, "grant select on %s.* to 'ssluser2'@'%s' require cipher 'AES256-SHA'", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
|
||||
#ifdef TEST_RANDOM_RESULT
|
||||
/* ssl_user2: connect with enforce should work */
|
||||
my= mysql_init(NULL);
|
||||
mysql_options(my, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
@@ -1005,8 +1030,21 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
return FAIL;
|
||||
}
|
||||
mysql_close(my);
|
||||
#endif
|
||||
/* ssl_user2: connect with correct cipher */
|
||||
diag("ssluser2");
|
||||
if (mysql_get_server_version(mysql) >= 100100)
|
||||
{
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
FAIL_IF(strcmp("AES256-SHA", mysql_get_ssl_cipher(my)) != 0, "expected cipher AES256-SHA");
|
||||
mysql_close(my);
|
||||
}
|
||||
|
||||
/* ssl_user2: connect with cipher should work */
|
||||
/* ssl_user2: connect with wrong cipher should not work */
|
||||
diag("ssluser2");
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES128-SHA");
|
||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
@@ -1014,17 +1052,10 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
mysql_close(my);
|
||||
|
||||
|
||||
/* ssl_user2: connect with correct cipher */
|
||||
my= mysql_init(NULL);
|
||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
FAIL_IF(strcmp("AES256-SHA", mysql_get_ssl_cipher(my)) != 0, "expected cipher AES256-SHA");
|
||||
mysql_close(my);
|
||||
|
||||
|
||||
if (!travis_test)
|
||||
{
|
||||
sprintf(query, "grant select on %s.* to 'ssluser3'@'%s' require cipher 'AES256-SHA' AND "
|
||||
" SUBJECT '/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB/CN=client'", schema, sslhost);
|
||||
" SUBJECT '/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB/CN=client'", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -1048,7 +1079,7 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
mysql_close(my);
|
||||
|
||||
sprintf(query, "grant select on %s.* to 'ssluser4'@'%s' require cipher 'AES256-SHA' AND "
|
||||
" ISSUER '/CN=cacert/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'", schema, sslhost);
|
||||
" ISSUER '/CN=cacert/C=FI/ST=Helsinki/L=Helsinki/O=MariaDB'", schema, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
@@ -1068,14 +1099,14 @@ static int test_openssl_1(MYSQL *mysql)
|
||||
"AES256-SHA");
|
||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||
port, socketname, 0), mysql_error(my));
|
||||
|
||||
mysql_close(my);
|
||||
}
|
||||
diag("drop users");
|
||||
for (i=1; i < 6; i++)
|
||||
{
|
||||
sprintf(query, "DROP USER IF EXISTS 'ssluser%d'@'%s'", i, sslhost);
|
||||
sprintf(query, "DROP USER 'ssluser%d'@'%s'", i, this_host);
|
||||
rc= mysql_query(mysql, query);
|
||||
check_mysql_rc(rc, mysql);
|
||||
}
|
||||
mysql_close(my);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -1195,8 +1226,6 @@ static int test_mdev14101(MYSQL *my __attribute__((unused)))
|
||||
bool skip_tlsv12= !have_openssl;
|
||||
#endif
|
||||
|
||||
diag("%d %d", skip_tlsv12, have_openssl);
|
||||
|
||||
for (i=0; combinations[i].expected; i++)
|
||||
{
|
||||
MYSQL *mysql;
|
||||
@@ -1206,6 +1235,8 @@ static int test_mdev14101(MYSQL *my __attribute__((unused)))
|
||||
if (!combinations[i].do_yassl && skip_tlsv12)
|
||||
break;
|
||||
|
||||
diag("combination: %s", combinations[i].opt_tls_version);
|
||||
|
||||
mysql= mysql_init(NULL);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||
mysql_options(mysql, MARIADB_OPT_TLS_VERSION, combinations[i].opt_tls_version);
|
||||
|
Reference in New Issue
Block a user