Skip to content

Commit 010cbc4

Browse files
author
Divang Sharma
committed
Added test cases to support Fedauth in connection resiliency case
1 parent 4400fcd commit 010cbc4

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/test/java/com/microsoft/sqlserver/jdbc/fedauth/FedauthCommon.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public class FedauthCommon extends AbstractTest {
145145
static final String ERR_MSG_REQUEST_THROTTLED = "Request was throttled";
146146
static final String ERR_FAILED_FEDAUTH = TestResource.getResource("R_failedFedauth");
147147

148-
enum SqlAuthentication {
148+
public enum SqlAuthentication {
149149
NotSpecified,
150150
SqlPassword,
151151
ActiveDirectoryPassword,

src/test/java/com/microsoft/sqlserver/jdbc/resiliency/BasicConnectionTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,20 @@ public void testUnprocessedResponseCountSuccessfulIdleConnectionRecovery() throw
491491
}
492492
}
493493

494+
@Test
495+
public void testAccessTokenInReconnect() throws SQLException {
496+
// Should use adIntegratedConnectionStr
497+
try (Connection c = DriverManager.getConnection(adIntegratedConnectionStr);
498+
Statement s = c.createStatement()) {
499+
s.executeQuery("SELECT 1");
500+
ResiliencyUtils.killConnection(c, adIntegratedConnectionStr, 0);
501+
s.executeQuery("SELECT 1");
502+
} catch (SQLException e) {
503+
fail(TestResource.getResource("R_expectedFailPassed"));
504+
}
505+
}
506+
507+
494508
private void basicReconnect(String connectionString) throws SQLException {
495509
// Ensure reconnects can happen multiple times over the same connection and subsequent connections
496510
for (int i1 = 0; i1 < 2; i1++) {

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.microsoft.sqlserver.jdbc.SQLServerXADataSource;
5151
import com.microsoft.sqlserver.jdbc.TestResource;
5252
import com.microsoft.sqlserver.jdbc.TestUtils;
53+
import com.microsoft.sqlserver.jdbc.fedauth.FedauthCommon.SqlAuthentication;
5354

5455

5556
/**
@@ -118,6 +119,10 @@ public abstract class AbstractTest {
118119
protected static String connectionString = null;
119120
protected static String connectionStringNTLM;
120121
protected static String connectionStringKerberos;
122+
123+
protected static String azureServer = null;
124+
protected static String azureDatabase = null;
125+
protected static String adIntegratedConnectionStr;
121126

122127
protected static ConfidentialClientApplication fedauthClientApp = null;
123128

@@ -184,6 +189,11 @@ public static void setup() throws Exception {
184189
connectionString = TestUtils.addOrOverrideProperty(connectionString, "trustServerCertificate",
185190
trustServerCertificate);
186191

192+
azureServer = getConfiguredProperty("azureServer");
193+
azureDatabase = getConfiguredProperty("azureDatabase");
194+
adIntegratedConnectionStr = "jdbc:sqlserver://" + azureServer + ";database=" + azureDatabase
195+
+ ";Authentication=" + SqlAuthentication.ActiveDirectoryIntegrated.toString();
196+
187197
javaKeyPath = TestUtils.getCurrentClassPath() + Constants.JKS_NAME;
188198

189199
keyIDs = getConfiguredProperty("keyID", "").split(Constants.SEMI_COLON);

0 commit comments

Comments
 (0)