Skip to content

Commit 89c9911

Browse files
committed
Added test case testManagedIdentityWithEncryptStrict
1 parent 4dbaeee commit 89c9911

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/test/java/com/microsoft/sqlserver/jdbc/SQLServerConnectionTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package com.microsoft.sqlserver.jdbc;
66

77
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertNotNull;
89
import static org.junit.jupiter.api.Assertions.assertThrows;
910
import static org.junit.jupiter.api.Assertions.assertTrue;
1011
import static org.junit.jupiter.api.Assertions.fail;
@@ -1370,4 +1371,35 @@ public void testGetSqlFedAuthTokenFailureNagativeWaiting() throws SQLException {
13701371
}
13711372
}
13721373

1374+
@Test
1375+
@Tag(Constants.xAzureSQLDW)
1376+
@Tag(Constants.xAzureSQLMI)
1377+
@Tag(Constants.xSQLv11)
1378+
@Tag(Constants.xSQLv12)
1379+
@Tag(Constants.xSQLv14)
1380+
@Tag(Constants.xSQLv15)
1381+
@Tag(Constants.xSQLv16)
1382+
public void testManagedIdentityWithEncryptStrict() {
1383+
SQLServerDataSource ds = new SQLServerDataSource();
1384+
1385+
String connectionUrl = connectionString;
1386+
if (connectionUrl.contains("user=")) {
1387+
connectionUrl = TestUtils.removeProperty(connectionUrl, "user");
1388+
}
1389+
if (connectionUrl.contains("password=")) {
1390+
connectionUrl = TestUtils.removeProperty(connectionUrl, "password");
1391+
}
1392+
1393+
ds.setURL(connectionUrl);
1394+
ds.setAuthentication("ActiveDirectoryMSI");
1395+
ds.setEncrypt("strict");
1396+
ds.setHostNameInCertificate("*.database.windows.net");
1397+
1398+
try (Connection con = ds.getConnection()) {
1399+
assertNotNull(con);
1400+
} catch (SQLException e) {
1401+
fail("Connection failed: " + e.getMessage());
1402+
}
1403+
}
1404+
13731405
}

0 commit comments

Comments
 (0)