Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for ManagedIdentityWithEncryptStrict #2599

Closed
wants to merge 10 commits into from
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 @@ -1369,5 +1370,35 @@ public void testGetSqlFedAuthTokenFailureNagativeWaiting() throws SQLException {
assertTrue(e.getMessage().contains(SQLServerException.getErrString("R_connectionTimedOut")), "Expected Timeout Exception was not thrown");
}
}

@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());
}
}
}
Loading