From f8abb46a5af4acd3b42ca82feb6b5b69a0b13b34 Mon Sep 17 00:00:00 2001 From: Cheena Malhotra Date: Thu, 25 Mar 2021 13:27:28 -0700 Subject: [PATCH] Update tests --- .../SqlAuthenticationMethod.xml | 4 ++-- .../tests/ManualTests/DataCommon/AADUtility.cs | 14 +++++++------- .../ManualTests/DataCommon/DataTestUtility.cs | 8 ++++---- .../SQL/ConnectivityTests/AADConnectionTest.cs | 4 ++-- .../Config.cs | 2 +- .../config.default.json | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/doc/snippets/Microsoft.Data.SqlClient/SqlAuthenticationMethod.xml b/doc/snippets/Microsoft.Data.SqlClient/SqlAuthenticationMethod.xml index 19927484fd..54b8f3d0a7 100644 --- a/doc/snippets/Microsoft.Data.SqlClient/SqlAuthenticationMethod.xml +++ b/doc/snippets/Microsoft.Data.SqlClient/SqlAuthenticationMethod.xml @@ -34,11 +34,11 @@ 6 - The authentication method uses Active Directory Managed Identity. Use System Assigned or User Assigned Managed Identity to connect to SQL Database from Azure client environments that have enabled support for Managed Identity. For User Assigned Managed Identity, 'User Id' or 'UID' is required to be set to the object ID of the user identity. + The authentication method uses Active Directory Managed Identity. Use System Assigned or User Assigned Managed Identity to connect to SQL Database from Azure client environments that have enabled support for Managed Identity. For User Assigned Managed Identity, 'User Id' or 'UID' is required to be set to the "client ID" of the user identity. 7 - Alias for "Active Directory Managed Identity" authentication method. Use System Assigned or User Assigned Managed Identity to connect to SQL Database from Azure client environments that have enabled support for Managed Identity. For User Assigned Managed Identity, 'User Id' or 'UID' is required to be set to the object ID of the user identity. + Alias for "Active Directory Managed Identity" authentication method. Use System Assigned or User Assigned Managed Identity to connect to SQL Database from Azure client environments that have enabled support for Managed Identity. For User Assigned Managed Identity, 'User Id' or 'UID' is required to be set to the "client ID" of the user identity. 8 diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs index 228217c039..16cbabf24c 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/AADUtility.cs @@ -26,8 +26,8 @@ public static async Task AzureActiveDirectoryAuthenticationCallback(stri return result.AccessToken; } - public static async Task GetManagedIdentityToken(string objectId = null) => - await new MockManagedIdentityTokenProvider().AcquireTokenAsync(objectId).ConfigureAwait(false); + public static async Task GetManagedIdentityToken(string clientId = null) => + await new MockManagedIdentityTokenProvider().AcquireTokenAsync(clientId).ConfigureAwait(false); } @@ -59,20 +59,20 @@ internal class MockManagedIdentityTokenProvider internal readonly int _retryTimeoutInSeconds = DefaultRetryTimeout; internal readonly int _maxRetryCount = DefaultMaxRetryCount; - public async Task AcquireTokenAsync(string objectId = null) + public async Task AcquireTokenAsync(string clientId = null) { // Use the httpClient specified in the constructor. If it was not specified in the constructor, use the default httpClient. HttpClient httpClient = s_defaultHttpClient; try { - // If user assigned managed identity is specified, include object ID parameter in request - string objectIdParameter = objectId != null - ? $"&object_id={objectId}" + // If user assigned managed identity is specified, include client Id parameter in request + string clientId = clientId != null + ? $"&client_id={clientId}" : string.Empty; // Craft request as per the MSI protocol - var requestUrl = $"{AzureVmImdsEndpoint}?resource={Resource}{objectIdParameter}{AzureVmImdsApiVersion}"; + var requestUrl = $"{AzureVmImdsEndpoint}?resource={Resource}{clientIdParameter}{AzureVmImdsApiVersion}"; HttpResponseMessage response = null; diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs index 80701905f3..58dd79df04 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs @@ -53,7 +53,7 @@ public static class DataTestUtility public static readonly string DNSCachingServerTR = null; // this is for the tenant ring public static readonly bool IsDNSCachingSupportedCR = false; // this is for the control ring public static readonly bool IsDNSCachingSupportedTR = false; // this is for the tenant ring - public static readonly string UserManagedIdentityObjectId = null; + public static readonly string UserManagedIdentityClientId = null; public static readonly string EnclaveAzureDatabaseConnString = null; public static bool ManagedIdentitySupported = true; @@ -93,7 +93,7 @@ static DataTestUtility() IsDNSCachingSupportedCR = c.IsDNSCachingSupportedCR; IsDNSCachingSupportedTR = c.IsDNSCachingSupportedTR; EnclaveAzureDatabaseConnString = c.EnclaveAzureDatabaseConnString; - UserManagedIdentityObjectId = c.UserManagedIdentityObjectId; + UserManagedIdentityClientId = c.UserManagedIdentityClientId; System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12; @@ -459,8 +459,8 @@ public static string GetUserIdentityAccessToken() { if (true == ManagedIdentitySupported && null == AADUserIdentityAccessToken && IsAADPasswordConnStrSetup()) { - // Pass User Assigned Managed Identity Object Id here. - AADUserIdentityAccessToken = AADUtility.GetManagedIdentityToken(UserManagedIdentityObjectId).GetAwaiter().GetResult(); + // Pass User Assigned Managed Identity Client Id here. + AADUserIdentityAccessToken = AADUtility.GetManagedIdentityToken(UserManagedIdentityClientId).GetAwaiter().GetResult(); if (AADUserIdentityAccessToken == null) { ManagedIdentitySupported = false; diff --git a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs index 8036f5aaf6..4d53f5d494 100644 --- a/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs +++ b/src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs @@ -491,7 +491,7 @@ public static void UserAssigned_ManagedIdentityTest() { string[] removeKeys = { "Authentication", "User ID", "Password", "UID", "PWD" }; string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, removeKeys) + - $"Authentication=Active Directory Managed Identity; User Id={DataTestUtility.UserManagedIdentityObjectId};"; + $"Authentication=Active Directory Managed Identity; User Id={DataTestUtility.UserManagedIdentityClientId};"; ConnectAndDisconnect(connStr); } @@ -543,7 +543,7 @@ public static void Azure_UserManagedIdentityTest() { string[] removeKeys = { "Authentication", "User ID", "Password", "UID", "PWD", "Trusted_Connection", "Integrated Security" }; string connectionString = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.TCPConnectionString, removeKeys) - + $"Authentication=Active Directory Managed Identity; User Id={DataTestUtility.UserManagedIdentityObjectId}"; + + $"Authentication=Active Directory Managed Identity; User Id={DataTestUtility.UserManagedIdentityClientId}"; using (SqlConnection conn = new SqlConnection(connectionString)) { diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs index de6fffd6ae..8379b81baa 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs @@ -36,7 +36,7 @@ public class Config public bool IsDNSCachingSupportedCR = false; // this is for the control ring public bool IsDNSCachingSupportedTR = false; // this is for the tenant ring public string EnclaveAzureDatabaseConnString = null; - public string UserManagedIdentityObjectId = null; + public string UserManagedIdentityClientId = null; public static Config Load(string configPath = @"config.json") { diff --git a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json index 11ee9f25e5..4c725d8555 100644 --- a/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json +++ b/src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.json @@ -20,5 +20,5 @@ "UseManagedSNIOnWindows": false, "IsAzureSynapse": false, "EnclaveAzureDatabaseConnString": "", - "UserManagedIdentityObjectId": "" + "UserManagedIdentityClientId": "" }