-
Notifications
You must be signed in to change notification settings - Fork 81
feat: support Azure AD auth in e2e tests #659
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
feat: support Azure AD auth in e2e tests #659
Conversation
The Azure DevOps pipeline runs tests twice: 1. SQL2022: Uses SQL auth (sa user) - tests will run 2. SQLDB: Uses Azure AD auth (service principal) - tests should skip The live connection e2e tests require SQL auth credentials (SQLCMDUSER/SQLCMDPASSWORD) which aren't available in the Azure AD auth scenario. Added skipIfNoSQLAuth() to properly skip these tests instead of failing with 'Login failed for user ''.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes pipeline failures from PR #642 by adding proper test skipping logic for end-to-end tests that require SQL authentication credentials. The SQLDB pipeline test runs use Azure AD authentication without SQLCMDUSER/SQLCMDPASSWORD environment variables, causing these tests to fail inappropriately.
Changes:
- Added
hasSQLAuthCredentials()helper function to check for SQL authentication credentials (SQLCMDUSER and SQLCMDPASSWORD) - Added
skipIfNoSQLAuth()helper function that skips tests when SQL authentication is not available - Updated three live connection tests to use the new skip function instead of just checking for SQLCMDSERVER
There was a problem hiding this comment.
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 1 out of 1 changed files in this pull request and generated no new comments.
There was a problem hiding this comment.
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 1 out of 1 changed files in this pull request and generated no new comments.
|
why can't these tests look for the same auth settings as the other tests? |
Instead of skipping tests when SQL auth credentials are unavailable, detect Azure AD authentication and use appropriate --authentication-method flag, matching the approach used in pkg/sqlcmd/sqlcmd_test.go. Tests now run on both SQL2022 (SQL auth) and SQLDB (Azure AD) pipelines.
There was a problem hiding this comment.
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 1 out of 1 changed files in this pull request and generated no new comments.
It turns out there's no good reason. Fixed. |
shueybubbles
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
Problem
PR #642 added e2e tests that originally only worked with SQL authentication credentials (SQLCMDUSER/SQLCMDPASSWORD). The ADO pipeline runs tests twice with different authentication methods:
Solution
Updated the e2e tests to detect and use Azure AD authentication when appropriate, matching the approach used in
pkg/sqlcmd/sqlcmd_test.go:canTestAzureAuth()- detects Azure SQL endpoint + no SQL credentialsgetAuthArgs()- returns appropriate--authentication-methodflag:ActiveDirectoryAzurePipelineswhen running in Azure PipelinesActiveDirectoryDefaultotherwiseResult
Tests now execute on both pipeline runs with the appropriate authentication method.
Files Changed
cmd/modern/e2e_test.go: Added Azure AD auth detection and--authentication-methodflag support