Skip to content

Tests | Cleanup AAD Password auth from tests + code cleanup#4390

Draft
cheenamalhotra wants to merge 7 commits into
mainfrom
dev/cheena/aad-test-improvements
Draft

Tests | Cleanup AAD Password auth from tests + code cleanup#4390
cheenamalhotra wants to merge 7 commits into
mainfrom
dev/cheena/aad-test-improvements

Conversation

@cheenamalhotra

Copy link
Copy Markdown
Member

Follow up changes to test suite after #4288 where AAD Password auth was disabled from pipelines. This PR removes the AAD Password Conn String parameter completely to make it easier for AAD tests to be managed.

What Changed

Pipeline / config

  • Replace AAD_PASSWORD_CONN_STR(_eastus) with AZURE_SQL_CONN_STRING_WestUS2 / AZURE_SQL_CONN_STRING_EastUS (bare conn string, no credentials).
  • Rename config property AADPasswordConnectionStringAzureSqlConnectionString across Config.cs, config.default.jsonc, and pipeline templates (update-config-file-step.yml, ci-run-tests-job.yml, dotnet-sqlclient-ci-core.yml, test-azure-package-ci-job.yml).
  • Move AADServicePrincipalId inside the IsFork == 'False' guard (matches existing policy for AADServicePrincipalSecret).

New shared test helpers (tests/Common/)

  • CommonUtils.cs: EnsureSeparator, GenerateRandomSecureString, GenerateRandomCharacters, GenerateObjectName.
  • StringExtensions.cs: fluent Add*AuthenticationToConnString extensions (Integrated, Interactive, DeviceCodeFlow, ServicePrincipal, WorkloadIdentity, MSI, Default) plus AddUserToConnString / AddPasswordToConnString. Tests now compose auth onto AzureSqlConnectionString dynamically — required for broker-aware test legs.

Test updates

  • ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs: removed all ActiveDirectoryPassword cases; rewrote MSI / Workload Identity / Device Code / Default / token-callback tests against the new helpers; applied target-typed new(), collection expressions, using SecureString, Assert.Equal(ConnectionState.Open, …).
  • DataTestUtility.cs, AADFedAuthTokenRefreshTest, ConnectionPoolTest, and Microsoft.Data.SqlClient.Extensions/Azure/test/AADConnectionTest.cs + Config.cs updated to match.
  • TESTGUIDE.md and .github/instructions/testing.instructions.md updated.

Breaking change (CI only)

Downstream pipelines / config.user.jsonc must rename AADPasswordConnectionStringAzureSqlConnectionString and supply a bare Azure SQL connection string (no Authentication=, User ID=, Password=). The variables AAD_PASSWORD_CONN_STR / _eastus are no longer consumed and can be retired.

Validation

  • dotnet build ManualTests / net9.0 — 0 warnings, 0 errors.
  • dotnet test UnitTests / net9.0 — 792 pass; 4 failures are pre-existing macOS-env issues (Windows-only SSPI + keychain-restricted AE fixtures), not regressions.
  • Full PR pipeline (validates renamed Azure-SQL secrets).
  • Tests updated.
  • No public API changes (test-only).

Copilot AI review requested due to automatic review settings June 23, 2026 01:52
@github-project-automation github-project-automation Bot moved this to To triage in SqlClient Board Jun 23, 2026
@cheenamalhotra cheenamalhotra added the Area\Tests Issues that are targeted to tests or test projects label Jun 23, 2026
@cheenamalhotra cheenamalhotra added this to the 7.1.0-preview2 milestone Jun 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the Entra ID “password auth” connection-string configuration from the test suite (and CI templates) following the pipeline change in #4288, replacing it with a single “bare” AzureSqlConnectionString that tests extend at runtime to exercise specific authentication modes.

Changes:

  • Renamed AADPasswordConnectionStringAzureSqlConnectionString across test config (Config.cs/config.default.jsonc), docs, and Azure DevOps pipeline templates; updated pipeline variables accordingly.
  • Added shared test helpers under tests/Common/ (CommonUtils, StringExtensions) to compose auth/credential keywords onto a base connection string.
  • Updated ManualTests + Azure extensions tests to remove ActiveDirectoryPassword coverage and to use managed identity / token-based flows with the new helpers.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
