From 05c2fe367a14d4be2f1a1e357233da3ba5ab62d8 Mon Sep 17 00:00:00 2001 From: lilgreenbird Date: Wed, 27 Nov 2019 11:47:57 -0800 Subject: [PATCH] review updates --- .../jdbc/AlwaysEncrypted/AESetup.java | 4 ++-- .../JDBCEncryptionDecryptionTest.java | 24 ++++++++----------- .../sqlserver/testframework/AbstractTest.java | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java index c8b1a8ff9..6344ccf13 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java @@ -163,12 +163,12 @@ public static void setUpConnection() throws TestAbortedException, Exception { readFromFile(Constants.JAVA_KEY_STORE_FILENAME, "Alias name"); - String enclaveAttestationUrl = System.getProperty("enclaveAttestationUrl"); + String enclaveAttestationUrl = getConfiguredProperty("enclaveAttestationUrl"); if (null != enclaveAttestationUrl) { AETestConnectionString = TestUtils.addOrOverrideProperty(AETestConnectionString, "enclaveAttestationUrl", enclaveAttestationUrl); } - String enclaveAttestationProtocol = System.getProperty("enclaveAttestationProtocol"); + String enclaveAttestationProtocol = getConfiguredProperty("enclaveAttestationProtocol"); if (null != enclaveAttestationProtocol) { AETestConnectionString = TestUtils.addOrOverrideProperty(AETestConnectionString, "enclaveAttestationProtocol", enclaveAttestationProtocol); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java index 3aa0bd677..0e51d0adc 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/JDBCEncryptionDecryptionTest.java @@ -1776,8 +1776,8 @@ void testChars(SQLServerStatement stmt, String cekName, String[][] table, String testChar(null, values); if (isTestEnclave) { - if (null == System.getProperty(Constants.ENCLAVE_ATTESTATIONURL) - || null == System.getProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { + if (null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONURL) + || null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { fail(TestResource.getResource("R_reqExternalSetup")); } @@ -1815,8 +1815,8 @@ void testBinaries(SQLServerStatement stmt, String cekName, String[][] table, Lin testBinary(null, values); if (isTestEnclave) { - if (null == System.getProperty(Constants.ENCLAVE_ATTESTATIONURL) - || null == System.getProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { + if (null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONURL) + || null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { fail(TestResource.getResource("R_reqExternalSetup")); } @@ -1858,8 +1858,8 @@ void testDates(SQLServerStatement stmt, String cekName, String[][] table, Linked testDate(null, values); if (isTestEnclave) { - if (null == System.getProperty(Constants.ENCLAVE_ATTESTATIONURL) - || null == System.getProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { + if (null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONURL) + || null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { fail(TestResource.getResource("R_reqExternalSetup")); } @@ -1897,8 +1897,8 @@ void testNumerics(SQLServerStatement stmt, String cekName, String[][] table, Str testNumeric(null, values2, isNull); if (isTestEnclave) { - if (null == System.getProperty(Constants.ENCLAVE_ATTESTATIONURL) - || null == System.getProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { + if (null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONURL) + || null == getConfiguredProperty(Constants.ENCLAVE_ATTESTATIONPROTOCOL)) { fail(TestResource.getResource("R_reqExternalSetup")); } @@ -1920,14 +1920,10 @@ public String getAccessToken(String authority, String resource, String scope) { ClientCredential cred = new ClientCredential(applicationClientID, applicationKey); Future future = context.acquireToken(resource, cred, null); result = future.get(); - return result.getAccessToken(); } catch (Exception e) { - e.printStackTrace(); - return null; + fail(TestResource.getResource("R_unexpectedException") + e.getMessage()); } - - // return null; + return result.getAccessToken(); } }; - } diff --git a/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java b/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java index 1bbb879df..98c63a83e 100644 --- a/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java +++ b/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java @@ -410,7 +410,7 @@ private static void isSqlAzureOrAzureDW(Connection con) throws SQLException { * @param key * @return property value */ - private static String getConfiguredProperty(String key) { + protected static String getConfiguredProperty(String key) { String value = System.getProperty(key); if (null == value && null != configProperties) {