-
Notifications
You must be signed in to change notification settings - Fork 315
Fix SetProvider to return immediately if user-defined provider found #3620
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
Conversation
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 an issue where SetProvider
method would continue execution after finding a user-defined provider instead of returning immediately, potentially allowing the replacement of existing user-defined authentication providers.
- Replaces
break
statement withreturn false
to prevent overriding user-defined providers - Ensures proper early exit when a user-defined provider already exists for the authentication method
Should we add a test that confirms the broken behaviour when using the config-file based auth provider registration? And then see it pass with your fix. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3620 +/- ##
==========================================
+ Coverage 69.61% 77.31% +7.69%
==========================================
Files 276 273 -3
Lines 61714 46058 -15656
==========================================
- Hits 42964 35611 -7353
+ Misses 18750 10447 -8303
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Wonder if it would be possible to add a test to prevent regression? |
src/Microsoft.Data.SqlClient/tests/FunctionalTests/AADAuthenticationTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/FunctionalTests/AADAuthenticationTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlAuthenticationProviderTest.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/FunctionalTests/AADAuthenticationTests.cs
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/tests/FunctionalTests/AADAuthenticationTests.cs
Show resolved
Hide resolved
…3620) * Fix SetProvider to return immediately if user-defined provider found * Include test * Fix tests * Remove unwanted changes * Update config file name * Rename file back to app.config * Copy always * Disable tests for now. * Fix framework inclusion * Fix test failures * Touch ups * Fix test (continued)
…3620) * Fix SetProvider to return immediately if user-defined provider found * Include test * Fix tests * Remove unwanted changes * Update config file name * Rename file back to app.config * Copy always * Disable tests for now. * Fix framework inclusion * Fix test failures * Touch ups * Fix test (continued)
Fixes #3618
The issue is reproducible when config file is configured with a custom authentication provider.
Using SetProvider (as in tests) to override default providers does not reproduce issue, hence missed.
The fix will be back-ported to other affected branches (release/6.0 and 6.1).