|
5 | 5 | package com.microsoft.sqlserver.jdbc; |
6 | 6 |
|
7 | 7 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 8 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
8 | 9 | import static org.junit.jupiter.api.Assertions.assertThrows; |
9 | 10 | import static org.junit.jupiter.api.Assertions.assertTrue; |
10 | 11 | import static org.junit.jupiter.api.Assertions.fail; |
@@ -1370,4 +1371,35 @@ public void testGetSqlFedAuthTokenFailureNagativeWaiting() throws SQLException { |
1370 | 1371 | } |
1371 | 1372 | } |
1372 | 1373 |
|
| 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 | + |
1373 | 1405 | } |
0 commit comments