php-sqlsrv/test/functional/sqlsrv/test_ae_keys_setup.phpt
David Puglielli 051328782d
Always Encrypted v2 support (#1045)
* Change to support ae-v2

* Add support for AE V2

* Added some descriptions and comments

* Fixed PDO pattern matching

* Updated key generation scripts

* Fixed key script

* Fixed char/nchar results, fixed formatting issues

* Addressed review comments

* Updated key scripts

* Debugging aev2 keyword failure

* Debugging aev2 keyword failure

* Debugging aev2 keyword failure

* Debugging aev2 keyword failure

* Added skipif to ae v2 keyword test

* Addressed review comments

* Fixed braces and camel caps

* Updated test descriptions

* Added detail to test descriptions

* Tiny change
2019-10-31 16:55:36 -07:00

52 lines
1.5 KiB
PHP

--TEST--
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--
<?php require('skipif_unix.inc'); ?>
--FILE--
<?php
sqlsrv_configure('WarningsReturnAsErrors', 0);
sqlsrv_configure('LogSeverity', SQLSRV_LOG_SEVERITY_ALL);
require_once('MsCommon.inc');
$conn = connect();
if (AE\IsQualified($conn)) {
$query = "SELECT name FROM sys.column_master_keys";
$stmt = sqlsrv_query($conn, $query);
$found = false;
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";
$stmt = sqlsrv_query($conn, $query);
$found = false;
while (sqlsrv_fetch($stmt)) {
$encryption_key_name = sqlsrv_get_field($stmt, 0);
if ($encryption_key_name == 'AEColumnKey') {
$found = true;
}
}
if (!$found) {
die("Windows Column Encryption Key not created.\n");
}
sqlsrv_free_stmt($stmt);
}
echo "Test successfully done.\n";
sqlsrv_close($conn);
?>
--EXPECT--
Test successfully done.