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 541f2da16f..02336f79c6 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java @@ -186,6 +186,13 @@ static void setAEConnectionString(String serverName, String url, String protocol if (enclaveServer.length > 1) { System.out.println("Testing enclave: " + enclaveProperties); } + + // remove the password in connection string + // this is necessary as updateDataSource will only use 1st occurrence + String password = getConfiguredProperty("enclaveServerPassword"); + AETestConnectionString = TestUtils.removeProperty(AETestConnectionString, Constants.PASSWORD); + AETestConnectionString = TestUtils.addOrOverrideProperty(AETestConnectionString, Constants.PASSWORD, + password); } else { AETestConnectionString = connectionString + ";sendTimeAsDateTime=false;columnEncryptionSetting=enabled;"; } diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/callablestatement/CallableStatementTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/callablestatement/CallableStatementTest.java index 5a502dab3c..67dde1fad2 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/callablestatement/CallableStatementTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/callablestatement/CallableStatementTest.java @@ -22,7 +22,6 @@ import java.util.TimeZone; import java.util.UUID; -import org.junit.Assert; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; @@ -41,8 +40,6 @@ import com.microsoft.sqlserver.testframework.AbstractTest; import com.microsoft.sqlserver.testframework.Constants; -import javax.sql.DataSource; - /** * Test CallableStatement @@ -1173,16 +1170,16 @@ public void testFourPartSyntaxCallEscapeSyntax() throws SQLException { } stmt.execute("EXEC sp_addlinkedserver @server='" + linkedServer + "';"); - stmt.execute("EXEC sp_addlinkedsrvlogin @rmtsrvname=N'" + linkedServer + "', @rmtuser=N'" + remoteUser - + "', @rmtpassword=N'" + remotePassword + "'"); + stmt.execute("EXEC sp_addlinkedsrvlogin @rmtsrvname=N'" + linkedServer + "', @useself=false" + + ", @rmtuser=N'" + linkedServerUser + "', @rmtpassword=N'" + linkedServerPassword + "'"); stmt.execute("EXEC sp_serveroption '" + linkedServer + "', 'rpc', true;"); stmt.execute("EXEC sp_serveroption '" + linkedServer + "', 'rpc out', true;"); } SQLServerDataSource ds = new SQLServerDataSource(); ds.setServerName(linkedServer); - ds.setUser(remoteUser); - ds.setPassword(remotePassword); + ds.setUser(linkedServerUser); + ds.setPassword(linkedServerPassword); ds.setEncrypt(false); ds.setTrustServerCertificate(true); diff --git a/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java b/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java index 1ce9cd195c..3590aa7f2f 100644 --- a/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java +++ b/src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java @@ -63,8 +63,8 @@ public abstract class AbstractTest { protected static String[] keyIDs = null; protected static String linkedServer = null; - protected static String remoteUser = null; - protected static String remotePassword = null; + protected static String linkedServerUser = null; + protected static String linkedServerPassword = null; protected static String[] enclaveServer = null; protected static String[] enclaveAttestationUrl = null; protected static String[] enclaveAttestationProtocol = null; @@ -201,8 +201,8 @@ public static void setup() throws Exception { clientKeyPassword = getConfiguredProperty("clientKeyPassword", ""); linkedServer = getConfiguredProperty("linkedServer", null); - remoteUser = getConfiguredProperty("remoteUser", null); - remotePassword = getConfiguredProperty("remotePassword", null); + linkedServerUser = getConfiguredProperty("linkedServerUser", null); + linkedServerPassword = getConfiguredProperty("linkedServerPassword", null); kerberosServer = getConfiguredProperty("kerberosServer", null); kerberosServerPort = getConfiguredProperty("kerberosServerPort", null); @@ -267,7 +267,6 @@ protected static void setupConnectionString() { // If these properties are defined then NTLM is desired, modify connection string accordingly String domain = getConfiguredProperty("domainNTLM"); String user = getConfiguredProperty("userNTLM"); - String password = getConfiguredProperty("passwordNTLM"); if (null != domain) { connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "domain", domain); @@ -277,11 +276,7 @@ protected static void setupConnectionString() { connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "user", user); } - if (null != password) { - connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "password", password); - } - - if (null != user && null != password) { + if (null != user) { connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "authenticationScheme", "NTLM"); connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "integratedSecurity", "true"); @@ -350,6 +345,9 @@ protected static ISQLServerDataSource updateDataSource(String connectionString, case Constants.INTEGRATED_SECURITY: ds.setIntegratedSecurity(Boolean.parseBoolean(value)); break; + case Constants.SERVER_NAME: + ds.setServerName(value); + break; case Constants.USER: case Constants.USER_NAME: ds.setUser(value); diff --git a/src/test/java/com/microsoft/sqlserver/testframework/Constants.java b/src/test/java/com/microsoft/sqlserver/testframework/Constants.java index e4338fc92e..8ed4099453 100644 --- a/src/test/java/com/microsoft/sqlserver/testframework/Constants.java +++ b/src/test/java/com/microsoft/sqlserver/testframework/Constants.java @@ -139,6 +139,8 @@ private Constants() {} public static final String DOMAIN_NAME = "DOMAINNAME"; public static final String DATABASE = "DATABASE"; public static final String DATABASE_NAME = "DATABASENAME"; + public static final String SERVER_NAME = "SERVERNAME"; + public static final String COLUMN_ENCRYPTION_SETTING = "COLUMNENCRYPTIONSETTING"; public static final String DISABLE_STATEMENT_POOLING = "DISABLESTATEMENTPOOLING"; public static final String STATEMENT_POOLING_CACHE_SIZE = "STATEMENTPOOLINGCACHESIZE";