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_MAJOR 3)
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR 0)
|
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}")
|
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 +
|
MATH(EXPR MARIADB_PACKAGE_VERSION_ID "${CPACK_PACKAGE_VERSION_MAJOR} * 10000 +
|
||||||
${CPACK_PACKAGE_VERSION_MINOR} * 100 +
|
${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:
|
branches:
|
||||||
only:
|
only:
|
||||||
- master
|
- master
|
||||||
os: Visual Studio 2015
|
|
||||||
configuration: RelWithDebInfo
|
|
||||||
platform: x64
|
|
||||||
clone_folder: c:\projects\mariadb-connector-c
|
|
||||||
environment:
|
environment:
|
||||||
MYSQL_TEST_USER: root
|
matrix:
|
||||||
MYSQL_TEST_HOST: 127.0.0.1
|
- DB: '10.2.12'
|
||||||
MYSQL_TEST_PASSWD: Password12!
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
services: mysql56
|
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:
|
before_build:
|
||||||
- ps: >-
|
- cmd: set MYSQL_TEST_USER=root
|
||||||
cd c:\projects\mariadb-connector-c
|
- cmd: set MYSQL_TEST_HOST=127.0.0.1
|
||||||
|
- cmd: set MYSQL_TEST_PASSWD=
|
||||||
echo running cmake
|
- cmd: set MYSQL_TEST_PORT=3306
|
||||||
|
- cmd: set MYSQL_TEST_DB=testc
|
||||||
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=RelWithDebInfo
|
- 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:
|
build:
|
||||||
project: mariadb-connector-c.sln
|
project: mariadb-connector-c.sln
|
||||||
parallel: true
|
parallel: true
|
||||||
verbosity: minimal
|
verbosity: minimal
|
||||||
test_script:
|
test_script:
|
||||||
- cmd: >-
|
- cmd: cd c:\projects\mariadb-connector-c\unittest\libmariadb
|
||||||
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
|
||||||
ctest -V
|
|
||||||
|
@@ -2537,7 +2537,11 @@ mysql_stat(MYSQL *mysql)
|
|||||||
int STDCALL
|
int STDCALL
|
||||||
mysql_ping(MYSQL *mysql)
|
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
|
char * STDCALL
|
||||||
|
@@ -340,10 +340,15 @@ void mthd_stmt_flush_unbuffered(MYSQL_STMT *stmt)
|
|||||||
}
|
}
|
||||||
if (packet_len < 8 && *pos == 254) /* EOF */
|
if (packet_len < 8 && *pos == 254) /* EOF */
|
||||||
{
|
{
|
||||||
stmt->mysql->server_status= uint2korr(pos + 3);
|
if (mariadb_connection(stmt->mysql))
|
||||||
if (in_resultset)
|
{
|
||||||
|
stmt->mysql->server_status= uint2korr(pos + 3);
|
||||||
|
if (in_resultset)
|
||||||
|
goto end;
|
||||||
|
in_resultset= 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
goto end;
|
goto end;
|
||||||
in_resultset= 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
@@ -2279,7 +2284,7 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->mysql->status == MYSQL_STATUS_GET_RESULT)
|
if (stmt->mysql->status == MYSQL_STATUS_GET_RESULT)
|
||||||
stmt->mysql->status= MYSQL_STATUS_STMT_RESULT;
|
stmt->mysql->status= MYSQL_STATUS_STMT_RESULT;
|
||||||
|
|
||||||
if (stmt->mysql->field_count)
|
if (stmt->mysql->field_count)
|
||||||
rc= madb_alloc_stmt_fields(stmt);
|
rc= madb_alloc_stmt_fields(stmt);
|
||||||
|
@@ -79,7 +79,11 @@ static long ma_tls_version_options(const char *version)
|
|||||||
disable_all_protocols;
|
disable_all_protocols;
|
||||||
|
|
||||||
protocol_options= 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)
|
if (!version)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -512,7 +516,9 @@ void *ma_tls_init(MYSQL *mysql)
|
|||||||
{
|
{
|
||||||
SSL *ssl= NULL;
|
SSL *ssl= NULL;
|
||||||
SSL_CTX *ctx= 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
|
#ifdef HAVE_TLS_SESSION_CACHE
|
||||||
MA_SSL_SESSION *session= ma_tls_get_session(mysql);
|
MA_SSL_SESSION *session= ma_tls_get_session(mysql);
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1003,14 +1003,11 @@ my_bool pvio_socket_is_alive(MARIADB_PVIO *pvio)
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
memset(&poll_fd, 0, sizeof(struct pollfd));
|
memset(&poll_fd, 0, sizeof(struct pollfd));
|
||||||
poll_fd.events= POLLPRI | POLLIN;
|
poll_fd.events= POLLPRI | POLLIN;
|
||||||
poll_fd.revents= POLLERR;
|
|
||||||
poll_fd.fd= csock->socket;
|
poll_fd.fd= csock->socket;
|
||||||
|
|
||||||
res= poll(&poll_fd, 1, 0);
|
res= poll(&poll_fd, 1, 0);
|
||||||
if (res <= 0) /* timeout or error */
|
if (res <= 0) /* timeout or error */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!(poll_fd.revents & POLLERR))
|
|
||||||
return FALSE;
|
|
||||||
if (!(poll_fd.revents & (POLLIN | POLLPRI)))
|
if (!(poll_fd.revents & (POLLIN | POLLPRI)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@@ -64,7 +64,7 @@ FOREACH(API_TEST ${API_TESTS})
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
TARGET_LINK_LIBRARIES(${API_TEST} cctap ma_getopt mariadbclient)
|
TARGET_LINK_LIBRARIES(${API_TEST} cctap ma_getopt mariadbclient)
|
||||||
ADD_TEST(${API_TEST} ${EXECUTABLE_OUTPUT_PATH}/${API_TEST})
|
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)
|
ENDFOREACH(API_TEST)
|
||||||
|
|
||||||
FOREACH(API_TEST ${MANUAL_TESTS})
|
FOREACH(API_TEST ${MANUAL_TESTS})
|
||||||
|
@@ -58,7 +58,6 @@ static int test_conc75(MYSQL *my)
|
|||||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||||
diag("killing connection");
|
diag("killing connection");
|
||||||
mysql_kill(my, thread_id);
|
mysql_kill(my, thread_id);
|
||||||
sleep(2);
|
|
||||||
mysql_ping(mysql);
|
mysql_ping(mysql);
|
||||||
rc= mysql_query(mysql, "load data local infile './nonexistingfile.csv' into table a (`a`)");
|
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");
|
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));
|
port, socketname, 0), mysql_error(my));
|
||||||
|
|
||||||
diag("kill server");
|
diag("kill server");
|
||||||
sleep(20);
|
|
||||||
|
|
||||||
rc= mysql_query(mysql, "SELECT 'foo' FROM DUAL");
|
rc= mysql_query(mysql, "SELECT 'foo' FROM DUAL");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
@@ -173,7 +171,6 @@ static int test_conc70(MYSQL *my)
|
|||||||
return SKIP;
|
return SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(20);
|
|
||||||
|
|
||||||
rc= mysql_query(mysql, "SELECT a FROM t1");
|
rc= mysql_query(mysql, "SELECT a FROM t1");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
@@ -717,6 +714,7 @@ static int test_reconnect_maxpackage(MYSQL *unused __attribute__((unused)))
|
|||||||
my_bool reconnect= 1;
|
my_bool reconnect= 1;
|
||||||
|
|
||||||
SKIP_CONNECTION_HANDLER;
|
SKIP_CONNECTION_HANDLER;
|
||||||
|
|
||||||
mysql= mysql_init(NULL);
|
mysql= mysql_init(NULL);
|
||||||
|
|
||||||
FAIL_IF(!my_test_connect(mysql, hostname, username, password, schema,
|
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;
|
return FAIL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
diag("Error: %s", mysql_error(mysql));
|
diag("Error (expected): %s", mysql_error(mysql));
|
||||||
|
|
||||||
rc= mysql_ping(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);
|
check_mysql_rc(rc, mysql);
|
||||||
rc= mysql_query(mysql, "SELECT @@max_allowed_packet");
|
rc= mysql_query(mysql, "SELECT @@max_allowed_packet");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
@@ -539,6 +539,8 @@ static int test_conc243(MYSQL *mysql)
|
|||||||
size_t row_size= sizeof(struct st_data);
|
size_t row_size= sizeof(struct st_data);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (!bulk_enabled)
|
||||||
|
return SKIP;
|
||||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
@@ -628,12 +630,15 @@ static int bulk7(MYSQL *mysql)
|
|||||||
|
|
||||||
static int test_char_conv1(MYSQL *mysql)
|
static int test_char_conv1(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
MYSQL_STMT *stmt;
|
||||||
int rc;
|
int rc;
|
||||||
MYSQL_BIND bind_in, bind_out;
|
MYSQL_BIND bind_in, bind_out;
|
||||||
char buffer[100];
|
char buffer[100];
|
||||||
char outbuffer[100];
|
char outbuffer[100];
|
||||||
|
|
||||||
|
if (!bulk_enabled)
|
||||||
|
return SKIP;
|
||||||
|
stmt= mysql_stmt_init(mysql);
|
||||||
strcpy (buffer, "\xC3\x82\xC3\x83\xC3\x84\x00");
|
strcpy (buffer, "\xC3\x82\xC3\x83\xC3\x84\x00");
|
||||||
|
|
||||||
rc= mysql_query(mysql, "SET NAMES UTF8");
|
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)
|
static int test_char_conv2(MYSQL *mysql)
|
||||||
{
|
{
|
||||||
MYSQL_STMT *stmt= mysql_stmt_init(mysql);
|
MYSQL_STMT *stmt;
|
||||||
int rc;
|
int rc;
|
||||||
int array_size= 1;
|
int array_size= 1;
|
||||||
MYSQL_BIND bind_in, bind_out;
|
MYSQL_BIND bind_in, bind_out;
|
||||||
char *buffer[1];
|
char *buffer[1];
|
||||||
char outbuffer[100];
|
char outbuffer[100];
|
||||||
|
|
||||||
|
if (!bulk_enabled)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
|
stmt= mysql_stmt_init(mysql);
|
||||||
buffer[0]= calloc(1, 7);
|
buffer[0]= calloc(1, 7);
|
||||||
strcpy (buffer[0], "\xC3\x82\xC3\x83\xC3\x84\x00");
|
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);
|
size_t row_size= sizeof(struct st_data);
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (!bulk_enabled)
|
||||||
|
return SKIP;
|
||||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS bulk_example2");
|
||||||
check_mysql_rc(rc, mysql);
|
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 character_set_results_4[MY_CS_NAME_SIZE];
|
||||||
char collation_connnection_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");
|
diag("Test requires MySQL Server version 5.1 or above");
|
||||||
return SKIP;
|
return SKIP;
|
||||||
}
|
}
|
||||||
|
@@ -52,7 +52,7 @@ static int test_conc66(MYSQL *my)
|
|||||||
rc= mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "./my-conc66-test.cnf");
|
rc= mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "./my-conc66-test.cnf");
|
||||||
check_mysql_rc(rc, mysql);
|
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);
|
rc= mysql_query(my, query);
|
||||||
check_mysql_rc(rc, my);
|
check_mysql_rc(rc, my);
|
||||||
rc= mysql_query(my, "FLUSH PRIVILEGES");
|
rc= mysql_query(my, "FLUSH PRIVILEGES");
|
||||||
@@ -60,11 +60,13 @@ static int test_conc66(MYSQL *my)
|
|||||||
if (!my_test_connect(mysql, hostname, NULL,
|
if (!my_test_connect(mysql, hostname, NULL,
|
||||||
NULL, schema, port, socketname, 0))
|
NULL, schema, port, socketname, 0))
|
||||||
{
|
{
|
||||||
|
diag("user: %s", mysql->options.user);
|
||||||
diag("Error: %s", mysql_error(mysql));
|
diag("Error: %s", mysql_error(mysql));
|
||||||
return FAIL;
|
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);
|
rc= mysql_query(my, query);
|
||||||
|
|
||||||
check_mysql_rc(rc, my);
|
check_mysql_rc(rc, my);
|
||||||
@@ -83,6 +85,9 @@ static int test_bug20023(MYSQL *mysql)
|
|||||||
int sql_big_selects_5;
|
int sql_big_selects_5;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (!is_mariadb)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
if (mysql_get_server_version(mysql) < 50100) {
|
if (mysql_get_server_version(mysql) < 50100) {
|
||||||
diag("Test requires MySQL Server version 5.1 or above");
|
diag("Test requires MySQL Server version 5.1 or above");
|
||||||
return SKIP;
|
return SKIP;
|
||||||
@@ -579,7 +584,6 @@ static int test_reconnect(MYSQL *mysql)
|
|||||||
|
|
||||||
diag("Thread_id before kill: %lu", mysql_thread_id(mysql1));
|
diag("Thread_id before kill: %lu", mysql_thread_id(mysql1));
|
||||||
mysql_kill(mysql, mysql_thread_id(mysql1));
|
mysql_kill(mysql, mysql_thread_id(mysql1));
|
||||||
sleep(4);
|
|
||||||
|
|
||||||
mysql_ping(mysql1);
|
mysql_ping(mysql1);
|
||||||
|
|
||||||
@@ -657,7 +661,7 @@ int test_connection_timeout(MYSQL *unused __attribute__((unused)))
|
|||||||
elapsed= time(NULL) - start;
|
elapsed= time(NULL) - start;
|
||||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||||
mysql_close(mysql);
|
mysql_close(mysql);
|
||||||
FAIL_IF(elapsed > 2 * timeout, "timeout ignored")
|
FAIL_IF((unsigned int)elapsed > 2 * timeout, "timeout ignored")
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,7 +681,7 @@ int test_connection_timeout2(MYSQL *unused __attribute__((unused)))
|
|||||||
elapsed= time(NULL) - start;
|
elapsed= time(NULL) - start;
|
||||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
diag("elapsed: %lu", (unsigned long)elapsed);
|
||||||
mysql_close(mysql);
|
mysql_close(mysql);
|
||||||
FAIL_IF(elapsed > 2 * timeout, "timeout ignored")
|
FAIL_IF((unsigned int)elapsed > 2 * timeout, "timeout ignored")
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +706,7 @@ int test_connection_timeout3(MYSQL *unused __attribute__((unused)))
|
|||||||
}
|
}
|
||||||
elapsed= time(NULL) - start;
|
elapsed= time(NULL) - start;
|
||||||
diag("elapsed: %lu", (unsigned long)elapsed);
|
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_close(mysql);
|
||||||
mysql= mysql_init(NULL);
|
mysql= mysql_init(NULL);
|
||||||
@@ -737,7 +741,6 @@ static int test_conc118(MYSQL *mysql)
|
|||||||
mysql->options.unused_1= 1;
|
mysql->options.unused_1= 1;
|
||||||
|
|
||||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
mysql_ping(mysql);
|
mysql_ping(mysql);
|
||||||
|
|
||||||
@@ -747,7 +750,6 @@ static int test_conc118(MYSQL *mysql)
|
|||||||
FAIL_IF(mysql->options.unused_1 != 1, "options got lost");
|
FAIL_IF(mysql->options.unused_1 != 1, "options got lost");
|
||||||
|
|
||||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
mysql_ping(mysql);
|
mysql_ping(mysql);
|
||||||
rc= mysql_query(mysql, "SET @a:=1");
|
rc= mysql_query(mysql, "SET @a:=1");
|
||||||
@@ -1021,6 +1023,9 @@ static int test_reset(MYSQL *mysql)
|
|||||||
int rc;
|
int rc;
|
||||||
MYSQL_RES *res;
|
MYSQL_RES *res;
|
||||||
|
|
||||||
|
if (mysql_get_server_version(mysql) < 100200)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
@@ -1071,6 +1076,13 @@ static int test_auth256(MYSQL *my)
|
|||||||
int rc;
|
int rc;
|
||||||
MYSQL_RES *res;
|
MYSQL_RES *res;
|
||||||
my_ulonglong num_rows= 0;
|
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'");
|
rc= mysql_query(my, "SELECT * FROM information_schema.plugins where plugin_name='sha256_password'");
|
||||||
check_mysql_rc(rc, mysql);
|
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");
|
rc= mysql_query(my, "DROP USER IF EXISTS sha256user@localhost");
|
||||||
check_mysql_rc(rc, mysql);
|
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);
|
check_mysql_rc(rc, my);
|
||||||
|
|
||||||
if (!mysql_real_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
|
if (!mysql_real_connect(mysql, hostname, "sha256user", "foo", NULL, port, socketname, 0))
|
||||||
{
|
{
|
||||||
diag("error: %s", mysql_error(mysql));
|
diag("error: %s", mysql_error(mysql));
|
||||||
@@ -1107,7 +1121,8 @@ static int test_auth256(MYSQL *my)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
mysql_close(mysql);
|
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);
|
check_mysql_rc(rc, mysql);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@@ -176,6 +176,8 @@ static int test_cuted_rows(MYSQL *mysql)
|
|||||||
int rc, count;
|
int rc, count;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
|
|
||||||
|
if (!is_mariadb)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
mysql_query(mysql, "DROP TABLE if exists t1");
|
mysql_query(mysql, "DROP TABLE if exists t1");
|
||||||
mysql_query(mysql, "DROP TABLE if exists t2");
|
mysql_query(mysql, "DROP TABLE if exists t2");
|
||||||
|
@@ -98,6 +98,7 @@ static int bug31418_impl()
|
|||||||
MYSQL *mysql;
|
MYSQL *mysql;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
|
||||||
/* Create a new connection. */
|
/* Create a new connection. */
|
||||||
|
|
||||||
mysql= test_connect(NULL);
|
mysql= test_connect(NULL);
|
||||||
@@ -169,7 +170,10 @@ static int bug31418_impl()
|
|||||||
|
|
||||||
static int test_bug31418(MYSQL *unused __attribute__((unused)))
|
static int test_bug31418(MYSQL *unused __attribute__((unused)))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!is_mariadb)
|
||||||
|
return SKIP;
|
||||||
/* Run test case for BUG#31418 for three different connections. */
|
/* Run test case for BUG#31418 for three different connections. */
|
||||||
|
|
||||||
for (i=0; i < 3; i++)
|
for (i=0; i < 3; i++)
|
||||||
@@ -976,7 +980,6 @@ static int test_conc117(MYSQL *unused __attribute__((unused)))
|
|||||||
port, socketname, 0), mysql_error(my));
|
port, socketname, 0), mysql_error(my));
|
||||||
|
|
||||||
mysql_kill(my, mysql_thread_id(my));
|
mysql_kill(my, mysql_thread_id(my));
|
||||||
sleep(5);
|
|
||||||
|
|
||||||
mysql_options(my, MYSQL_OPT_RECONNECT, &reconnect);
|
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");
|
const char *env= getenv("MYSQL_TMP_DIR");
|
||||||
char cnf_file1[FN_REFLEN + 1];
|
char cnf_file1[FN_REFLEN + 1];
|
||||||
|
|
||||||
|
if (travis_test)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
if (!env)
|
if (!env)
|
||||||
env= "/tmp";
|
env= "/tmp";
|
||||||
|
|
||||||
@@ -1082,7 +1088,7 @@ static int test_mdev12965(MYSQL *unused __attribute__((unused)))
|
|||||||
fprintf(fp, "[client]\ndefault-character-set=latin2\nreconnect=1\n");
|
fprintf(fp, "[client]\ndefault-character-set=latin2\nreconnect=1\n");
|
||||||
fclose(fp);
|
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,
|
my_test_connect(mysql, hostname, username, password,
|
||||||
schema, 0, socketname, 0);
|
schema, 0, socketname, 0);
|
||||||
|
|
||||||
@@ -1189,7 +1195,12 @@ static int test_server_status(MYSQL *mysql)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
unsigned int server_status;
|
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);
|
rc= mysql_autocommit(mysql, 1);
|
||||||
mariadb_get_infov(mysql, MARIADB_CONNECTION_SERVER_STATUS, &server_status);
|
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 *socketname = 0;
|
||||||
static char *username = 0;
|
static char *username = 0;
|
||||||
static int force_tls= 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[] =
|
static struct my_option test_options[] =
|
||||||
{
|
{
|
||||||
@@ -216,6 +219,22 @@ int do_verify_prepare_field(MYSQL_RES *result,
|
|||||||
return OK;
|
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 */
|
/* Prepare statement, execute, and process result set for given query */
|
||||||
|
|
||||||
int my_stmt_result(MYSQL *mysql, const char *buff)
|
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) {
|
static int reset_connection(MYSQL *mysql) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc= mysql_change_user(mysql, username, password, schema);
|
if (is_mariadb)
|
||||||
|
rc= mysql_change_user(mysql, username, password, schema);
|
||||||
|
else
|
||||||
|
rc= mysql_reset_connection(mysql);
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
rc= mysql_query(mysql, "SET sql_mode=''");
|
rc= mysql_query(mysql, "SET sql_mode=''");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
@@ -452,6 +474,9 @@ static int reset_connection(MYSQL *mysql) {
|
|||||||
void get_envvars() {
|
void get_envvars() {
|
||||||
char *envvar;
|
char *envvar;
|
||||||
|
|
||||||
|
if (getenv("MYSQL_TEST_TRAVIS"))
|
||||||
|
travis_test= 1;
|
||||||
|
|
||||||
if (!hostname && (envvar= getenv("MYSQL_TEST_HOST")))
|
if (!hostname && (envvar= getenv("MYSQL_TEST_HOST")))
|
||||||
hostname= envvar;
|
hostname= envvar;
|
||||||
if (!username)
|
if (!username)
|
||||||
@@ -504,6 +529,8 @@ MYSQL *my_test_connect(MYSQL *mysql,
|
|||||||
diag("Error: TLS connection not established");
|
diag("Error: TLS connection not established");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (!this_host)
|
||||||
|
get_this_host(mysql);
|
||||||
return mysql;
|
return mysql;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +539,6 @@ void run_tests(struct my_tests_st *test) {
|
|||||||
int i, rc, total=0;
|
int i, rc, total=0;
|
||||||
MYSQL *mysql, *mysql_default= NULL; /* default connection */
|
MYSQL *mysql, *mysql_default= NULL; /* default connection */
|
||||||
|
|
||||||
|
|
||||||
while (test[total].function)
|
while (test[total].function)
|
||||||
total++;
|
total++;
|
||||||
plan(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("Testing against MySQL Server %s", mysql_get_server_info(mysql_default));
|
||||||
diag("Host: %s", mysql_get_host_info(mysql_default));
|
diag("Host: %s", mysql_get_host_info(mysql_default));
|
||||||
diag("Client library: %s", mysql_get_client_info());
|
diag("Client library: %s", mysql_get_client_info());
|
||||||
|
is_mariadb= mariadb_connection(mysql_default);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -567,6 +594,9 @@ void run_tests(struct my_tests_st *test) {
|
|||||||
skip(1, "%s", test[i].skipmsg);
|
skip(1, "%s", test[i].skipmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this_host)
|
||||||
|
free(this_host);
|
||||||
|
|
||||||
if (mysql_default) {
|
if (mysql_default) {
|
||||||
diag("close default");
|
diag("close default");
|
||||||
mysql_close(mysql_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 */
|
/* 1. Status is inited, so prepare should work */
|
||||||
|
|
||||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||||
sleep(5);
|
|
||||||
|
|
||||||
rc= mysql_ping(mysql);
|
rc= mysql_ping(mysql);
|
||||||
check_mysql_rc(rc, 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 */
|
/* 2. Status is prepared, execute should fail */
|
||||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||||
sleep(2);
|
|
||||||
|
|
||||||
rc= mysql_stmt_execute(stmt);
|
rc= mysql_stmt_execute(stmt);
|
||||||
FAIL_IF(!rc, "Error expected");
|
FAIL_IF(!rc, "Error expected");
|
||||||
@@ -1377,7 +1375,7 @@ static int test_long_data_str1(MYSQL *mysql)
|
|||||||
int rc, i, rowcount= 0;
|
int rc, i, rowcount= 0;
|
||||||
char data[255];
|
char data[255];
|
||||||
long length;
|
long length;
|
||||||
size_t max_blob_length, blob_length, length1;
|
unsigned long max_blob_length, blob_length, length1;
|
||||||
my_bool true_value;
|
my_bool true_value;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_BIND my_bind[2];
|
MYSQL_BIND my_bind[2];
|
||||||
@@ -3137,6 +3135,8 @@ static int test_datetime_ranges(MYSQL *mysql)
|
|||||||
MYSQL_BIND my_bind[6];
|
MYSQL_BIND my_bind[6];
|
||||||
MYSQL_TIME tm[6];
|
MYSQL_TIME tm[6];
|
||||||
|
|
||||||
|
if (!is_mariadb)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
stmt_text= "drop table if exists t1";
|
stmt_text= "drop table if exists t1";
|
||||||
rc= mysql_real_query(mysql, stmt_text, (unsigned long)strlen(stmt_text));
|
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 int_data[3]; /* input/output values */
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (!mariadb_connection(mysql))
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
/* set up stored procedure */
|
/* set up stored procedure */
|
||||||
rc = mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
|
rc = mysql_query(mysql, "DROP PROCEDURE IF EXISTS p1");
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
@@ -537,7 +537,6 @@ static int test_bug12744(MYSQL *mysql)
|
|||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||||
|
|
||||||
sleep(4);
|
|
||||||
rc= mysql_ping(mysql);
|
rc= mysql_ping(mysql);
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
@@ -2731,6 +2730,8 @@ static int test_bug5315(MYSQL *mysql)
|
|||||||
const char *stmt_text;
|
const char *stmt_text;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (!is_mariadb)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
stmt_text= "SELECT 1";
|
stmt_text= "SELECT 1";
|
||||||
stmt= mysql_stmt_init(mysql);
|
stmt= mysql_stmt_init(mysql);
|
||||||
@@ -3456,6 +3457,8 @@ static int test_explain_bug(MYSQL *mysql)
|
|||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
if (!is_mariadb)
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
mysql_autocommit(mysql, TRUE);
|
mysql_autocommit(mysql, TRUE);
|
||||||
|
|
||||||
@@ -3803,7 +3806,6 @@ static int test_bug53311(MYSQL *mysql)
|
|||||||
|
|
||||||
/* kill connection */
|
/* kill connection */
|
||||||
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
rc= mysql_kill(mysql, mysql_thread_id(mysql));
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
rc= mysql_stmt_execute(stmt);
|
rc= mysql_stmt_execute(stmt);
|
||||||
FAIL_IF(rc == 0, "Error expected");
|
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));
|
rc= mysql_stmt_prepare(stmt, stmtstr, (unsigned long)strlen(stmtstr));
|
||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
FAIL_IF(mysql_warning_count(mysql) < 2, "expected 2 or more warnings");
|
if (mysql_get_server_version(mysql) >= 100100)
|
||||||
FAIL_IF(mysql_stmt_warning_count(stmt) < 2, "expected 2 or more warnings");
|
{
|
||||||
|
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);
|
mysql_stmt_close(stmt);
|
||||||
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
|
||||||
|
@@ -104,7 +104,7 @@ static int test_multi_result(MYSQL *mysql)
|
|||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
FAIL_IF(int_data[0] != 10 || int_data[1] != 20 || int_data[2] != 30,
|
FAIL_IF(int_data[0] != 10 || int_data[1] != 20 || int_data[2] != 30,
|
||||||
"expected 10 20 30");
|
"expected 10 20 30");
|
||||||
rc= mysql_stmt_next_result(stmt);
|
rc= mysql_stmt_next_result(stmt);
|
||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
rc= mysql_stmt_bind_result(stmt, rs_bind);
|
rc= mysql_stmt_bind_result(stmt, rs_bind);
|
||||||
@@ -112,7 +112,7 @@ static int test_multi_result(MYSQL *mysql)
|
|||||||
rc= mysql_stmt_fetch(stmt);
|
rc= mysql_stmt_fetch(stmt);
|
||||||
FAIL_IF(mysql_stmt_field_count(stmt) != 3, "expected 3 fields");
|
FAIL_IF(mysql_stmt_field_count(stmt) != 3, "expected 3 fields");
|
||||||
FAIL_IF(int_data[0] != 100 || int_data[1] != 200 || int_data[2] != 300,
|
FAIL_IF(int_data[0] != 100 || int_data[1] != 200 || int_data[2] != 300,
|
||||||
"expected 100 200 300");
|
"expected 100 200 300");
|
||||||
|
|
||||||
FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results");
|
FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results");
|
||||||
rc= mysql_stmt_bind_result(stmt, rs_bind);
|
rc= mysql_stmt_bind_result(stmt, rs_bind);
|
||||||
@@ -120,7 +120,7 @@ static int test_multi_result(MYSQL *mysql)
|
|||||||
rc= mysql_stmt_fetch(stmt);
|
rc= mysql_stmt_fetch(stmt);
|
||||||
FAIL_IF(mysql_stmt_field_count(stmt) != 2, "expected 2 fields");
|
FAIL_IF(mysql_stmt_field_count(stmt) != 2, "expected 2 fields");
|
||||||
FAIL_IF(int_data[0] != 200 || int_data[1] != 300,
|
FAIL_IF(int_data[0] != 200 || int_data[1] != 300,
|
||||||
"expected 100 200 300");
|
"expected 100 200 300");
|
||||||
|
|
||||||
FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results");
|
FAIL_IF(mysql_stmt_next_result(stmt) != 0, "expected more results");
|
||||||
FAIL_IF(mysql_stmt_field_count(stmt) != 0, "expected 0 fields");
|
FAIL_IF(mysql_stmt_field_count(stmt) != 0, "expected 0 fields");
|
||||||
|
@@ -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,
|
FAIL_IF(!mysql_real_connect(mysql, hostname, username, password, schema,
|
||||||
port, socketname, 0), mysql_error(mysql));
|
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);
|
rc= mysql_query(mysql, query);
|
||||||
check_mysql_rc(rc,mysql);
|
check_mysql_rc(rc,mysql);
|
||||||
|
|
||||||
sprintf(query, "CREATE USER '%s'@'%s' IDENTIFIED BY '%s'", ssluser, sslhost, sslpw);
|
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);
|
|
||||||
|
|
||||||
sprintf(query, "GRANT ALL ON %s.* TO '%s'@'%s' REQUIRE %s", schema, ssluser, sslhost, is_X509 ? "X509" : "SSL");
|
|
||||||
rc= mysql_query(mysql, query);
|
rc= mysql_query(mysql, query);
|
||||||
check_mysql_rc(rc,mysql);
|
check_mysql_rc(rc,mysql);
|
||||||
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
||||||
@@ -128,6 +127,24 @@ static int test_ssl(MYSQL *mysql)
|
|||||||
}
|
}
|
||||||
mysql_free_result(res);
|
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);
|
mariadb_get_infov(NULL, MARIADB_TLS_LIBRARY, &tls_library);
|
||||||
diag("SSL library: %s", tls_library);
|
diag("SSL library: %s", tls_library);
|
||||||
|
|
||||||
@@ -450,6 +467,8 @@ static int test_conc50_1(MYSQL *unused __attribute__((unused)))
|
|||||||
return SKIP;
|
return SKIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create_ssl_user(ssluser, 0);
|
||||||
|
|
||||||
mysql= mysql_init(NULL);
|
mysql= mysql_init(NULL);
|
||||||
FAIL_IF(!mysql, "Can't allocate memory");
|
FAIL_IF(!mysql, "Can't allocate memory");
|
||||||
|
|
||||||
@@ -460,6 +479,7 @@ static int test_conc50_1(MYSQL *unused __attribute__((unused)))
|
|||||||
if (mysql_errno(mysql))
|
if (mysql_errno(mysql))
|
||||||
diag("Error: %d %s", mysql_errno(mysql), mysql_error(mysql));
|
diag("Error: %d %s", mysql_errno(mysql), mysql_error(mysql));
|
||||||
FAIL_IF(mysql_errno(mysql), "No error expected");
|
FAIL_IF(mysql_errno(mysql), "No error expected");
|
||||||
|
|
||||||
mysql_close(mysql);
|
mysql_close(mysql);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -957,19 +977,23 @@ static int test_openssl_1(MYSQL *mysql)
|
|||||||
if (check_skip_ssl())
|
if (check_skip_ssl())
|
||||||
return SKIP;
|
return SKIP;
|
||||||
|
|
||||||
|
if (!mariadb_connection(mysql))
|
||||||
|
return SKIP;
|
||||||
|
|
||||||
for (i=1; i < 6; i++)
|
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);
|
rc= mysql_query(mysql, query);
|
||||||
check_mysql_rc(rc, mysql);
|
sprintf(query, "CREATE USER 'ssluser%d'@'%s'", i, this_host);
|
||||||
sprintf(query, "CREATE USER 'ssluser%d'@'%s'", i, sslhost);
|
|
||||||
rc= mysql_query(mysql, query);
|
rc= mysql_query(mysql, query);
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
}
|
}
|
||||||
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
rc= mysql_query(mysql, "FLUSH PRIVILEGES");
|
||||||
check_mysql_rc(rc, mysql);
|
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);
|
rc= mysql_query(mysql, query);
|
||||||
check_mysql_rc(rc, mysql);
|
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");
|
FAIL_IF(!mysql_get_ssl_cipher(my), "No TLS connection");
|
||||||
mysql_close(my);
|
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);
|
rc= mysql_query(mysql, query);
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
#ifdef TEST_RANDOM_RESULT
|
||||||
/* ssl_user2: connect with enforce should work */
|
/* ssl_user2: connect with enforce should work */
|
||||||
my= mysql_init(NULL);
|
my= mysql_init(NULL);
|
||||||
mysql_options(my, MYSQL_OPT_SSL_ENFORCE, &val);
|
mysql_options(my, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||||
@@ -1005,8 +1030,21 @@ static int test_openssl_1(MYSQL *mysql)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
mysql_close(my);
|
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);
|
my= mysql_init(NULL);
|
||||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES128-SHA");
|
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES128-SHA");
|
||||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
FAIL_IF(mysql_real_connect(my, hostname, "ssluser2", NULL, schema,
|
||||||
@@ -1014,68 +1052,61 @@ static int test_openssl_1(MYSQL *mysql)
|
|||||||
mysql_close(my);
|
mysql_close(my);
|
||||||
|
|
||||||
|
|
||||||
/* ssl_user2: connect with correct cipher */
|
if (!travis_test)
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
rc= mysql_query(mysql, query);
|
|
||||||
check_mysql_rc(rc, mysql);
|
|
||||||
|
|
||||||
/* ssluser3: connect with cipher only */
|
|
||||||
my= mysql_init(NULL);
|
|
||||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
|
||||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
|
||||||
port, socketname, 0), "Error expected");
|
|
||||||
mysql_close(my);
|
|
||||||
|
|
||||||
/* ssluser3 connect with cipher and certs */
|
|
||||||
my= mysql_init(NULL);
|
|
||||||
mysql_ssl_set(my, sslkey,
|
|
||||||
sslcert,
|
|
||||||
sslca,
|
|
||||||
NULL,
|
|
||||||
"AES256-SHA");
|
|
||||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
|
||||||
port, socketname, 0), mysql_error(my));
|
|
||||||
|
|
||||||
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);
|
|
||||||
rc= mysql_query(mysql, query);
|
|
||||||
check_mysql_rc(rc, mysql);
|
|
||||||
|
|
||||||
/* ssluser4: connect with cipher only */
|
|
||||||
my= mysql_init(NULL);
|
|
||||||
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
|
||||||
FAIL_IF(mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
|
||||||
port, socketname, 0), "Error expected");
|
|
||||||
mysql_close(my);
|
|
||||||
|
|
||||||
/* ssluser4 connect with cipher and certs */
|
|
||||||
my= mysql_init(NULL);
|
|
||||||
mysql_ssl_set(my, sslkey,
|
|
||||||
sslcert,
|
|
||||||
sslca,
|
|
||||||
NULL,
|
|
||||||
"AES256-SHA");
|
|
||||||
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
|
||||||
port, socketname, 0), mysql_error(my));
|
|
||||||
|
|
||||||
for (i=1; i < 6; i++)
|
|
||||||
{
|
{
|
||||||
sprintf(query, "DROP USER IF EXISTS 'ssluser%d'@'%s'", i, sslhost);
|
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, this_host);
|
||||||
rc= mysql_query(mysql, query);
|
rc= mysql_query(mysql, query);
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
/* ssluser3: connect with cipher only */
|
||||||
|
my= mysql_init(NULL);
|
||||||
|
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||||
|
FAIL_IF(mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||||
|
port, socketname, 0), "Error expected");
|
||||||
|
mysql_close(my);
|
||||||
|
|
||||||
|
/* ssluser3 connect with cipher and certs */
|
||||||
|
my= mysql_init(NULL);
|
||||||
|
mysql_ssl_set(my, sslkey,
|
||||||
|
sslcert,
|
||||||
|
sslca,
|
||||||
|
NULL,
|
||||||
|
"AES256-SHA");
|
||||||
|
FAIL_IF(!mysql_real_connect(my, hostname, "ssluser3", NULL, schema,
|
||||||
|
port, socketname, 0), mysql_error(my));
|
||||||
|
|
||||||
|
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, this_host);
|
||||||
|
rc= mysql_query(mysql, query);
|
||||||
|
check_mysql_rc(rc, mysql);
|
||||||
|
|
||||||
|
/* ssluser4: connect with cipher only */
|
||||||
|
my= mysql_init(NULL);
|
||||||
|
mysql_ssl_set(my, NULL, NULL, NULL, NULL, "AES256-SHA");
|
||||||
|
FAIL_IF(mysql_real_connect(my, hostname, "ssluser4", NULL, schema,
|
||||||
|
port, socketname, 0), "Error expected");
|
||||||
|
mysql_close(my);
|
||||||
|
|
||||||
|
/* ssluser4 connect with cipher and certs */
|
||||||
|
my= mysql_init(NULL);
|
||||||
|
mysql_ssl_set(my, sslkey,
|
||||||
|
sslcert,
|
||||||
|
sslca,
|
||||||
|
NULL,
|
||||||
|
"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 'ssluser%d'@'%s'", i, this_host);
|
||||||
|
rc= mysql_query(mysql, query);
|
||||||
}
|
}
|
||||||
mysql_close(my);
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@@ -1195,8 +1226,6 @@ static int test_mdev14101(MYSQL *my __attribute__((unused)))
|
|||||||
bool skip_tlsv12= !have_openssl;
|
bool skip_tlsv12= !have_openssl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
diag("%d %d", skip_tlsv12, have_openssl);
|
|
||||||
|
|
||||||
for (i=0; combinations[i].expected; i++)
|
for (i=0; combinations[i].expected; i++)
|
||||||
{
|
{
|
||||||
MYSQL *mysql;
|
MYSQL *mysql;
|
||||||
@@ -1205,7 +1234,9 @@ static int test_mdev14101(MYSQL *my __attribute__((unused)))
|
|||||||
|
|
||||||
if (!combinations[i].do_yassl && skip_tlsv12)
|
if (!combinations[i].do_yassl && skip_tlsv12)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
diag("combination: %s", combinations[i].opt_tls_version);
|
||||||
|
|
||||||
mysql= mysql_init(NULL);
|
mysql= mysql_init(NULL);
|
||||||
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &val);
|
mysql_options(mysql, MYSQL_OPT_SSL_ENFORCE, &val);
|
||||||
mysql_options(mysql, MARIADB_OPT_TLS_VERSION, combinations[i].opt_tls_version);
|
mysql_options(mysql, MARIADB_OPT_TLS_VERSION, combinations[i].opt_tls_version);
|
||||||
|
Reference in New Issue
Block a user