Modified to check if qualified for AE connections (#967)

This commit is contained in:
Jenny Tam 2019-04-09 15:30:24 -07:00 committed by GitHub
parent 8ba932b1ca
commit 1e4f014727
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View file

@ -12,6 +12,17 @@ require_once("MsSetup.inc");
require_once("MsCommon_mid-refactor.inc");
try {
// This test requires to connect with the Always Encrypted feature
// First check if the system is qualified to run this test
$dsn = getDSN($server, null);
$conn = new PDO($dsn, $uid, $pwd);
if (!isAEQualified($conn)) {
echo "Done\n";
return;
}
unset($conn);
// Now connect with ColumnEncryption enabled
$connectionInfo = "ColumnEncryption = Enabled;";
$conn = new PDO("sqlsrv:server = $server; database=$databaseName; $connectionInfo", $uid, $pwd);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

View file

@ -19,7 +19,22 @@ function verifyFetchError()
require_once('MsCommon.inc');
$connectionOptions = array("Database" => $database, "UID" => $userName, "PWD" => $userPassword, "ColumnEncryption" => "Enabled");
// This test requires to connect with the Always Encrypted feature
// First check if the system is qualified to run this test
$options = array("Database" => $database, "UID" => $userName, "PWD" => $userPassword);
$conn = sqlsrv_connect($server, $options);
if ($conn === false) {
fatalError("Failed to connect to $server.");
}
if (!AE\isQualified($conn)) {
echo "Done\n";
return;
}
sqlsrv_close($conn);
// Now connect with ColumnEncryption enabled
$connectionOptions = array_merge($options, array('ColumnEncryption' => 'Enabled'));
$conn = sqlsrv_connect($server, $connectionOptions);
if ($conn === false) {
fatalError("Failed to connect to $server.");