diff --git a/appveyor.yml b/appveyor.yml index f672aa84..119535e3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -30,7 +30,7 @@ environment: SQL_INSTANCE: SQL2019 PHP_VC: vs16 PHP_MAJOR_VER: 8.0 - PHP_MINOR_VER: 0RC2 + PHP_MINOR_VER: latest PHP_EXE_PATH: Release THREAD: nts platform: x86 @@ -79,7 +79,7 @@ install: } - echo Downloading MSODBCSQL 17 # AppVeyor build works are x64 VMs and 32-bit ODBC driver cannot be installed on it - - ps: (new-object net.webclient).DownloadFile('https://download.microsoft.com/download/6/b/3/6b3dd05c-678c-4e6b-b503-1d66e16ef23d/en-US/17.6.1.1/x64/msodbcsql.msi', 'c:\projects\msodbcsql.msi') + - ps: (new-object net.webclient).DownloadFile('https://download.microsoft.com/download/2/c/c/2cc12eab-a3aa-45d6-95bb-13f968fb6cd6/en-US/17.7.1.1/x64/msodbcsql.msi', 'c:\projects\msodbcsql.msi') - cmd /c start /wait msiexec /i "c:\projects\msodbcsql.msi" /q IACCEPTMSODBCSQLLICENSETERMS=YES ADDLOCAL=ALL - echo Checking the version of MSODBCSQL - reg query "HKLM\SOFTWARE\ODBC\odbcinst.ini\ODBC Driver 17 for SQL Server" diff --git a/test/functional/sqlsrv/MsHelper.inc b/test/functional/sqlsrv/MsHelper.inc index 590e8b33..2e35366a 100644 --- a/test/functional/sqlsrv/MsHelper.inc +++ b/test/functional/sqlsrv/MsHelper.inc @@ -33,6 +33,7 @@ class ColumnMeta public $options; // a string that is null by default (e.g. NOT NULL Identity (1,1) ) protected $encryptable; // whether Always Encrypted supports this column + protected $forcedEncrypt; // force column encryption regardless, default to 'false' public function __construct($dataType, $colName = null, $options = null, $deterministic = true, $noEncrypt = false) { @@ -41,6 +42,8 @@ class ColumnMeta } else { $this->colName = $colName; } + + $this->forcedEncrypt = false; $this->encType = ($deterministic ? "deterministic" : "randomized"); if (empty($dataType)) { @@ -79,6 +82,16 @@ class ColumnMeta $this->encryptable = true; } } + + /** + * force column to be encrypted regardless of the current settings + * @return void + */ + public function forceEncryption($forceEncryption) + { + $this->forcedEncrypt = $forceEncryption; + } + /** * @return string column definition for creating a table */ @@ -86,9 +99,12 @@ class ColumnMeta { $append = " "; - if ($this->encryptable && isDataEncrypted()) { + if (($this->encryptable && isDataEncrypted()) || $this->forcedEncrypt) { $cekName = getCekName(); + if ($this->forcedEncrypt && empty($cekName)) { + $cekName = 'AEColumnKey'; // Use Windows AE key by default + } if (stripos($this->dataType, "char") !== false) { $append .= "COLLATE Latin1_General_BIN2 "; } diff --git a/test/functional/sqlsrv/sqlsrv_ae_fetch_phptypes.phpt b/test/functional/sqlsrv/sqlsrv_ae_fetch_phptypes.phpt index c492a961..3c47a00a 100644 --- a/test/functional/sqlsrv/sqlsrv_ae_fetch_phptypes.phpt +++ b/test/functional/sqlsrv/sqlsrv_ae_fetch_phptypes.phpt @@ -1,9 +1,24 @@ --TEST-- Test insert data and fetch as all possible php types --DESCRIPTION-- -Test insert data of most common column types and fetch them all as possible php types +Test insert data of most common column types and fetch them all as possible php types. +This test requires the Always Encrypted feature. --SKIPIF-- - + $database, "UID" => $userName, "PWD" => $userPassword); +$conn = sqlsrv_connect($server, $options); +if (! $conn) { + die("Skip Could not connect during SKIPIF!"); +} +if (!AE\isQualified($conn)) { + die("skip AE feature not supported in the current environment."); +} +?> --FILE-- forceEncryption($forceEncryption); + $columns[] = $anAEcolumn; $columns[] = new AE\ColumnMeta($dataTypes[$i], "c_".$colname, null, true, true); $queryTypes .= "c_"."$colname, "; $queryTypes .= "c_"."$colname"."_AE, "; @@ -66,7 +86,7 @@ set_time_limit(0); sqlsrv_configure('WarningsReturnAsErrors', 1); // Connect -$connectionInfo = array("CharacterSet"=>"UTF-8"); +$connectionInfo = array('CharacterSet'=>'UTF-8', 'ColumnEncryption' => 'Enabled'); $conn = AE\connect($connectionInfo); if (!$conn) { fatalError("Could not connect.\n"); diff --git a/test/functional/sqlsrv/sqlsrv_ae_type_conversion_select.phpt b/test/functional/sqlsrv/sqlsrv_ae_type_conversion_select.phpt index d4ea1c94..f1571dbc 100644 --- a/test/functional/sqlsrv/sqlsrv_ae_type_conversion_select.phpt +++ b/test/functional/sqlsrv/sqlsrv_ae_type_conversion_select.phpt @@ -1,13 +1,30 @@ --TEST-- Test fetching data by conversion with CAST in the SELECT statement --DESCRIPTION-- -This test checks the allowed data type conversions in SELECT statements under Always Encrypted and non-encrypted +This test requires the Always Encrypted feature and checks the allowed data type conversions in +SELECT statements under Always Encrypted and non-encrypted Reference chart for conversions found at https://www.microsoft.com/en-us/download/details.aspx?id=35834 --SKIPIF-- - + $database, "UID" => $userName, "PWD" => $userPassword); +$conn = sqlsrv_connect($server, $options); +if (! $conn) { + die("Skip Could not connect during SKIPIF!"); +} +if (!AE\isQualified($conn)) { + die("skip AE feature not supported in the current environment."); +} +?> --FILE-- forceEncryption($forceEncryption); + $columns[] = $anAEcolumn; + $columns[] = new AE\ColumnMeta($dataTypes[$i], "c_".$colname, null, true, true); + $queryTypes .= "c_"."$colname, "; + $queryTypes .= "c_"."$colname"."_AE, "; + $valuesString .= "?, ?, "; + } + + $queryTypes = substr($queryTypes, 0, -2).")"; + $valuesString = substr($valuesString, 0, -2).")"; + + $insertQuery = "INSERT INTO $tableName ".$queryTypes." ".$valuesString; +} + // Build the select queries. We want every combination of types for conversion // testing, so the matrix of queries selects every type from every column // and convert using CAST. @@ -154,7 +201,7 @@ $conversionMatrixAE = array(array('y','y','y','x','x','x','x','x','x','x','x','x set_time_limit(0); sqlsrv_configure('WarningsReturnAsErrors', 1); -$connectionInfo = array("CharacterSet"=>"UTF-8"); +$connectionInfo = array('CharacterSet'=>'UTF-8', 'ColumnEncryption' => 'Enabled'); $conn = AE\connect($connectionInfo); if (!$conn) { fatalError("Could not connect.\n");