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

Renamed applicationKey property in tests to applicationClientKey (to align with applicationClientID) #2399

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void testAkvName(String serverName, String url, String protocol) throws E
setAEConnectionString(serverName, url, protocol);

SQLServerColumnEncryptionAzureKeyVaultProvider akv = new SQLServerColumnEncryptionAzureKeyVaultProvider(
applicationClientID, applicationKey);
applicationClientID, applicationClientKey);
String keystoreName = "keystoreName";
akv.setName(keystoreName);
assertTrue(akv.getName().equals(keystoreName), "AKV name: " + akv.getName() + " keystoreName: " + keystoreName);
Expand Down Expand Up @@ -211,7 +211,7 @@ public void testAkvBadEncryptColumnEncryptionKey(String serverName, String url,
setAEConnectionString(serverName, url, protocol);

SQLServerColumnEncryptionAzureKeyVaultProvider akv = null;
akv = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationKey);
akv = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationClientKey);

// null encryptedColumnEncryptionKey
try {
Expand Down Expand Up @@ -290,7 +290,7 @@ public void testAkvDecryptColumnEncryptionKey(String serverName, String url, Str
setAEConnectionString(serverName, url, protocol);

SQLServerColumnEncryptionAzureKeyVaultProvider akv = null;
akv = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationKey);
akv = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationClientKey);

