Skip to content

Commit aa82054

Browse files
Merge branch 'microsoft:main' into main
2 parents 28ba94a + f452337 commit aa82054

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/AESetup.java

+7
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ static void setAEConnectionString(String serverName, String url, String protocol
186186
if (enclaveServer.length > 1) {
187187
System.out.println("Testing enclave: " + enclaveProperties);
188188
}
189+
190+
// remove the password in connection string
191+
// this is necessary as updateDataSource will only use 1st occurrence
192+
String password = getConfiguredProperty("enclaveServerPassword");
193+
AETestConnectionString = TestUtils.removeProperty(AETestConnectionString, Constants.PASSWORD);
194+
AETestConnectionString = TestUtils.addOrOverrideProperty(AETestConnectionString, Constants.PASSWORD,
195+
password);
189196
} else {
190197
AETestConnectionString = connectionString + ";sendTimeAsDateTime=false;columnEncryptionSetting=enabled;";
191198
}

src/test/java/com/microsoft/sqlserver/jdbc/callablestatement/CallableStatementTest.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.TimeZone;
2323
import java.util.UUID;
2424

25-
import org.junit.Assert;
2625
import org.junit.jupiter.api.AfterAll;
2726
import org.junit.jupiter.api.BeforeAll;
2827
import org.junit.jupiter.api.Tag;
@@ -41,8 +40,6 @@
4140
import com.microsoft.sqlserver.testframework.AbstractTest;
4241
import com.microsoft.sqlserver.testframework.Constants;
4342

44-
import javax.sql.DataSource;
45-
4643

4744
/**
4845
* Test CallableStatement
@@ -1173,16 +1170,16 @@ public void testFourPartSyntaxCallEscapeSyntax() throws SQLException {
11731170
}
11741171

11751172
stmt.execute("EXEC sp_addlinkedserver @server='" + linkedServer + "';");
1176-
stmt.execute("EXEC sp_addlinkedsrvlogin @rmtsrvname=N'" + linkedServer + "', @rmtuser=N'" + remoteUser
1177-
+ "', @rmtpassword=N'" + remotePassword + "'");
1173+
stmt.execute("EXEC sp_addlinkedsrvlogin @rmtsrvname=N'" + linkedServer + "', @useself=false"
1174+
+ ", @rmtuser=N'" + linkedServerUser + "', @rmtpassword=N'" + linkedServerPassword + "'");
11781175
stmt.execute("EXEC sp_serveroption '" + linkedServer + "', 'rpc', true;");
11791176
stmt.execute("EXEC sp_serveroption '" + linkedServer + "', 'rpc out', true;");
11801177
}
11811178

11821179
SQLServerDataSource ds = new SQLServerDataSource();
11831180
ds.setServerName(linkedServer);
1184-
ds.setUser(remoteUser);
1185-
ds.setPassword(remotePassword);
1181+
ds.setUser(linkedServerUser);
1182+
ds.setPassword(linkedServerPassword);
11861183
ds.setEncrypt(false);
11871184
ds.setTrustServerCertificate(true);
11881185

src/test/java/com/microsoft/sqlserver/testframework/AbstractTest.java

+8-10
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public abstract class AbstractTest {
6363
protected static String[] keyIDs = null;
6464

6565
protected static String linkedServer = null;
66-
protected static String remoteUser = null;
67-
protected static String remotePassword = null;
66+
protected static String linkedServerUser = null;
67+
protected static String linkedServerPassword = null;
6868
protected static String[] enclaveServer = null;
6969
protected static String[] enclaveAttestationUrl = null;
7070
protected static String[] enclaveAttestationProtocol = null;
@@ -201,8 +201,8 @@ public static void setup() throws Exception {
201201
clientKeyPassword = getConfiguredProperty("clientKeyPassword", "");
202202

203203
linkedServer = getConfiguredProperty("linkedServer", null);
204-
remoteUser = getConfiguredProperty("remoteUser", null);
205-
remotePassword = getConfiguredProperty("remotePassword", null);
204+
linkedServerUser = getConfiguredProperty("linkedServerUser", null);
205+
linkedServerPassword = getConfiguredProperty("linkedServerPassword", null);
206206

207207
kerberosServer = getConfiguredProperty("kerberosServer", null);
208208
kerberosServerPort = getConfiguredProperty("kerberosServerPort", null);
@@ -267,7 +267,6 @@ protected static void setupConnectionString() {
267267
// If these properties are defined then NTLM is desired, modify connection string accordingly
268268
String domain = getConfiguredProperty("domainNTLM");
269269
String user = getConfiguredProperty("userNTLM");
270-
String password = getConfiguredProperty("passwordNTLM");
271270

272271
if (null != domain) {
273272
connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "domain", domain);
@@ -277,11 +276,7 @@ protected static void setupConnectionString() {
277276
connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "user", user);
278277
}
279278

280-
if (null != password) {
281-
connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "password", password);
282-
}
283-
284-
if (null != user && null != password) {
279+
if (null != user) {
285280
connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "authenticationScheme",
286281
"NTLM");
287282
connectionStringNTLM = TestUtils.addOrOverrideProperty(connectionStringNTLM, "integratedSecurity", "true");
@@ -350,6 +345,9 @@ protected static ISQLServerDataSource updateDataSource(String connectionString,
350345
case Constants.INTEGRATED_SECURITY:
351346
ds.setIntegratedSecurity(Boolean.parseBoolean(value));
352347
break;
348+
case Constants.SERVER_NAME:
349+
ds.setServerName(value);
350+
break;
353351
case Constants.USER:
354352
case Constants.USER_NAME:
355353
ds.setUser(value);

src/test/java/com/microsoft/sqlserver/testframework/Constants.java

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ private Constants() {}
139139
public static final String DOMAIN_NAME = "DOMAINNAME";
140140
public static final String DATABASE = "DATABASE";
141141
public static final String DATABASE_NAME = "DATABASENAME";
142+
public static final String SERVER_NAME = "SERVERNAME";
143+
142144
public static final String COLUMN_ENCRYPTION_SETTING = "COLUMNENCRYPTIONSETTING";
143145
public static final String DISABLE_STATEMENT_POOLING = "DISABLESTATEMENTPOOLING";
144146
public static final String STATEMENT_POOLING_CACHE_SIZE = "STATEMENTPOOLINGCACHESIZE";

0 commit comments

Comments
 (0)