From 0441af291c50062b232965b671222909ef0fdd77 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Thu, 24 Aug 2017 10:55:27 -0700 Subject: [PATCH] added checks for server version in the tests --- Dockerfile-msphpsql | 11 ++++++++ source/shared/core_conn.cpp | 5 ++-- .../pdo_connect_encrypted_ksp_errors.phpt | 2 +- .../pdo_sqlsrv/skipif_server_old.inc | 19 ++++++++++++++ test/functional/sqlsrv/skipif_server_old.inc | 25 +++++++++++++++++++ .../sqlsrv_connect_encrypted_ksp_errors.phpt | 2 +- 6 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 test/functional/pdo_sqlsrv/skipif_server_old.inc create mode 100644 test/functional/sqlsrv/skipif_server_old.inc diff --git a/Dockerfile-msphpsql b/Dockerfile-msphpsql index 9a554d95..fcdaba6e 100644 --- a/Dockerfile-msphpsql +++ b/Dockerfile-msphpsql @@ -44,9 +44,20 @@ RUN pip install --upgrade pip && pip install cpp-coveralls #Either Install git / download zip (One can see other strategies : https://ryanfb.github.io/etc/2015/07/29/git_strategies_for_docker.html ) #One option is to get source from zip file of repository. +<<<<<<< HEAD #another option is to copy source to build directory on image RUN mkdir -p $PHPSQLDIR COPY . $PHPSQLDIR +======= + +# another option is to copy source to build directory on image +RUN mkdir -p $PHPSQLDIR +COPY . $PHPSQLDIR + +# copy odbc header file to setup +COPY $PHPSQLDIR/source/shared/msodbcsql.h $PHPSQLDIR/test/functional/setup + +>>>>>>> 328286b... added checks for server version in the tests WORKDIR $PHPSQLDIR/source/ RUN chmod +x ./packagize.sh diff --git a/source/shared/core_conn.cpp b/source/shared/core_conn.cpp index 93a7e8c9..eae1d427 100644 --- a/source/shared/core_conn.cpp +++ b/source/shared/core_conn.cpp @@ -835,9 +835,8 @@ void load_configure_ksp( _Inout_ sqlsrv_conn* conn TSRMLS_DC ) char* encrypt_key = Z_STRVAL_P( conn->ce_option.ksp_encrypt_key ); memcpy_s( pKsd->data, key_size * sizeof( char ) , encrypt_key, key_size ); - // Will uncomment these two lines when it's ready to test with a real custom keystore provider - // core::SQLSetConnectAttr( conn, SQL_COPT_SS_CEKEYSTOREPROVIDER, ksp_path, SQL_NTS ); - // core::SQLSetConnectAttr( conn, SQL_COPT_SS_CEKEYSTOREDATA, reinterpret_cast( pKsd ), SQL_IS_POINTER ); + core::SQLSetConnectAttr( conn, SQL_COPT_SS_CEKEYSTOREPROVIDER, ksp_path, SQL_NTS ); + core::SQLSetConnectAttr( conn, SQL_COPT_SS_CEKEYSTOREDATA, reinterpret_cast( pKsd ), SQL_IS_POINTER ); } void common_conn_str_append_func( const char* odbc_name, const char* val, size_t val_len, std::string& conn_str TSRMLS_DC ) diff --git a/test/functional/pdo_sqlsrv/pdo_connect_encrypted_ksp_errors.phpt b/test/functional/pdo_sqlsrv/pdo_connect_encrypted_ksp_errors.phpt index 9756a361..3b1da719 100644 --- a/test/functional/pdo_sqlsrv/pdo_connect_encrypted_ksp_errors.phpt +++ b/test/functional/pdo_sqlsrv/pdo_connect_encrypted_ksp_errors.phpt @@ -1,7 +1,7 @@ --TEST-- Fetch data from a prepopulated test table given a custom keystore provider --SKIPIF-- - + --FILE-- getAttribute(constant('PDO::ATTR_SERVER_VERSION')); +$version = substr($attr, 0, 2); +if ($version < 13) +{ + die( "skip - feature not supported in this version of SQL Server." ); +} +?> \ No newline at end of file diff --git a/test/functional/sqlsrv/skipif_server_old.inc b/test/functional/sqlsrv/skipif_server_old.inc new file mode 100644 index 00000000..3ee03362 --- /dev/null +++ b/test/functional/sqlsrv/skipif_server_old.inc @@ -0,0 +1,25 @@ +$userName, "PWD"=>$userPassword ); + +$conn = sqlsrv_connect( $server, $connectionInfo ); +if( ! $conn ) +{ + die( "skip - could not connect during SKIPIF." ); +} + +$server_info = sqlsrv_server_info( $conn ); +if( $server_info ) +{ + // check SQL Server version + $version = substr($server_info['SQLServerVersion'], 0, 2); + if ($version < 13) + { + die( "skip - feature not supported in this version of SQL Server." ); + } +} +?> \ No newline at end of file diff --git a/test/functional/sqlsrv/sqlsrv_connect_encrypted_ksp_errors.phpt b/test/functional/sqlsrv/sqlsrv_connect_encrypted_ksp_errors.phpt index a2033c11..be6204e0 100644 --- a/test/functional/sqlsrv/sqlsrv_connect_encrypted_ksp_errors.phpt +++ b/test/functional/sqlsrv/sqlsrv_connect_encrypted_ksp_errors.phpt @@ -1,7 +1,7 @@ --TEST-- Connect using a custom keystore provider with some required inputs missing --SKIPIF-- - + --FILE--