Skip to content

Commit

Permalink
Fixed failing tests (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam authored Apr 26, 2019
1 parent e8d1389 commit c5b6540
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
19 changes: 10 additions & 9 deletions test/functional/pdo_sqlsrv/pdo_569_query_varcharmax.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
$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);
}
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);

$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))";
Expand Down
5 changes: 4 additions & 1 deletion test/functional/pdo_sqlsrv/pdo_construct_attr_errors.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
23 changes: 11 additions & 12 deletions test/functional/sqlsrv/srv_569_query_varcharmax.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))";
Expand Down

0 comments on commit c5b6540

Please sign in to comment.