Skip to content

Commit d7b11dd

Browse files
lilgreenbirdJeffery-Wasty
authored andcommitted
Fixed Managed Identity tests (#1935)
Signed-off-by: Jeff Wasty <[email protected]> # Conflicts: # src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted/MSITest.java
1 parent c308a65 commit d7b11dd

File tree

1 file changed

+13
-23
lines changed
  • src/test/java/com/microsoft/sqlserver/jdbc/AlwaysEncrypted

1 file changed

+13
-23
lines changed

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

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,11 @@ public void testMSIAuth() throws SQLException {
5757
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.PASSWORD, "");
5858
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.AUTHENTICATION, "ActiveDirectoryMSI");
5959

60-
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.MSITOKENCACHETTL, "0");
61-
6260
testSimpleConnect(connStr);
6361

64-
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.MSITOKENCACHETTL,
65-
Integer.toString(Integer.MAX_VALUE));
62+
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.AUTHENTICATION, "ActiveDirectoryMSI");
6663

6764
testSimpleConnect(connStr);
68-
69-
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.MSITOKENCACHETTL, "");
70-
71-
testSimpleConnect(connStr); // This call will use a cached token
7265
}
7366

7467
private void testSimpleConnect(String connStr) {
@@ -92,18 +85,10 @@ public void testMSIAuthWithMSIClientId() throws SQLException {
9285
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.AUTHENTICATION, "ActiveDirectoryMSI");
9386
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.MSICLIENTID, msiClientId);
9487

95-
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.MSITOKENCACHETTL, "0");
96-
9788
testSimpleConnect(connStr);
9889

99-
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.MSITOKENCACHETTL,
100-
Integer.toString(Integer.MAX_VALUE));
101-
90+
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.AUTHENTICATION, "ActiveDirectoryMSI");
10291
testSimpleConnect(connStr);
103-
104-
connStr = TestUtils.addOrOverrideProperty(connStr, Constants.MSITOKENCACHETTL, "");
105-
106-
testSimpleConnect(connStr); // This call will use a cached token
10792
}
10893

10994
/*
@@ -123,9 +108,12 @@ public void testDSMSIAuth() throws SQLException {
123108
ds.setAuthentication("ActiveDirectoryMSI");
124109
AbstractTest.updateDataSource(connStr, ds);
125110

126-
try (SQLServerConnection con = (SQLServerConnection) ds.getConnection()) {} catch (Exception e) {
127-
fail(TestResource.getResource("R_loginFailed") + e.getMessage());
128-
}
111+
try (SQLServerConnection con = (SQLServerConnection) ds.getConnection()) {}
112+
113+
ds.setAuthentication("ActiveDirectoryMSI");
114+
AbstractTest.updateDataSource(connStr, ds);
115+
116+
try (SQLServerConnection con = (SQLServerConnection) ds.getConnection()) {}
129117
}
130118

131119
/*
@@ -146,10 +134,12 @@ public void testDSMSIAuthWithMSIClientId() throws SQLException {
146134
ds.setMSIClientId(msiClientId);
147135
AbstractTest.updateDataSource(connStr, ds);
148136

137+
try (SQLServerConnection con = (SQLServerConnection) ds.getConnection()) {}
149138

150-
try (SQLServerConnection con = (SQLServerConnection) ds.getConnection()) {} catch (Exception e) {
151-
fail(TestResource.getResource("R_loginFailed") + e.getMessage());
152-
}
139+
ds.setAuthentication("ActiveDirectoryMSI");
140+
AbstractTest.updateDataSource(connStr, ds);
141+
142+
try (SQLServerConnection con = (SQLServerConnection) ds.getConnection()) {}
153143
}
154144

155145
/*

0 commit comments

Comments
 (0)