Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CallableStatements test to use defined credentials and some test config changes #2393

Merged
merged 9 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ static void setAEConnectionString(String serverName, String url, String protocol
if (enclaveServer.length > 1) {
System.out.println("Testing enclave: " + enclaveProperties);
}

String password = getConfiguredProperty("enclaveServerPassword");
AETestConnectionString = TestUtils.addOrOverrideProperty(AETestConnectionString, Constants.PASSWORD,
password);
} else {
AETestConnectionString = connectionString + ";sendTimeAsDateTime=false;columnEncryptionSetting=enabled;";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,20 +1173,21 @@ 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);

try (Connection linkedServerConnection = ds.getConnection();
// Statement stmt = linkedServerConnection.createStatement()) {
lilgreenbird marked this conversation as resolved.
Show resolved Hide resolved
Statement stmt = linkedServerConnection.createStatement()) {
stmt.execute(
"create or alter procedure dbo.TestAdd(@Num1 int, @Num2 int, @Result int output) as begin set @Result = @Num1 + @Num2; end;");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand Down