TESTGUIDE.md Updates documented test config property name/meaning for AAD/Azure SQL tests.
src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj References the new shared test helper project.
src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/config.default.jsonc Renames config field and clarifies Azure SQL base conn string expectation (no creds).
src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs Renames the config field to AzureSqlConnectionString.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectivityTests/AADConnectionTest.cs Removes AAD password tests and rewrites AAD scenarios to use helpers and AzureSqlConnectionString.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionPoolTest/ConnectionPoolTest.cs Updates pooled AAD/token tests to use AzureSqlConnectionString and async token retrieval.
src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/AADFedAuthTokenRefreshTest/AADFedAuthTokenRefreshTest.cs Switches the fed-auth refresh scenario to managed identity-based auth/provider usage.
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/ManagedIdentityProvider.cs Renames the custom provider class to clarify it targets user-assigned MI.
src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs Renames config fields, adds MI-based token retrieval APIs, and removes AAD password token generation.
src/Microsoft.Data.SqlClient/tests/Common/StringExtensions.cs Adds fluent helpers for composing auth/credential keywords and for removing auth/credential keywords.
src/Microsoft.Data.SqlClient/tests/Common/CommonUtils.cs Adds shared random/name helpers used by updated tests.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/Config.cs Renames the Azure test config field read from config.jsonc.
src/Microsoft.Data.SqlClient.Extensions/Azure/test/AADConnectionTest.cs Updates Azure extension tests to build auth modes from the base Azure SQL conn string.
eng/pipelines/jobs/test-azure-package-ci-job.yml Switches pipeline config-writing to AzureSqlConnectionString and updates secret scoping.
eng/pipelines/dotnet-sqlclient-ci-core.yml Switches CI template config-writing to AzureSqlConnectionString (WestUS2/EastUS).
eng/pipelines/common/templates/steps/update-config-file-step.yml Renames template parameter and output property to AzureSqlConnectionString.
eng/pipelines/common/templates/jobs/ci-run-tests-job.yml Renames config pass-through property to AzureSqlConnectionString.
.github/instructions/testing.instructions.md Updates the test-config docs to match the renamed Azure SQL config property.

Comment thread src/Microsoft.Data.SqlClient/tests/Common/StringExtensions.cs
Comment thread src/Microsoft.Data.SqlClient/tests/Common/StringExtensions.cs
Comment thread src/Microsoft.Data.SqlClient.Extensions/Azure/test/Config.cs Outdated
Copilot AI review requested due to automatic review settings June 23, 2026 06:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 28 changed files in this pull request and generated 6 comments.

Comment thread src/Microsoft.Data.SqlClient/tests/Common/CommonUtils.cs Outdated
Comment thread src/Microsoft.Data.SqlClient/tests/Common/CommonUtils.cs
Comment thread src/Microsoft.Data.SqlClient/tests/ManualTests/DataCommon/DataTestUtility.cs Outdated
Comment thread src/Microsoft.Data.SqlClient.Extensions/Azure/test/Config.cs
Copilot AI review requested due to automatic review settings June 23, 2026 08:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 5 comments.

Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Comment thread src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs
Comment on lines +32 to +35
private static bool IsAccessTokenSetup() => DataTestUtility.IsAccessTokenAsyncSetup().GetAwaiter().GetResult();
private static bool IsAzureSqlConnStringSetup() => DataTestUtility.IsAzureConnStringSetup() && DataTestUtility.IsUserManagedIdentitySupported;
private static bool IsManagedIdentitySetup() => DataTestUtility.IsUserManagedIdentitySupported;
private static bool SupportsSystemAssignedManagedIdentity() => DataTestUtility.IsSystemManagedIdentitySupported;
Comment on lines +39 to +41
string path = Path.GetRandomFileName();
path = path.Replace(".", ""); // Remove period.
return string.Concat(prefix, path.Substring(0, length));
Comment on lines +135 to +142
foreach (var keyToRemove in keysToRemove)
{
if (key.Trim().ToLower().StartsWith(keyToRemove.Trim().ToLower(), StringComparison.Ordinal))
{
removeKey = true;
break;
}
}
Copilot AI review requested due to automatic review settings June 24, 2026 02:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Comment on lines +26 to +30
// Map random bytes into the printable ASCII range [33, 126).
for (int i = 0; i < length; i++)
{
secureString.AppendChar((char)(33 + (bytes[i] % 93)));
}
bool removeKey = false;
foreach (var keyToRemove in keysToRemove)
{
if (key.Trim().ToLower().StartsWith(keyToRemove.Trim().ToLower(), StringComparison.Ordinal))
Comment on lines 274 to 279
UserManagedIdentityClientId = c.UserManagedIdentityClientId;
PowerShellPath = c.PowerShellPath;
KerberosDomainPassword = c.KerberosDomainPassword;
KerberosDomainUser = c.KerberosDomainUser;
ManagedIdentitySupported = c.ManagedIdentitySupported;
IsUserManagedIdentitySupported = c.ManagedIdentitySupported;
IsManagedInstance = c.IsManagedInstance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area\Tests Issues that are targeted to tests or test projects

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

2 participants