Skip to content

Commit

Permalink
Added test case testManagedIdentityWithEncryptStrict
Browse files Browse the repository at this point in the history
  • Loading branch information
muskan124947 committed Feb 13, 2025
1 parent 4dbaeee commit 89c9911
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package com.microsoft.sqlserver.jdbc;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
Expand Down Expand Up @@ -1370,4 +1371,35 @@ public void testGetSqlFedAuthTokenFailureNagativeWaiting() throws SQLException {
}
}

@Test
@Tag(Constants.xAzureSQLDW)
@Tag(Constants.xAzureSQLMI)
@Tag(Constants.xSQLv11)
@Tag(Constants.xSQLv12)
@Tag(Constants.xSQLv14)
@Tag(Constants.xSQLv15)
@Tag(Constants.xSQLv16)
public void testManagedIdentityWithEncryptStrict() {
SQLServerDataSource ds = new SQLServerDataSource();

String connectionUrl = connectionString;
if (connectionUrl.contains("user=")) {
connectionUrl = TestUtils.removeProperty(connectionUrl, "user");
}
if (connectionUrl.contains("password=")) {
connectionUrl = TestUtils.removeProperty(connectionUrl, "password");
}

ds.setURL(connectionUrl);
ds.setAuthentication("ActiveDirectoryMSI");
ds.setEncrypt("strict");
ds.setHostNameInCertificate("*.database.windows.net");

try (Connection con = ds.getConnection()) {
assertNotNull(con);
} catch (SQLException e) {
fail("Connection failed: " + e.getMessage());
}
}

}

0 comments on commit 89c9911

Please sign in to comment.