-
Notifications
You must be signed in to change notification settings - Fork 317
Fix Async thread blocking on SqlConnection open for AAD modes #1213
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
48daafe
Fix Async thread blocking on SqlConnection open for AAD modes
cheenamalhotra 9adeb8c
back to result
cheenamalhotra cf15d35
Fix AAD Tests
cheenamalhotra 4d69e29
More changes
cheenamalhotra de5c963
Fix for Unix
cheenamalhotra 75471d4
Wrap internal exceptions into SqlException
cheenamalhotra f25e4f7
Add comments
cheenamalhotra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Microsoft.Data.SqlClient/netcore/src/Resources/Strings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Microsoft.Data.SqlClient/netfx/src/Resources/Strings.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,10 +161,10 @@ public static void AADPasswordWithWrongPassword() | |
string[] credKeys = { "Password", "PWD" }; | ||
string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, credKeys) + "Password=TestPassword;"; | ||
|
||
AggregateException e = Assert.Throws<AggregateException>(() => ConnectAndDisconnect(connStr)); | ||
SqlException e = Assert.Throws<SqlException>(() => ConnectAndDisconnect(connStr)); | ||
cheenamalhotra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
string expectedMessage = "ID3242: The security token could not be authenticated or authorized."; | ||
Assert.Contains(expectedMessage, e.InnerException.InnerException.Message); | ||
Assert.Contains(expectedMessage, e.Message); | ||
} | ||
|
||
|
||
|
@@ -241,7 +241,11 @@ public static void EmptyPasswordInConnStrAADPassword() | |
// connection fails with expected error message. | ||
string[] pwdKey = { "Password", "PWD" }; | ||
string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, pwdKey) + "Password=;"; | ||
Assert.Throws<AggregateException>(() => ConnectAndDisconnect(connStr)); | ||
SqlException e = Assert.Throws<SqlException>(() => ConnectAndDisconnect(connStr)); | ||
|
||
string user = DataTestUtility.FetchKeyInConnStr(DataTestUtility.AADPasswordConnectionString, new string[] { "User Id", "UID" }); | ||
string expectedMessage = string.Format("Failed to authenticate the user {0} in Active Directory (Authentication=ActiveDirectoryPassword).", user); | ||
Assert.Contains(expectedMessage, e.Message); | ||
} | ||
|
||
[PlatformSpecific(TestPlatforms.Windows)] | ||
|
@@ -251,7 +255,10 @@ public static void EmptyCredInConnStrAADPassword() | |
// connection fails with expected error message. | ||
string[] removeKeys = { "User ID", "Password", "UID", "PWD" }; | ||
string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, removeKeys) + "User ID=; Password=;"; | ||
Assert.Throws<AggregateException>(() => ConnectAndDisconnect(connStr)); | ||
SqlException e = Assert.Throws<SqlException>(() => ConnectAndDisconnect(connStr)); | ||
|
||
string expectedMessage = "Failed to authenticate the user in Active Directory (Authentication=ActiveDirectoryPassword)."; | ||
Assert.Contains(expectedMessage, e.Message); | ||
} | ||
|
||
[PlatformSpecific(TestPlatforms.AnyUnix)] | ||
|
@@ -261,16 +268,23 @@ public static void EmptyCredInConnStrAADPasswordAnyUnix() | |
// connection fails with expected error message. | ||
string[] removeKeys = { "User ID", "Password", "UID", "PWD" }; | ||
string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, removeKeys) + "User ID=; Password=;"; | ||
Assert.Throws<AggregateException>(() => ConnectAndDisconnect(connStr)); | ||
SqlException e = Assert.Throws<SqlException>(() => ConnectAndDisconnect(connStr)); | ||
|
||
string expectedMessage = "MSAL cannot determine the username (UPN) of the currently logged in user.For Integrated Windows Authentication and Username/Password flows, please use .WithUsername() before calling ExecuteAsync()."; | ||
Assert.Contains(expectedMessage, e.Message); | ||
} | ||
|
||
[ConditionalFact(nameof(IsAADConnStringsSetup))] | ||
public static void AADPasswordWithInvalidUser() | ||
{ | ||
// connection fails with expected error message. | ||
string[] removeKeys = { "User ID", "UID" }; | ||
string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, removeKeys) + "User [email protected]"; | ||
Assert.Throws<AggregateException>(() => ConnectAndDisconnect(connStr)); | ||
string user = "[email protected]"; | ||
string connStr = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, removeKeys) + $"User ID={user}"; | ||
SqlException e = Assert.Throws<SqlException>(() => ConnectAndDisconnect(connStr)); | ||
|
||
string expectedMessage = string.Format("Failed to authenticate the user {0} in Active Directory (Authentication=ActiveDirectoryPassword).", user); | ||
Assert.Contains(expectedMessage, e.Message); | ||
} | ||
|
||
[ConditionalFact(nameof(IsAADConnStringsSetup))] | ||
|
@@ -386,7 +400,7 @@ public static void ActiveDirectoryManagedIdentityWithInvalidUserIdMustFail(strin | |
string connStrWithNoCred = DataTestUtility.RemoveKeysInConnStr(DataTestUtility.AADPasswordConnectionString, credKeys) + | ||
$"Authentication=Active Directory Managed Identity; User Id={userId}"; | ||
|
||
AggregateException e = Assert.Throws<AggregateException>(() => ConnectAndDisconnect(connStrWithNoCred)); | ||
SqlException e = Assert.Throws<SqlException>(() => ConnectAndDisconnect(connStrWithNoCred)); | ||
|
||
string expectedMessage = "ManagedIdentityCredential authentication unavailable"; | ||
Assert.Contains(expectedMessage, e.GetBaseException().Message); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.