Skip to content
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

Add | Adding Net6 support and dropping netcoreapp3.1 #1704

Merged
merged 4 commits into from
Oct 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removing Secure password which is obsolete and addressing some test i…
…mprovments.
  • Loading branch information
JRahnama committed Oct 20, 2022
commit 49a00429c923149a624e678d35c15b7025d11609
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,11 @@ public override async Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenti
}
else if (parameters.AuthenticationMethod == SqlAuthenticationMethod.ActiveDirectoryPassword)
{
#if NETFRAMEWORK
SecureString password = new SecureString();
foreach (char c in parameters.Password)
password.AppendChar(c);
password.MakeReadOnly();

result = await app.AcquireTokenByUsernamePassword(scopes, parameters.UserId, password)
.WithCorrelationId(parameters.ConnectionId)
.ExecuteAsync(cancellationToken: cts.Token)
.ConfigureAwait(false);
#else
result = await app.AcquireTokenByUsernamePassword(scopes, parameters.UserId, parameters.Password)
.WithCorrelationId(parameters.ConnectionId)
.ExecuteAsync(cancellationToken: cts.Token)
.ConfigureAwait(false);
#endif

SqlClientEventSource.Log.TryTraceEvent("AcquireTokenAsync | Acquired access token for Active Directory Password auth mode. Expiry Time: {0}", result?.ExpiresOn);
}
else if (parameters.AuthenticationMethod == SqlAuthenticationMethod.ActiveDirectoryInteractive ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,8 @@ private static Task<string> AcquireTokenAsync(string authorityURL, string userID

SecureString securePassword = new SecureString();

foreach (char c in password)
securePassword.AppendChar(c);
securePassword.MakeReadOnly();
result = app.AcquireTokenByUsernamePassword(scopes, userID, securePassword).ExecuteAsync().Result;
result = app.AcquireTokenByUsernamePassword(scopes, userID, password).ExecuteAsync().Result;

return result.AccessToken;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,10 @@ public override async Task<SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenti

string[] scopes = new string[] { scope };
SecureString password = new SecureString();
foreach (char c in parameters.Password)
password.AppendChar(c);
password.MakeReadOnly();

AuthenticationResult result = await PublicClientApplicationBuilder.Create(_appClientId)
.WithAuthority(parameters.Authority)
.Build().AcquireTokenByUsernamePassword(scopes, parameters.UserId, password)
.Build().AcquireTokenByUsernamePassword(scopes, parameters.UserId, parameters.Password)
.WithCorrelationId(parameters.ConnectionId)
.ExecuteAsync(cancellationToken: cts.Token);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public static void Test_WithDecimalValue_ShouldReturnDecimal()
var cmd = new SqlCommand("select @foo", conn);
cmd.Parameters.AddWithValue("@foo", new SqlDecimal(0.5));
var result = (decimal)cmd.ExecuteScalar();
Assert.Equal(result, (decimal)0.5);
Assert.Equal((decimal)0.5, result);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

upgrading xunit to 2.4.2 discovered these mistakes. expected values needs to be the first and actual value has to come second.

}

// Synapse: Unsupported parameter type found while parsing RPC request. The request has been terminated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ private static void TestReaderNonMarsCase(string caseName, string connectionStri
{
rdr.Read();
Assert.Equal(1, rdr.FieldCount);
Assert.Equal(rdr.GetName(0), COLUMN_NAME_2);
Assert.Equal(COLUMN_NAME_2, rdr.GetName(0));
}
break;

case ReaderVerificationType.ChangeDatabase:
con.ChangeDatabase(CHANGE_DATABASE_NAME);
Assert.Equal(con.Database, CHANGE_DATABASE_NAME);
Assert.Equal(CHANGE_DATABASE_NAME, con.Database);
break;

case ReaderVerificationType.BeginTransaction:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="$(SystemRuntimeInteropServicesRuntimeInformationVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(xunitrunnervisualstudioVersion)" />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

xunit.runner.visualstudio now has a different version than xunit itself.

<PackageReference Include="xunit.runner.console" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.utility" Version="$(XunitVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
Expand Down