Visitar URL original
Fix SetProvider to return immediately if user-defined provider found by cheenamalhotra · Pull Request #3620 · dotnet/SqlClient · GitHub
Skip to content
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
Fix tests
  • Loading branch information
cheenamalhotra committed Sep 23, 2025
commit 08265d24bab33cb06ae6d5f89d0038f38b5528a4
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,18 @@ public bool SetProvider(SqlAuthenticationMethod authenticationMethod, SqlAuthent
return true;
}

/// <summary>
/// Fetches provided configuration section from app.config file.
/// Does not support reading from appsettings.json yet.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="name"></param>
/// <returns></returns>
private static T FetchConfigurationSection<T>(string name)
{
Type t = typeof(T);

// TODO: Support reading configuration from appsettings.json for .NET runtime applications.
object section = ConfigurationManager.GetSection(name);
if (section != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ private void InvalidCombinationCheck(SqlCredential credential)
}
}

[Fact]
/// <summary>
/// Tests whether SQL Auth provider is overridden using app.config file.
/// This use case is only supported for .NET Framework applications, as driver doesn't support reading configuration from appsettings.json file.
/// In future if need be, appsettings.json support can be added.
/// </summary>
/// <returns></returns>
[ConditionalFact(typeof(TestUtility), nameof(TestUtility.IsFullFramework))]
public async Task IsDummySqlAuthenticationProviderSetByDefault()
Comment thread
cheenamalhotra marked this conversation as resolved.
Resolved
{
var provider = SqlAuthenticationProvider.GetProvider(SqlAuthenticationMethod.ActiveDirectoryInteractive);
Comment thread
cheenamalhotra marked this conversation as resolved.
Resolved
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.Data.SqlClient/tests/FunctionalTests/App.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Application configuration file is loaded by the compiler first before loading managed types. -->
<configuration>
<configSections>
<section name="SqlClientAuthenticationProviders" type="Microsoft.Data.SqlClient.SqlClientAuthenticationProviderConfigurationSection,Microsoft.Data.SqlClient" />
</configSections>
<!-- Custom authentication providers from app.config are loaded by the SqlAuthenticationProviderManager before registering default authentication provider. -->
<SqlClientAuthenticationProviders>
<providers>
<add name="active directory interactive" type="Microsoft.Data.SqlClient.FunctionalTests.DataCommon.DummySqlAuthenticationProvider, FunctionalTests" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<Compile Include="..\..\src\Microsoft\Data\SqlClient\TdsParserStateObject.Multiplexer.cs" />
<Compile Include="..\..\src\Microsoft\Data\SqlClient\Packet.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netfx'">
<None Update="App.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- XUnit and XUnit extensions -->
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
Expand All @@ -92,6 +97,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.SqlServer.Types" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Security.Cryptography.Pkcs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetGroup)' == 'netcoreapp'">
Expand Down Expand Up @@ -138,10 +144,14 @@
<TargetPath>%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>xunit.runner.json</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="appconfig" /></VisualStudio></ProjectExtensions>
</Project>