This repository has been archived by the owner on May 8, 2019. It is now read-only.
forked from mariadb-corporation/mariadb-connector-c
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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.
- Loading branch information
Showing
23 changed files
with
549 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "$@" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE USER 'bob'@'%'; | ||
GRANT ALL ON *.* TO 'bob'@'%' with grant option; | ||
|
||
FLUSH PRIVILEGES; | ||
|
||
CREATE DATABASE ctest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
before_build: | ||
- ps: >- | ||
cd c:\projects\mariadb-connector-c | ||
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' | ||
|
||
echo running cmake | ||
|
||
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=RelWithDebInfo | ||
configuration: RelWithDebInfo | ||
clone_folder: c:\projects\mariadb-connector-c | ||
before_build: | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.