Skip to content

Commit

Permalink
Added Azure Active Directory tests for Azure Data Explorer using user…
Browse files Browse the repository at this point in the history
…/password/applicationName AND removed deprecated tags to fix build warnings (#1755)

* Added AAD test for ADX connection using user/pass/applicationName

* Fixed formatting in FedauthTest.java

* Removed @deprecated warnings on AAD_SECURE_PRINCIPAL, and AAD_SECURE_SECRET, to remove build warnings.
  • Loading branch information
Jeffery-Wasty committed Feb 22, 2022
1 parent f0d6259 commit f9caf73
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,9 @@ public class SQLServerConnection implements ISQLServerConnection, java.io.Serial
private String clientKeyPassword = "";

/** AAD principal id */
@Deprecated
private String aadPrincipalID = "";

/** AAD principal secret */
@Deprecated
private String aadPrincipalSecret = "";

/** sendTemporalDataTypesAsStringForBulkCopy flag */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,7 @@ enum SQLServerDriverStringProperty {
CLIENT_CERTIFICATE("clientCertificate", ""),
CLIENT_KEY("clientKey", ""),
CLIENT_KEY_PASSWORD("clientKeyPassword", ""),
@Deprecated
AAD_SECURE_PRINCIPAL_ID("AADSecurePrincipalId", ""),
@Deprecated
AAD_SECURE_PRINCIPAL_SECRET("AADSecurePrincipalSecret", ""),
MAX_RESULT_BUFFER("maxResultBuffer", "-1");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public class FedauthCommon extends AbstractTest {

static boolean enableADIntegrated = false;

static String hostNameInCertificate = null;
static String applicationName = null;
static String kustoServer = null;
static String spn = null;
static String stsurl = null;
static String fedauthClientId = null;
Expand Down Expand Up @@ -140,6 +143,9 @@ public static void getConfigs() throws Exception {
fedauthJksPaths = getConfiguredProperty("fedauthJksPaths", "").split(Constants.SEMI_COLON);
fedauthJavaKeyAliases = getConfiguredProperty("fedauthJavaKeyAliases", "").split(Constants.SEMI_COLON);

hostNameInCertificate = getConfiguredProperty("hostNameInCertificate");
applicationName = getConfiguredProperty("applicationName");
kustoServer = getConfiguredProperty("kustoServer");
spn = getConfiguredProperty("spn");
stsurl = getConfiguredProperty("stsurl");
fedauthClientId = getConfiguredProperty("fedauthClientId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,29 @@ public void testCorrectAccessTokenDS() throws SQLException {
}
}

/**
* Test AAD Password Authentication using username/password in connection string, data source and SSL
* encryption, in addition to application name in order to use different authorities.
*
* @throws Exception
* if an exception occurs
*/
@Test
public void testAADPasswordApplicationName() throws Exception {
String url = "jdbc:sqlserver://" + kustoServer + ";database=" + azureDatabase + ";user=" + azureUserName
+ ";password=" + azurePassword + ";Authentication="
+ SqlAuthentication.ActiveDirectoryPassword.toString() + ";hostNameInCertificate="
+ hostNameInCertificate + ";applicationName=" + applicationName
+ ";encrypt=true;trustServerCertificate=true;";
SQLServerDataSource ds = new SQLServerDataSource();
ds.setURL(url);

try (Connection con = ds.getConnection()) {
} catch (Exception e) {
fail(e.getMessage());
}
}

/**
* Test AAD Service Principal Authentication using AADSecurePrincipalId/AADSecurePrincipalSecret in connection
* string, data source and SSL encryption.
Expand Down

0 comments on commit f9caf73

Please sign in to comment.