Skip to content

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

Merged
mdaigle merged 26 commits into
mainfrom
dev/cheena/aad-test-improvements
Oct 7, 2026
Merged

mdaigle merged 26 commits into
mainfrom
dev/cheena/aad-test-improvements

Conversation

@cheenamalhotra

@cheenamalhotra cheenamalhotra commented Jun 23, 2026 •

Copy link
Copy Markdown
Member

Removes live AAD Password authentication from test pipelines and uses managed-identity access tokens for Azure SQL tests.

Changes

  • Azure test legs consume bare connection strings from AZURE_SQL_CONN_STRING_WestUS2 and AZURE_SQL_CONN_STRING_EastUS.
  • Removed AAD Password connection-string config and live AAD Password tests.
  • Azure manual-test connections use tokens from DataTestUtility; connection-string-only paths use a test Managed Identity provider backed by the same API.
  • Explicit AccessToken and callback tests remove inherited authentication first.
  • Access tokens are cached until near expiry and pool tests reuse the same token.
  • Updated Azure extension tests and shared connection-string helpers.

CI migration

Supply bare Azure SQL connection strings through AZURE_SQL_CONN_STRING_WestUS2 and AZURE_SQL_CONN_STRING_EastUS, without authentication, user, or password fields. Legacy AAD_PASSWORD_CONN_STR* and AZURE_DB_*_CONN_STRING* variables are no longer consumed by these test legs.

Validation

  • ManualTests build: net8.0 and net9.0
  • Azure extension tests build: net8.0 and net9.0
  • Tests added or updated
  • No public API changes
  • No breaking product changes

Copilot AI balanced 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 AADPasswordConnectionString → AzureSqlConnectionString 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.

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.

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

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

Copilot AI review requested due to automatic review settings June 24, 2026 20:22

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

@cheenamalhotra
cheenamalhotra marked this pull request as ready for review June 25, 2026 00:50
@cheenamalhotra
cheenamalhotra requested review from a team and Copilot June 25, 2026 00:50
@cheenamalhotra cheenamalhotra moved this from To triage to In review in SqlClient Board Jun 25, 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

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 thread TESTGUIDE.md Resolved
@codecov

codecov Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.33%. Comparing base (6f6a0d2) to head (a22fb77).

❗ There is a different number of reports uploaded between BASE (6f6a0d2) and HEAD (a22fb77). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (6f6a0d2) HEAD (a22fb77)
CI-SqlClient 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4390      +/-   ##
==========================================
- Coverage   72.18%   65.33%   -6.85%     
==========================================
  Files         292      286       -6     
  Lines       45341    68413   +23072     
==========================================
+ Hits        32728    44697   +11969     
- Misses      12613    23716   +11103     
Flag Coverage Δ
CI-SqlClient ?
PR-SqlClient-Project 65.33% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@benrr101 benrr101 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.

I think the scope of these changes are a bit too broad. Don't mind cleanup where sensible, but I'm concerned about the intentions behind the connection string changes being more sweeping than we really want right now.

cheenamalhotra and others added 7 commits October 5, 2026 21:00
- Add IsUserManagedIdentitySupported condition to TestCustomProviderAuthentication and FedAuthTokenRefreshTest
- Update RemoveAuthAndCredsProperties doc to list all 7 removed keys
- Remove orphaned TcpConnectionString property from Azure.Test Config.cs
- Update Azure.Test AADConnectionTest.cs to use Config.TCPConnectionString

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99
Route Azure SQL manual-test connections through DataTestUtility so managed identity access tokens are applied without AAD Password authentication. Remove the unused username/password provider.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99
Copilot AI balanced review requested due to automatic review settings October 6, 2026 04:24
@cheenamalhotra
cheenamalhotra force-pushed the dev/cheena/aad-test-improvements branch from 3a160c9 to d2af3fa Compare October 6, 2026 04:24

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.

Copilot review overview

🟡 Changes recommended

The Windows 11 Azure test leg still references retired connection-string variables, potentially skipping its Azure coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
Resolved since last review (1)
Files not reviewed (1)
  • src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs: Generated file

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99
Copilot AI balanced review requested due to automatic review settings October 6, 2026 04:53

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.

Copilot review overview

🔵 Needs a closer look

One Azure test leg still depends on retired connection-string variables, and new helper documentation is incomplete.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

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

- Use AZURE_SQL_CONN_STRING_WestUS2 in Win11 Azure leg
- Add XML docs to TestRandomUtilities
- Fix MI invalid user id assertion
- Gate system-assigned MI tests behind SupportsSystemAssignedManagedIdentity
- Remove unused code and unrelated Strings.Designer.cs change

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99
Copilot AI balanced review requested due to automatic review settings October 6, 2026 05:06

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.

Copilot review overview

🟡 Changes recommended

The Azure SQL setup documentation omits the required managed-identity configuration, causing the documented default setup to fail token acquisition.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (2)

Comment thread TESTGUIDE.md Resolved
Updated the description for the TCPConnectionString to include additional configuration details for Azure SQL authentication tests.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 05:49
@cheenamalhotra
cheenamalhotra dismissed mdaigle’s stale review October 6, 2026 05:50

Removing stale reviews

@cheenamalhotra
cheenamalhotra dismissed benrr101’s stale review October 6, 2026 05:50

Removing stale reviews

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.

Copilot review overview

🔵 Needs a closer look

Managed-identity token acquisition drops callback cancellation, allowing IMDS requests to overrun the configured connection timeout.

Review effort: Balanced
Findings: None

Resolved since last review (1)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Managed identity token acquisition ignores cancellation

src/​Microsoft.Data.SqlClient/​tests/​ManualTests/​SQL/​AADFedAuthTokenRefreshTest/​AADFedAuthTokenRefreshTest.cs:123

Forward the callback's cancellation token into the managed-identity token acquisition path. The previous TokenCredential.GetTokenAsync(..., cancellationToken) call was cancellable, but GetSqlAuthenticationTokenAsync() eventually calls AADUtility.SendAsyncWithRetry(..., default) (DataCommon/AADUtility.cs:67), so cancellation or the 30-second connect timeout is only observed after the IMDS request finishes (the shared HttpClient can wait longer). The checks before and after the await do not cancel the in-flight request, which can make these pool tests substantially overrun their login budget during an identity-service stall.

RemoveKeysInConnStr no longer leaves a trailing ';', so build the
Integrated Security string with SqlConnectionStringBuilder. Skip
TestInitialCatalogStandardValues when the conn string has no User ID or
Integrated Security (MI token auth), since the converter requires them.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: 556e4cc8-f9fd-46f1-aafa-1459e8659f99

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.

Copilot review overview

🔵 Needs a closer look

The broad live-authentication and CI matrix migration requires human verification across managed identities, operating systems, frameworks, and pool implementations.

Review effort: Balanced
Findings: None

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: Done

Development

Successfully merging this pull request may close these issues.

5 participants