Fixed failing tests (#981)

This commit is contained in:
Jenny Tam 2019-04-26 16:30:15 -07:00 committed by GitHub
parent e8d13896ba
commit c5b6540498
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 23 deletions

View file

@ -5,7 +5,7 @@ Verifies that the problem is no longer reproducible.
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_mid-refactor.inc'); ?>
<?php require('skipif.inc'); ?>
--FILE--
<?php
require_once("MsSetup.inc");
@ -16,21 +16,22 @@ try {
// 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);
$qualified = isAEQualified($conn);
if ($qualified) {
unset($conn);
// Now connect with ColumnEncryption enabled
$connectionInfo = "ColumnEncryption = Enabled;";
$conn = new PDO("sqlsrv:server = $server; database=$databaseName; $connectionInfo", $uid, $pwd);
}
// 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);
$tableName = 'pdoTestTable_569';
dropTable($conn, $tableName);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
if ($qualified && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$tsql = "CREATE TABLE $tableName ([c1] varchar(max) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = deterministic, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = AEColumnKey))";
} else {
$tsql = "CREATE TABLE $tableName ([c1] varchar(max))";

View file

@ -73,12 +73,15 @@ function invalidCredentials()
$options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
$error1 = "*Login failed for user \'*\'.";
$error2 = "*Login timeout expired*";
$error3 = "*Could not open a connection to SQL Server*";
try {
$conn = new PDO("sqlsrv:server = $server; database = $database;", $user, $passwd, $options);
echo "Should have failed to connect\n";
} catch (PDOException $e) {
if (fnmatch($error1, $e->getMessage()) || fnmatch($error2, $e->getMessage())) {
if (fnmatch($error1, $e->getMessage()) ||
fnmatch($error2, $e->getMessage()) ||
fnmatch($error3, $e->getMessage())) {
; // matched at least one of the expected error messages
} else {
echo "invalidCredentials()\n";

View file

@ -5,7 +5,7 @@ Verifies that the problem is no longer reproducible.
--ENV--
PHPT_EXEC=true
--SKIPIF--
<?php require('skipif_versions_old.inc'); ?>
<?php require('skipif.inc'); ?>
--FILE--
<?php
@ -27,24 +27,23 @@ if ($conn === false) {
fatalError("Failed to connect to $server.");
}
if (!AE\isQualified($conn)) {
echo "Done\n";
return;
}
sqlsrv_close($conn);
$qualified = AE\isQualified($conn);
if ($qualified) {
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.");
// 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.");
}
}
$tableName = 'srvTestTable_569';
dropTable($conn, $tableName);
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
if ($qualified && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$tsql = "CREATE TABLE $tableName ([c1] varchar(max) COLLATE Latin1_General_BIN2 ENCRYPTED WITH (ENCRYPTION_TYPE = deterministic, ALGORITHM = 'AEAD_AES_256_CBC_HMAC_SHA_256', COLUMN_ENCRYPTION_KEY = AEColumnKey))";
} else {
$tsql = "CREATE TABLE $tableName ([c1] varchar(max))";