// null akvpath
try {
Expand Down Expand Up @@ -2291,7 +2291,7 @@ public void testAkvNameWithTokenCredential(String serverName, String url, String
setAEConnectionString(serverName, url, protocol);

ClientSecretCredential credential = new ClientSecretCredentialBuilder().tenantId(tenantID)
.clientId(applicationClientID).clientSecret(applicationKey).build();
.clientId(applicationClientID).clientSecret(applicationClientKey).build();

try {
SQLServerColumnEncryptionAzureKeyVaultProvider akv = new SQLServerColumnEncryptionAzureKeyVaultProvider(
Expand Down Expand Up @@ -2340,7 +2340,7 @@ public void testAkvBadEncryptColumnEncryptionKeyWithAuthCallback(String serverNa
@Override
public String getAccessToken(String authority, String resource, String scope) {
try {
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationKey);
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationClientKey);
ConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplication
.builder(applicationClientID, credential).authority(authority).build();
Set<String> scopes = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public void registerAKVProvider() throws Exception {
SQLServerConnection.unregisterColumnEncryptionKeyStoreProviders();

Map<String, SQLServerColumnEncryptionKeyStoreProvider> map = new HashMap<String, SQLServerColumnEncryptionKeyStoreProvider>();
if (null != applicationClientID && null != applicationKey) {
if (null != applicationClientID && null != applicationClientKey) {
File file = null;
try {
file = new File(Constants.MSSQL_JDBC_PROPERTIES);
Expand All @@ -471,7 +471,8 @@ public void registerAKVProvider() throws Exception {
props.setProperty(Constants.AKV_TRUSTED_ENDPOINTS_KEYWORD, ";vault.azure.net");
props.store(os, "");
}
akvProvider = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationKey);
akvProvider = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID,
applicationClientKey);
map.put(Constants.AZURE_KEY_VAULT_NAME, akvProvider);
} finally {
if (null != file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static void testCleanUp() throws Exception {
tempMap.put(Constants.CUSTOM_KEYSTORE_NAME, jksProvider);
}

if (null != akvProvider && null != applicationClientID && null != applicationKey) {
if (null != akvProvider && null != applicationClientID && null != applicationClientKey) {
tempMap.put(Constants.AZURE_KEY_VAULT_NAME, akvProvider);
}

Expand Down Expand Up @@ -313,7 +313,7 @@ public void testLocalCekCacheIsScopedToProvider() throws Exception {

// Register invalid key store provider on statement level. This will overwrite the previous one.
SQLServerColumnEncryptionAzureKeyVaultProvider providerWithBadCred = new SQLServerColumnEncryptionAzureKeyVaultProvider(
"badApplicationID", "badApplicationKey");
"badApplicationID", "badapplicationClientKey");
providerMap.put(Constants.AZURE_KEY_VAULT_NAME, providerWithBadCred);
pstmt.registerColumnEncryptionKeyStoreProvidersOnStatement(providerMap);

Expand Down Expand Up @@ -614,7 +614,7 @@ private SQLServerColumnEncryptionAzureKeyVaultProvider createAKVProvider() throw

SQLServerColumnEncryptionAzureKeyVaultProvider azureKeyVaultProvider = null;

if (null != applicationClientID && null != applicationKey) {
if (null != applicationClientID && null != applicationClientKey) {
File file = null;
try {
file = new File(Constants.MSSQL_JDBC_PROPERTIES);
Expand All @@ -625,7 +625,7 @@ private SQLServerColumnEncryptionAzureKeyVaultProvider createAKVProvider() throw
props.store(os, "");
}
azureKeyVaultProvider = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID,
applicationKey);
applicationClientKey);

} finally {
if (null != file) {
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/microsoft/sqlserver/jdbc/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ public final class TestUtils {

public static String ACCESS_TOKEN_CALLBACK = null;

static String applicationKey;
static String applicationClientKey;
static String applicationClientID;

static {
try (InputStream input = new FileInputStream(Constants.CONFIG_PROPERTIES_FILE)) {
Properties configProperties = new Properties();
configProperties.load(input);
applicationKey = configProperties.getProperty("applicationKey");
applicationClientKey = configProperties.getProperty("applicationClientKey");
applicationClientID = configProperties.getProperty("applicationClientID");
} catch (IOException e) {
// No config file found
Expand All @@ -123,7 +123,7 @@ public SqlAuthenticationToken getAccessToken(String spn, String stsurl) {

try {
ExecutorService executorService = Executors.newSingleThreadExecutor();
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationKey);
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationClientKey);
ConfidentialClientApplication clientApplication = ConfidentialClientApplication
.builder(applicationClientID, credential).executorService(executorService).authority(stsurl)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static void getFedauthInfo() {
Set<String> scopes = new HashSet<>();
scopes.add(spn + "/.default");
if (null == fedauthClientApp) {
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationKey);
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationClientKey);
fedauthClientApp = ConfidentialClientApplication.builder(applicationClientID, credential)
.executorService(Executors.newFixedThreadPool(1))
.setTokenCacheAccessAspect(FedauthTokenCache.getInstance()).authority(stsurl).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void testAADPasswordApplicationName() throws Exception {
public void testAADServicePrincipalAuthDeprecated() {
String url = "jdbc:sqlserver://" + azureServer + ";database=" + azureDatabase + ";authentication="
+ SqlAuthentication.ActiveDirectoryServicePrincipal + ";AADSecurePrincipalId=" + applicationClientID
+ ";AADSecurePrincipalSecret=" + applicationKey;
+ ";AADSecurePrincipalSecret=" + applicationClientKey;
String urlEncrypted = url + ";encrypt=true;trustServerCertificate=true;";
SQLServerDataSource ds = new SQLServerDataSource();
updateDataSource(url, ds);
Expand All @@ -310,7 +310,7 @@ public void testAADServicePrincipalAuthDeprecated() {
public void testAADServicePrincipalAuth() {
String url = "jdbc:sqlserver://" + azureServer + ";database=" + azureDatabase + ";authentication="
+ SqlAuthentication.ActiveDirectoryServicePrincipal + ";Username=" + applicationClientID + ";Password="
+ applicationKey;
+ applicationClientKey;
String urlEncrypted = url + ";encrypt=true;trustServerCertificate=true;";
SQLServerDataSource ds = new SQLServerDataSource();
updateDataSource(url, ds);
Expand All @@ -328,7 +328,7 @@ public void testAADServicePrincipalAuth() {
public void testAADServicePrincipalAuthFailureOnSubsequentConnectionsWithInvalidatedTokenCacheWithInvalidSecret() throws Exception {
String url = "jdbc:sqlserver://" + azureServer + ";database=" + azureDatabase + ";authentication="
+ SqlAuthentication.ActiveDirectoryServicePrincipal + ";Username=" + applicationClientID + ";Password="
+ applicationKey;
+ applicationClientKey;

String invalidSecretUrl = "jdbc:sqlserver://" + azureServer + ";database=" + azureDatabase + ";authentication="
+ SqlAuthentication.ActiveDirectoryServicePrincipal + ";Username=" + applicationClientID + ";Password="
Expand Down Expand Up @@ -396,7 +396,7 @@ public void testAADServicePrincipalAuthWrong() {
validateException(url, "R_MSALExecution");

// Wrong AADSecurePrincipalId provided.
url = baseUrl + "AADSecurePrincipalId=wrongId;AADSecurePrincipalSecret=" + applicationKey;
url = baseUrl + "AADSecurePrincipalId=wrongId;AADSecurePrincipalSecret=" + applicationClientKey;
validateException(url, "R_MSALExecution");

// AADSecurePrincipalSecret/password not provided.
Expand All @@ -406,17 +406,17 @@ public void testAADServicePrincipalAuthWrong() {
validateException(url, "R_NoUserPasswordForActiveServicePrincipal");

// AADSecurePrincipalId/username not provided.
url = baseUrl + "AADSecurePrincipalSecret=" + applicationKey;
url = baseUrl + "AADSecurePrincipalSecret=" + applicationClientKey;
validateException(url, "R_NoUserPasswordForActiveServicePrincipal");
url = baseUrl + "password=" + applicationKey;
url = baseUrl + "password=" + applicationClientKey;
validateException(url, "R_NoUserPasswordForActiveServicePrincipal");

// Both AADSecurePrincipalId/username and AADSecurePrincipalSecret/password not provided.
validateException(baseUrl, "R_NoUserPasswordForActiveServicePrincipal");

// both username/password and AADSecurePrincipalId/AADSecurePrincipalSecret provided
url = baseUrl + "Username=" + applicationClientID + ";password=" + applicationKey + ";AADSecurePrincipalId="
+ applicationClientID + ";AADSecurePrincipalSecret=" + applicationKey;
url = baseUrl + "Username=" + applicationClientID + ";password=" + applicationClientKey
+ ";AADSecurePrincipalId=" + applicationClientID + ";AADSecurePrincipalSecret=" + applicationClientKey;
validateException(url, "R_BothUserPasswordandDeprecated");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private SQLServerColumnEncryptionKeyStoreProvider setupKeyStoreProvider_JKS() th
private SQLServerColumnEncryptionKeyStoreProvider setupKeyStoreProvider_AKV() throws SQLServerException {
SQLServerConnection.unregisterColumnEncryptionKeyStoreProviders();
return registerAKVProvider(
new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationKey));
new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationClientKey));
}

private SQLServerColumnEncryptionKeyStoreProvider registerAKVProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public SqlAuthenticationToken getAccessToken(String spn, String stsurl) {

try {
ExecutorService executorService = Executors.newSingleThreadExecutor();
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationKey);
IClientCredential credential = ClientCredentialFactory.createFromSecret(applicationClientKey);
ConfidentialClientApplication clientApplication = ConfidentialClientApplication
.builder(applicationClientID, credential).executorService(executorService)
.setTokenCacheAccessAspect(FedauthTokenCache.getInstance()).authority(stsurl).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
public abstract class AbstractTest {

protected static String applicationClientID = null;
protected static String applicationKey = null;
protected static String applicationClientKey = null;
protected static String tenantID;
protected static String[] keyIDs = null;

Expand Down Expand Up @@ -158,7 +158,7 @@ public static void setup() throws Exception {
connectionString = getConfiguredPropertyOrEnv(Constants.MSSQL_JDBC_TEST_CONNECTION_PROPERTIES);

applicationClientID = getConfiguredProperty("applicationClientID");
applicationKey = getConfiguredProperty("applicationKey");
applicationClientKey = getConfiguredProperty("applicationClientKey");
tenantID = getConfiguredProperty("tenantID");

accessTokenClientId = getConfiguredProperty("accessTokenClientId");
Expand Down Expand Up @@ -231,7 +231,7 @@ public static void setup() throws Exception {
map.put(Constants.CUSTOM_KEYSTORE_NAME, jksProvider);
}

if (null == akvProvider && null != applicationClientID && null != applicationKey) {
if (null == akvProvider && null != applicationClientID && null != applicationClientKey) {
File file = null;
try {
file = new File(Constants.MSSQL_JDBC_PROPERTIES);
Expand All @@ -241,7 +241,8 @@ public static void setup() throws Exception {
props.setProperty(Constants.AKV_TRUSTED_ENDPOINTS_KEYWORD, ";vault.azure.net");
props.store(os, "");
}
akvProvider = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID, applicationKey);
akvProvider = new SQLServerColumnEncryptionAzureKeyVaultProvider(applicationClientID,
applicationClientKey);
map.put(Constants.AZURE_KEY_VAULT_NAME, akvProvider);
} finally {
if (null != file) {
Expand Down