refactor KSP related tests

This commit is contained in:
v-kaywon 2017-12-05 09:54:11 -08:00
parent 0bb4703e2b
commit aa04104bb2
3 changed files with 16 additions and 28 deletions

View file

@ -4,19 +4,11 @@ Fetch data from a prepopulated test table given a custom keystore provider
<?php require('skipif_not_ksp.inc'); ?>
--FILE--
<?php
require( 'MsSetup.inc' );
require( 'AE_Ksp.inc' );
$ksp_path = getKSPpath();
$connectionInfo = "Database = $databaseName; ColumnEncryption = Enabled; ";
$connectionInfo .= "CEKeystoreProvider = $ksp_path; ";
$connectionInfo .= "CEKeystoreName = $ksp_name; ";
$connectionInfo .= "CEKeystoreEncryptKey = $encrypt_key; ";
require_once("MsCommon_mid-refactor.inc");
try
{
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo", $uid, $pwd );
$conn = connect();
echo "Connected successfully with ColumnEncryption enabled and KSP specified.\n";
}
catch( PDOException $e )
@ -26,15 +18,16 @@ Fetch data from a prepopulated test table given a custom keystore provider
echo "\n";
}
$tsql = "SELECT * FROM CustomKSPTestTable";
$tbname = KSP_TEST_TABLE;
$tsql = "SELECT * FROM $tbname";
$stmt = $conn->query($tsql);
while ($row = $stmt->fetch(PDO::FETCH_NUM))
{
echo "c1=" . $row[0] . "\tc2=" . $row[1] . "\tc3=" . $row[2] . "\tc4=" . $row[3] . "\n";
}
$stmt = null;
$conn = null;
unset($stmt);
unset($conn);
echo "Done\n";

View file

@ -4,19 +4,11 @@ Fetch encrypted data from a prepopulated test table given a custom keystore prov
<?php require('skipif_not_ksp.inc'); ?>
--FILE--
<?php
require( 'MsSetup.inc' );
require( 'AE_Ksp.inc' );
$ksp_path = getKSPpath();
$connectionInfo = "Database = $databaseName; ";
$connectionInfo .= "CEKeystoreProvider = $ksp_path; ";
$connectionInfo .= "CEKeystoreName = $ksp_name; ";
$connectionInfo .= "CEKeystoreEncryptKey = $encrypt_key; ";
require_once("MsCommon_mid-refactor.inc");
try
{
$conn = new PDO( "sqlsrv:server = $server ; $connectionInfo", $uid, $pwd );
$conn = connect();
echo "Connected successfully with ColumnEncryption disabled and KSP specified.\n";
}
catch( PDOException $e )
@ -26,7 +18,8 @@ Fetch encrypted data from a prepopulated test table given a custom keystore prov
echo "\n";
}
$tsql = "SELECT * FROM CustomKSPTestTable";
$tbname = KSP_TEST_TABLE;
$tsql = "SELECT * FROM $tbname";
$stmt = $conn->query($tsql);
while ($row = $stmt->fetch(PDO::FETCH_NUM))
{
@ -37,8 +30,8 @@ Fetch encrypted data from a prepopulated test table given a custom keystore prov
echo "\n" ;
}
$stmt = null;
$conn = null;
unset($stmt);
unset($conn);
echo "Done\n";

View file

@ -4,8 +4,8 @@ Connect using a custom keystore provider with some required inputs missing
<?php require('skipif_not_ksp.inc'); ?>
--FILE--
<?php
require( 'MsSetup.inc' );
require( 'AE_Ksp.inc' );
require("MsSetup.inc");
require_once("MsCommon_mid-refactor.inc");
function connect( $connectionInfo )
{
@ -25,6 +25,8 @@ Connect using a custom keystore provider with some required inputs missing
}
$ksp_path = getKSPpath();
$ksp_name = KSP_NAME;
$encrypt_key = ENCRYPT_KEY;
echo("Connecting... with column encryption\n");
$connectionInfo = "Database = $databaseName; ColumnEncryption = Enabled; ";