Merge pull request #793 from yitam/addDriverOption
Added the driver option to run functional tests
This commit is contained in:
commit
ea6381c34b
|
@ -8,30 +8,6 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//
|
|
||||||
// looks like an additional file (in addition to pdo_test_base.inc) may be needed for these PHPTs
|
|
||||||
// to be runnable from the MSSQL teams' internal proprietary test running system
|
|
||||||
//
|
|
||||||
|
|
||||||
function IsAEQualified($conn)
|
|
||||||
{
|
|
||||||
$msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"];
|
|
||||||
$msodbcsql_maj = explode(".", $msodbcsql_ver)[0];
|
|
||||||
if ($msodbcsql_maj < 17) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
require 'MsSetup.inc';
|
|
||||||
if ($daasMode) {
|
|
||||||
// running against Azure
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// if not Azure, check the server version
|
|
||||||
$server_ver = $conn->getAttribute(PDO::ATTR_SERVER_VERSION);
|
|
||||||
if (explode('.', $server_ver)[0] < 13)
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TO BE DELETED
|
// TO BE DELETED
|
||||||
function connect($options=array())
|
function connect($options=array())
|
||||||
{
|
{
|
||||||
|
@ -40,7 +16,7 @@ function connect($options=array())
|
||||||
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
|
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
|
||||||
// which does not support switching databases
|
// which does not support switching databases
|
||||||
require 'MsSetup.inc';
|
require 'MsSetup.inc';
|
||||||
$conn = new PDO( "sqlsrv:Server=$server;database=$databaseName;ConnectionPooling=false;" , $uid, $pwd, $options);
|
$conn = new PDO( "sqlsrv:Server=$server;database=$databaseName;Driver=$driver;ConnectionPooling=false;" , $uid, $pwd, $options);
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
||||||
return $conn;
|
return $conn;
|
||||||
}
|
}
|
||||||
|
@ -58,138 +34,6 @@ function connect($options=array())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connect to the database specified in MsSetup.inc; Column Encryption keywords automatically added when $keystore is not none
|
|
||||||
* @param string $keywords : string to append to the dsn string in PDO::_construct
|
|
||||||
* @param array $options : attributes to pass to PDO::_construct
|
|
||||||
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
|
|
||||||
* for testing fetching encrypted data when connection column encryption is off
|
|
||||||
* @return PDO connection object
|
|
||||||
*/
|
|
||||||
function ae_connect( $keywords='', $options=array(), $disableCE = false )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
|
|
||||||
// which does not support switching databases
|
|
||||||
require 'MsSetup.inc';
|
|
||||||
$dsn = "sqlsrv:Server=$server;database=$databaseName;ConnectionPooling=false;";
|
|
||||||
if ( $keystore != "none" && !$disableCE )
|
|
||||||
{
|
|
||||||
$dsn .= "ColumnEncryption=Enabled;";
|
|
||||||
}
|
|
||||||
if ( $keystore == "ksp" && !$disableCE )
|
|
||||||
{
|
|
||||||
require( 'AE_Ksp.inc' );
|
|
||||||
$ksp_path = getKSPPath();
|
|
||||||
$dsn .= "CEKeystoreProvider=$ksp_path;CEKeystoreName=$ksp_name;CEKeystoreEncryptKey=$encrypt_key;";
|
|
||||||
}
|
|
||||||
if ( $keywords )
|
|
||||||
{
|
|
||||||
$dsn .= $keywords;
|
|
||||||
}
|
|
||||||
$conn = new PDO( $dsn, $uid, $pwd, $options );
|
|
||||||
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
|
|
||||||
return $conn;
|
|
||||||
}
|
|
||||||
catch( PDOException $e )
|
|
||||||
{
|
|
||||||
var_dump( $e );
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
catch(Exception $e)
|
|
||||||
{
|
|
||||||
var_dump( $e );
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string CEK name depending on the connection keywords
|
|
||||||
*/
|
|
||||||
function getCekName()
|
|
||||||
{
|
|
||||||
require 'MsSetup.inc';
|
|
||||||
$cekName = '';
|
|
||||||
switch ( $keystore ) {
|
|
||||||
case "none":
|
|
||||||
$cekName = '';
|
|
||||||
break;
|
|
||||||
case "win":
|
|
||||||
$cekName = 'AEColumnKey';
|
|
||||||
break;
|
|
||||||
case "ksp":
|
|
||||||
$cekName = 'CustomCEK';
|
|
||||||
break;
|
|
||||||
case "akv":
|
|
||||||
$cekName = 'AKVColumnKey';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
echo "getCekName: Invalid keystore name.\n";
|
|
||||||
}
|
|
||||||
return $cekName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* class for encapsulating column metadata needed for creating a table
|
|
||||||
*/
|
|
||||||
class columnMeta {
|
|
||||||
public $colName;
|
|
||||||
public $dataType; //a string that includes the size of the type if necessary (e.g., decimal(10,5))
|
|
||||||
public $encType; //randomized or deterministic; default is deterministic
|
|
||||||
public $options; //a string that is null by default (e.g. NOT NULL Identity (1,1) )
|
|
||||||
|
|
||||||
function __construct( $dataType, $colName = null, $options = null, $encType = "deterministic" )
|
|
||||||
{
|
|
||||||
if ( is_null( $colName ))
|
|
||||||
{
|
|
||||||
$this->colName = get_default_colname( $dataType );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->colName = $colName;
|
|
||||||
}
|
|
||||||
$this->dataType = $dataType;
|
|
||||||
$this->encType = $encType;
|
|
||||||
$this->options = $options;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @return string column definition for creating a table
|
|
||||||
*/
|
|
||||||
function getColDef()
|
|
||||||
{
|
|
||||||
require 'MsSetup.inc';
|
|
||||||
$append = " ";
|
|
||||||
|
|
||||||
// an identity column is not encrypted because a select query with identity column as the where clause is often run and the user want to have to bind parameter every time
|
|
||||||
if ( $keystore != "none" && stripos( $this->options, "identity" ) === false )
|
|
||||||
{
|
|
||||||
$cekName = getCekName();
|
|
||||||
if ( stripos( $this->dataType, "char" ) !== false )
|
|
||||||
$append .= "COLLATE Latin1_General_BIN2 ";
|
|
||||||
$append .= sprintf( "ENCRYPTED WITH (ENCRYPTION_TYPE = %s, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = $cekName) ", $this->encType );
|
|
||||||
}
|
|
||||||
$append .= $this->options;
|
|
||||||
$colDef = "[" . $this->colName . "] " . $this->dataType . $append;
|
|
||||||
return $colDef;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string default column name when a name is not provided in the columnMeta class
|
|
||||||
*/
|
|
||||||
function get_default_colname( $dataType )
|
|
||||||
{
|
|
||||||
$colName = "c_" . str_replace( ",", "_", str_replace( "(", "_", $dataType ));
|
|
||||||
$colName = rtrim( $colName, ")" );
|
|
||||||
return $colName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a table
|
* Create a table
|
||||||
* @param object $conn : PDO connection object
|
* @param object $conn : PDO connection object
|
||||||
|
|
|
@ -13,10 +13,6 @@
|
||||||
// to be runnable from the MSSQL teams' internal proprietary test running system
|
// to be runnable from the MSSQL teams' internal proprietary test running system
|
||||||
//
|
//
|
||||||
|
|
||||||
const KSP_NAME = 'MyCustomKSPName';
|
|
||||||
const ENCRYPT_KEY = 'LPKCWVD07N3RG98J0MBLG4H2';
|
|
||||||
const KSP_TEST_TABLE = 'CustomKSPTestTable';
|
|
||||||
|
|
||||||
function isAEQualified($conn)
|
function isAEQualified($conn)
|
||||||
{
|
{
|
||||||
$msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"];
|
$msodbcsql_ver = $conn->getAttribute(PDO::ATTR_CLIENT_VERSION)["DriverVer"];
|
||||||
|
@ -52,7 +48,7 @@ function connect($keywords = '', $options=array(), $errmode = PDO::ERRMODE_EXCEP
|
||||||
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
|
// simply use $databaseName from MsSetup.inc to facilitate testing in Azure,
|
||||||
// which does not support switching databases
|
// which does not support switching databases
|
||||||
require("MsSetup.inc");
|
require("MsSetup.inc");
|
||||||
$dsn = getDSN($server, $databaseName, $keywords, $disableCE);
|
$dsn = getDSN($server, $databaseName, $driver, $keywords, $disableCE);
|
||||||
$conn = new PDO($dsn, $uid, $pwd, $options);
|
$conn = new PDO($dsn, $uid, $pwd, $options);
|
||||||
if ($errmode == PDO::ERRMODE_EXCEPTION || $errmode == PDO::ERRMODE_WARNING || $errmode == PDO::ERRMODE_SILENT) {
|
if ($errmode == PDO::ERRMODE_EXCEPTION || $errmode == PDO::ERRMODE_WARNING || $errmode == PDO::ERRMODE_SILENT) {
|
||||||
$conn->setAttribute(PDO::ATTR_ERRMODE, $errmode);
|
$conn->setAttribute(PDO::ATTR_ERRMODE, $errmode);
|
||||||
|
@ -76,7 +72,7 @@ function connect($keywords = '', $options=array(), $errmode = PDO::ERRMODE_EXCEP
|
||||||
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
|
* @param bool $disableCE : flag for disabling column encryption even when keystore is NOT none
|
||||||
* @return string dsn string used for PDO constructor
|
* @return string dsn string used for PDO constructor
|
||||||
*/
|
*/
|
||||||
function getDSN($sqlsrvserver, $database, $keywords = '', $disableCE = false)
|
function getDSN($sqlsrvserver, $database, $driver, $keywords = '', $disableCE = false)
|
||||||
{
|
{
|
||||||
require("MsSetup.inc");
|
require("MsSetup.inc");
|
||||||
$dsn = "";
|
$dsn = "";
|
||||||
|
@ -89,6 +85,9 @@ function getDSN($sqlsrvserver, $database, $keywords = '', $disableCE = false)
|
||||||
if ($database) {
|
if ($database) {
|
||||||
$dsn .= "database=$database;";
|
$dsn .= "database=$database;";
|
||||||
}
|
}
|
||||||
|
if ($driver) {
|
||||||
|
$dsn .= "driver=$driver;";
|
||||||
|
}
|
||||||
if ($keystore != "none" && !$disableCE) {
|
if ($keystore != "none" && !$disableCE) {
|
||||||
$dsn .= "ColumnEncryption=Enabled;";
|
$dsn .= "ColumnEncryption=Enabled;";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ if (isset($_ENV['MSSQL_SERVER']) || isset($_ENV['MSSQL_USER']) || isset($_ENV['M
|
||||||
$uid = 'TARGET_USERNAME';
|
$uid = 'TARGET_USERNAME';
|
||||||
$pwd = 'TARGET_PASSWORD';
|
$pwd = 'TARGET_PASSWORD';
|
||||||
$databaseName = 'TARGET_DATABASE';
|
$databaseName = 'TARGET_DATABASE';
|
||||||
$DriverName = "ODBC Driver 11 for SQL Server";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$adServer = 'TARGET_AD_SERVER';
|
$adServer = 'TARGET_AD_SERVER';
|
||||||
|
@ -27,13 +26,12 @@ $adUser = 'TARGET_AD_USERNAME';
|
||||||
$adPassword = 'TARGET_AD_PASSWORD';
|
$adPassword = 'TARGET_AD_PASSWORD';
|
||||||
|
|
||||||
$driverType = true;
|
$driverType = true;
|
||||||
$PhpDriver = "ODBC Driver 11 for SQL Server";
|
$driver = "ODBC Driver 17 for SQL Server";
|
||||||
|
|
||||||
$tableName = 'pdo_test_table';
|
$tableName = 'pdo_test_table';
|
||||||
$tableIndex = 'php_test_table_idx';
|
$tableIndex = 'php_test_table_idx';
|
||||||
$procName = 'php_test_proc';
|
$procName = 'php_test_proc';
|
||||||
$fileName = 'php_test_file.dat';
|
$fileName = 'php_test_file.dat';
|
||||||
$dsn = "odbc:Driver={$DriverName};Server=$server";
|
|
||||||
$connectionOptions = array();
|
$connectionOptions = array();
|
||||||
$daasMode = false;
|
$daasMode = false;
|
||||||
$marsMode = true;
|
$marsMode = true;
|
||||||
|
|
|
@ -15,7 +15,7 @@ try {
|
||||||
// Invalid connection attempt => errors are expected
|
// Invalid connection attempt => errors are expected
|
||||||
$serverName="InvalidServerName";
|
$serverName="InvalidServerName";
|
||||||
|
|
||||||
$dsn = getDSN($serverName, $databaseName);
|
$dsn = getDSN($serverName, $databaseName, $driver);
|
||||||
$conn1 = new PDO($dsn, $uid, $pwd, $connectionOptions);
|
$conn1 = new PDO($dsn, $uid, $pwd, $connectionOptions);
|
||||||
if ($conn1) {
|
if ($conn1) {
|
||||||
printf("Invalid connection attempt should have failed.\n");
|
printf("Invalid connection attempt should have failed.\n");
|
||||||
|
|
|
@ -12,6 +12,8 @@ try {
|
||||||
|
|
||||||
// Create table
|
// Create table
|
||||||
$tableName = 'bindParams';
|
$tableName = 'bindParams';
|
||||||
|
dropTable($conn, $tableName);
|
||||||
|
|
||||||
$sql = "CREATE TABLE $tableName (ID TINYINT, SID CHAR(5))";
|
$sql = "CREATE TABLE $tableName (ID TINYINT, SID CHAR(5))";
|
||||||
$stmt = $conn->exec($sql);
|
$stmt = $conn->exec($sql);
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ try {
|
||||||
|
|
||||||
// Create table
|
// Create table
|
||||||
$tableName = 'pdo_040test';
|
$tableName = 'pdo_040test';
|
||||||
|
dropTable($conn, $tableName);
|
||||||
|
|
||||||
// common function insertRow() is not used here since the test deliberately
|
// common function insertRow() is not used here since the test deliberately
|
||||||
// executes an invalid insertion statement
|
// executes an invalid insertion statement
|
||||||
// thus it's not necessary to create an encrypted column for testing column encryption
|
// thus it's not necessary to create an encrypted column for testing column encryption
|
||||||
|
|
|
@ -13,7 +13,7 @@ require_once("MsCommon_mid-refactor.inc");
|
||||||
try {
|
try {
|
||||||
echo "Testing a connection with ATTR_PERSISTENT...\n";
|
echo "Testing a connection with ATTR_PERSISTENT...\n";
|
||||||
// setting PDO::ATTR_PERSISTENT in PDO constructor returns an exception
|
// setting PDO::ATTR_PERSISTENT in PDO constructor returns an exception
|
||||||
$dsn = getDSN($server, $databaseName);
|
$dsn = getDSN($server, $databaseName, $driver);
|
||||||
$attr = array(PDO::ATTR_PERSISTENT => true);
|
$attr = array(PDO::ATTR_PERSISTENT => true);
|
||||||
$conn = new PDO($dsn, $uid, $pwd, $attr);
|
$conn = new PDO($dsn, $uid, $pwd, $attr);
|
||||||
//free the connection
|
//free the connection
|
||||||
|
|
|
@ -10,7 +10,7 @@ require_once("MsSetup.inc");
|
||||||
require_once("MsCommon_mid-refactor.inc");
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
try {
|
try {
|
||||||
echo "Testing a connection with ATTR_PREFETCH before ERRMODE_EXCEPTION...\n";
|
echo "Testing a connection with ATTR_PREFETCH before ERRMODE_EXCEPTION...\n";
|
||||||
$dsn = getDSN($server, $databaseName);
|
$dsn = getDSN($server, $databaseName, $driver);
|
||||||
|
|
||||||
$attr = array(PDO::ATTR_PREFETCH => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
|
$attr = array(PDO::ATTR_PREFETCH => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
|
||||||
$conn = new PDO($dsn, $uid, $pwd, $attr);
|
$conn = new PDO($dsn, $uid, $pwd, $attr);
|
||||||
|
|
|
@ -29,6 +29,7 @@ $colMetaArr = array("c1_int" => "int",
|
||||||
createTable($conn, $tbname, $colMetaArr);
|
createTable($conn, $tbname, $colMetaArr);
|
||||||
// Create a Store Procedure
|
// Create a Store Procedure
|
||||||
$spname = 'selectAllColumns';
|
$spname = 'selectAllColumns';
|
||||||
|
dropProc($conn, $spname);
|
||||||
$spSql = "CREATE PROCEDURE $spname (
|
$spSql = "CREATE PROCEDURE $spname (
|
||||||
@c1_int int OUTPUT, @c2_smallint smallint OUTPUT,
|
@c1_int int OUTPUT, @c2_smallint smallint OUTPUT,
|
||||||
@c3_tinyint tinyint OUTPUT, @c4_bit bit OUTPUT,
|
@c3_tinyint tinyint OUTPUT, @c4_bit bit OUTPUT,
|
||||||
|
|
|
@ -4,6 +4,7 @@ UTF-8 connection strings
|
||||||
<?php require('skipif_mid-refactor.inc'); ?>
|
<?php require('skipif_mid-refactor.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
require_once("MsSetup.inc");
|
||||||
require_once("MsCommon_mid-refactor.inc");
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
$server = 'localhost';
|
$server = 'localhost';
|
||||||
|
@ -11,7 +12,7 @@ $databaseName = 'test';
|
||||||
$uid = 'sa';
|
$uid = 'sa';
|
||||||
$pwd = 'Sunshine4u';
|
$pwd = 'Sunshine4u';
|
||||||
|
|
||||||
$dsn = getDSN($server, $databaseName);
|
$dsn = getDSN($server, $databaseName, $driver);
|
||||||
// test an invalid connection credentials
|
// test an invalid connection credentials
|
||||||
$c = new PDO($dsn, $uid, $pwd);
|
$c = new PDO($dsn, $uid, $pwd);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,11 @@ if (!extension_loaded("pdo") || !extension_loaded('pdo_sqlsrv')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once("MsSetup.inc");
|
require_once("MsSetup.inc");
|
||||||
|
if ($driver != "ODBC Driver 17 for SQL Server") {
|
||||||
|
// the testing is not set to use ODBC 17
|
||||||
|
die("skip - AE feature not supported in the current environment.");
|
||||||
|
}
|
||||||
|
|
||||||
require_once("MsCommon_mid-refactor.inc");
|
require_once("MsCommon_mid-refactor.inc");
|
||||||
|
|
||||||
$dsn = getDSN($server, null);
|
$dsn = getDSN($server, null);
|
||||||
|
|
|
@ -1,36 +1,49 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
retrieval of names of column master key and column encryption key generated in the database setup
|
Test the existence of Windows Always Encrypted keys generated in the database setup
|
||||||
--SKIPIF--
|
--DESCRIPTION--
|
||||||
<?php require('skipif_unix.inc'); ?>
|
This test iterates through the rows of sys.column_master_keys and/or
|
||||||
--FILE--
|
sys.column_encryption_keys to look for the specific column master key and
|
||||||
<?php
|
column encryption key generated in the database setup
|
||||||
sqlsrv_configure( 'WarningsReturnAsErrors', 0 );
|
--SKIPIF--
|
||||||
sqlsrv_configure( 'LogSeverity', SQLSRV_LOG_SEVERITY_ALL );
|
<?php require('skipif_unix.inc'); ?>
|
||||||
|
--FILE--
|
||||||
require( 'MsCommon.inc' );
|
<?php
|
||||||
$conn = Connect();
|
require_once('MsCommon_mid-refactor.inc');
|
||||||
|
$conn = connect();
|
||||||
if (IsAEQualified($conn)){
|
|
||||||
$query = "SELECT name FROM sys.column_master_keys";
|
if (isAEQualified($conn)){
|
||||||
$stmt = $conn->query($query);
|
$query = "SELECT name FROM sys.column_master_keys";
|
||||||
$master_key_row = $stmt->fetch();
|
$stmt = $conn->query($query);
|
||||||
|
|
||||||
$query = "SELECT name FROM sys.column_encryption_keys";
|
// Do not assume the master key must be the first one created
|
||||||
$stmt = $conn->query($query);
|
$found = false;
|
||||||
$encryption_key_row = $stmt->fetch();
|
while ($master_key_row = $stmt->fetch()) {
|
||||||
|
if ($master_key_row[0] == 'AEMasterKey') {
|
||||||
if ($master_key_row[0] == 'AEMasterKey' && $encryption_key_row[0] == 'AEColumnKey'){
|
$found = true;
|
||||||
echo "Test Successfully done.\n";
|
}
|
||||||
}
|
}
|
||||||
else {
|
if (!$found) {
|
||||||
die("Column Master Key and Column Encryption Key not created.\n");
|
die("Windows Column Master Key not created.\n");
|
||||||
}
|
}
|
||||||
unset($stmt);
|
|
||||||
}
|
// Do not assume the encryption key must be the first one created
|
||||||
else {
|
$query = "SELECT name FROM sys.column_encryption_keys";
|
||||||
echo "Test Successfully done.\n";
|
$stmt = $conn->query($query);
|
||||||
}
|
|
||||||
unset($conn);
|
$found = false;
|
||||||
?>
|
while ($encryption_key_row = $stmt->fetch()) {
|
||||||
--EXPECT--
|
if ($encryption_key_row[0] == 'AEColumnKey') {
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$found) {
|
||||||
|
die("Windows Column Encryption Key not created.\n");
|
||||||
|
}
|
||||||
|
unset($stmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Test Successfully done.\n";
|
||||||
|
unset($conn);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
Test Successfully done.
|
Test Successfully done.
|
|
@ -18,7 +18,9 @@ $tableIndex = "php_test_table_index";
|
||||||
$procName = "php_test_proc";
|
$procName = "php_test_proc";
|
||||||
$fileName = "php_test_file.dat";
|
$fileName = "php_test_file.dat";
|
||||||
|
|
||||||
$connectionOptions = array("Database"=>$database, "UID"=>$userName, "PWD"=>$userPassword, "TraceOn"=>false);
|
$driver = "ODBC Driver 17 for SQL Server";
|
||||||
|
|
||||||
|
$connectionOptions = array("Database" => $database, "UID" => $userName, "PWD" => $userPassword, "TraceOn" => false, "Driver" => $driver);
|
||||||
$daasMode = false;
|
$daasMode = false;
|
||||||
$marsMode = true;
|
$marsMode = true;
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,12 @@ if (! extension_loaded("sqlsrv")) {
|
||||||
die("skip extension not loaded");
|
die("skip extension not loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_once("MsSetup.inc");
|
||||||
|
if ($driver != "ODBC Driver 17 for SQL Server") {
|
||||||
|
// the testing is not set to use ODBC 17
|
||||||
|
die("skip - AE feature not supported in the current environment.");
|
||||||
|
}
|
||||||
|
|
||||||
require_once('MsCommon.inc');
|
require_once('MsCommon.inc');
|
||||||
|
|
||||||
$conn = AE\connect();
|
$conn = AE\connect();
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
retrieval of names of column master key and column encryption key generated in the database setup
|
Test the existence of Windows Always Encrypted keys generated in the database setup
|
||||||
|
--DESCRIPTION--
|
||||||
|
This test iterates through the rows of sys.column_master_keys and/or
|
||||||
|
sys.column_encryption_keys to look for the specific column master key and
|
||||||
|
column encryption key generated in the database setup
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php require('skipif_unix.inc'); ?>
|
<?php require('skipif_unix.inc'); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
|
@ -13,23 +17,34 @@ $conn = connect();
|
||||||
if (AE\IsQualified($conn)) {
|
if (AE\IsQualified($conn)) {
|
||||||
$query = "SELECT name FROM sys.column_master_keys";
|
$query = "SELECT name FROM sys.column_master_keys";
|
||||||
$stmt = sqlsrv_query($conn, $query);
|
$stmt = sqlsrv_query($conn, $query);
|
||||||
sqlsrv_fetch($stmt);
|
$found = false;
|
||||||
$master_key_name = sqlsrv_get_field($stmt, 0);
|
while (sqlsrv_fetch($stmt)) {
|
||||||
|
$master_key_name = sqlsrv_get_field($stmt, 0);
|
||||||
|
if ($master_key_name == 'AEMasterKey') {
|
||||||
|
$found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// $master_key_name = sqlsrv_get_field($stmt, 0);
|
||||||
|
if (!$found) {
|
||||||
|
die("Windows Column Master Key not created.\n");
|
||||||
|
}
|
||||||
|
|
||||||
$query = "SELECT name FROM sys.column_encryption_keys";
|
$query = "SELECT name FROM sys.column_encryption_keys";
|
||||||
$stmt = sqlsrv_query($conn, $query);
|
$stmt = sqlsrv_query($conn, $query);
|
||||||
sqlsrv_fetch($stmt);
|
$found = false;
|
||||||
$encryption_key_name = sqlsrv_get_field($stmt, 0);
|
while (sqlsrv_fetch($stmt)) {
|
||||||
|
$encryption_key_name = sqlsrv_get_field($stmt, 0);
|
||||||
if ($master_key_name == 'AEMasterKey' && $encryption_key_name == 'AEColumnKey') {
|
if ($encryption_key_name == 'AEColumnKey') {
|
||||||
echo "Test Successfully done.\n";
|
$found = true;
|
||||||
} else {
|
}
|
||||||
echo "Column Master Key and Column Encryption Key not created.\n";
|
}
|
||||||
|
if (!$found) {
|
||||||
|
die("Windows Column Encryption Key not created.\n");
|
||||||
}
|
}
|
||||||
sqlsrv_free_stmt($stmt);
|
sqlsrv_free_stmt($stmt);
|
||||||
} else {
|
|
||||||
echo "Test Successfully done.\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo "Test Successfully done.\n";
|
||||||
sqlsrv_close($conn);
|
sqlsrv_close($conn);
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
|
|
Loading…
Reference in a new issue