From c87af63d5728fb46ff0490000594f586337c8038 Mon Sep 17 00:00:00 2001 From: Jenny Tam Date: Wed, 22 Sep 2021 09:40:57 -0700 Subject: [PATCH] Updated tests to run against AE v2 server (#1305) --- azure-pipelines.yml | 2 ++ .../pdo_sqlsrv/MsCommon_mid-refactor.inc | 19 +++++++++++++++++++ .../pdo_sqlsrv/pdo_azure_ad_access_token.phpt | 2 +- .../pdo_sqlsrv/pdo_connect_encrypted.phpt | 13 ++++--------- test/functional/pdo_sqlsrv/pdo_construct.phpt | 3 ++- .../pdo_construct_conn_options.phpt | 3 ++- test/functional/pdo_sqlsrv/skipif_azure.inc | 6 ++++++ test/functional/pdo_sqlsrv/skipif_not_hgs.inc | 2 +- test/functional/sqlsrv/MsCommon.inc | 15 +++++++++++++++ test/functional/sqlsrv/skipif_azure.inc | 4 ++++ test/functional/sqlsrv/skipif_not_hgs.inc | 2 +- .../sqlsrv/sqlsrv_azure_ad_access_token.phpt | 2 +- .../sqlsrv/sqlsrv_connect_encrypted.phpt | 8 ++------ 13 files changed, 60 insertions(+), 21 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 57824f77..944cc954 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -206,10 +206,12 @@ jobs: coveralls -i ./source/ -e ./source/shared/ -e ./test/ -e ./source/pdo_sqlsrv/shared/core_stream.cpp \ -E r'.*localization*' -E r'.*globalization*' --gcov-options '\-lp' displayName: 'Invoke coveralls using repo token' + condition: false env: COVERALLS_REPO_TOKEN: $(repo_token) TRAVIS_JOB_ID: $(Build.BuildId) TRAVIS_BRANCH: $(Build.SourceBranchName) + PYTHONWARNINGS: ignore::yaml.YAMLLoadWarning - script: | cd $(Build.SourcesDirectory)/test/functional/ diff --git a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc index 44d88454..5c120200 100644 --- a/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc +++ b/test/functional/pdo_sqlsrv/MsCommon_mid-refactor.inc @@ -636,6 +636,25 @@ function IsDaasMode() return ($daasMode ? true : false); } +function isServerHGSEnabled() +{ + $enabled = false; + try { + $conn = connect(); + $tsql = "SELECT @@SERVERNAME"; + $stmt = $conn->query($tsql); + + $result = $stmt->fetch(PDO::FETCH_NUM); + $name = $result[0]; + + $enabled = (strpos($result[0], 'HGS') != false); + } catch (Exception $e) { + echo $e->getMessage(); + die("Could not fetch server property."); + } + return $enabled; +} + function isSQLAzure() { // 'SQL Azure' indicates SQL Database or SQL Data Warehouse diff --git a/test/functional/pdo_sqlsrv/pdo_azure_ad_access_token.phpt b/test/functional/pdo_sqlsrv/pdo_azure_ad_access_token.phpt index ce36df03..56f271a4 100644 --- a/test/functional/pdo_sqlsrv/pdo_azure_ad_access_token.phpt +++ b/test/functional/pdo_sqlsrv/pdo_azure_ad_access_token.phpt @@ -3,7 +3,7 @@ Test some basics of Azure AD Access Token support --DESCRIPTION-- This test also expects certain exceptions to be thrown under some conditions. --SKIPIF-- - --FILE-- --FILE-- getAttribute(PDO::ATTR_CLIENT_VERSION)['DriverVer']; $version = explode(".", $msodbcsqlVer); $msodbcsqlMaj = $version[0]; - - // Next, check if the server is HGS enabled - $serverInfo = $conn->getAttribute(PDO::ATTR_SERVER_INFO); - if (strpos($serverInfo['SQLServerName'], 'PHPHGS') === false) { - $hgsEnabled = false; - } } catch (PDOException $e) { echo "Failed to connect\n"; print_r($e->getMessage()); @@ -32,7 +28,6 @@ try { testColumnEncryption($server, $uid, $pwd, $msodbcsqlMaj); echo "Done"; - function verifyOutput($PDOerror, $expected, $caseNum) { if (strpos($PDOerror->getMessage(), $expected) === false) { diff --git a/test/functional/pdo_sqlsrv/pdo_construct.phpt b/test/functional/pdo_sqlsrv/pdo_construct.phpt index eba2c640..d5ab56d6 100644 --- a/test/functional/pdo_sqlsrv/pdo_construct.phpt +++ b/test/functional/pdo_sqlsrv/pdo_construct.phpt @@ -1,7 +1,8 @@ --TEST-- Test PDO::__Construct by passing connection options and attributes. --SKIPIF-- - + --FILE-- + --FILE-- \ No newline at end of file diff --git a/test/functional/pdo_sqlsrv/skipif_not_hgs.inc b/test/functional/pdo_sqlsrv/skipif_not_hgs.inc index ccf177ab..a7d72bb6 100644 --- a/test/functional/pdo_sqlsrv/skipif_not_hgs.inc +++ b/test/functional/pdo_sqlsrv/skipif_not_hgs.inc @@ -34,7 +34,7 @@ if ($msodbcsqlMin < 4 and $msodbcsqlMaj == 17) { // Get SQL Server $serverInfo = $conn->getAttribute(PDO::ATTR_SERVER_INFO); -if (strpos($serverInfo['SQLServerName'], 'PHPHGS') === false) { +if (strpos($serverInfo['SQLServerName'], 'HGS') === false) { die("skip Server is not HGS enabled"); } ?> \ No newline at end of file diff --git a/test/functional/sqlsrv/MsCommon.inc b/test/functional/sqlsrv/MsCommon.inc index ddefaac6..cc260a77 100644 --- a/test/functional/sqlsrv/MsCommon.inc +++ b/test/functional/sqlsrv/MsCommon.inc @@ -94,6 +94,21 @@ function isLocaleDisabled() return ($daasMode || $localeDisabled); } +function isServerHGSEnabled() +{ + $conn = connect(); + $tsql = "SELECT @@SERVERNAME"; + $stmt = sqlsrv_query($conn, $tsql); + + if (sqlsrv_fetch($stmt)) { + $name = sqlsrv_get_field($stmt, 0); + if (strpos($name, 'HGS') != false) { + return true; + } + } + return false; +} + function isSQLAzure() { // 'SQL Azure' indicates SQL Database or SQL Data Warehouse diff --git a/test/functional/sqlsrv/skipif_azure.inc b/test/functional/sqlsrv/skipif_azure.inc index 81c557a1..caffc08e 100644 --- a/test/functional/sqlsrv/skipif_azure.inc +++ b/test/functional/sqlsrv/skipif_azure.inc @@ -7,4 +7,8 @@ if (!extension_loaded("sqlsrv")) { require 'MsSetup.inc'; if ($daasMode) die("skip test not applicable in Azure\n"); +require 'MsCommon.inc'; +if (isServerHGSEnabled()) { + die("skip test not applicable in Azure VM\n"); +} ?> \ No newline at end of file diff --git a/test/functional/sqlsrv/skipif_not_hgs.inc b/test/functional/sqlsrv/skipif_not_hgs.inc index 5295a73a..be0c822f 100644 --- a/test/functional/sqlsrv/skipif_not_hgs.inc +++ b/test/functional/sqlsrv/skipif_not_hgs.inc @@ -34,7 +34,7 @@ if ($msodbcsql_min < 4 and $msodbcsql_maj == 17) { // Get SQL Server $server_info = sqlsrv_server_info($conn); -if (strpos($server_info['SQLServerName'], 'PHPHGS') === false) { +if (strpos($server_info['SQLServerName'], 'HGS') === false) { die("skip Server is not HGS enabled"); } ?> diff --git a/test/functional/sqlsrv/sqlsrv_azure_ad_access_token.phpt b/test/functional/sqlsrv/sqlsrv_azure_ad_access_token.phpt index fcbc4080..62c1e3d1 100644 --- a/test/functional/sqlsrv/sqlsrv_azure_ad_access_token.phpt +++ b/test/functional/sqlsrv/sqlsrv_azure_ad_access_token.phpt @@ -3,7 +3,7 @@ Test some basics of Azure AD Access Token support --DESCRIPTION-- This test also expects certain exceptions to be thrown under some conditions. --SKIPIF-- - --FILE-- $database,"UID"=>$userName, "PWD"=>$userPassword); testColumnEncryption($server, $connectionOptions); @@ -25,11 +25,7 @@ function testColumnEncryption($server, $connectionOptions) $msodbcsqlMaj = explode(".", $msodbcsql_ver)[0]; // Next, check if the server is HGS enabled - $hgsEnabled = true; - $serverInfo = sqlsrv_server_info($conn); - if (strpos($serverInfo['SQLServerName'], 'PHPHGS') === false) { - $hgsEnabled = false; - } + $hgsEnabled = isServerHGSEnabled(); // Only works for ODBC 17 $connectionOptions['ColumnEncryption'] = 'Enabled';