Skip to content

Commit 4d70468

Browse files
Ignore casing in functions host config options keys (#9122)
1 parent 71c449f commit 4d70468

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/WebJobs.Script/Config/FunctionsHostingConfigOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

4+
using System;
45
using System.Collections.Generic;
56
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
67

@@ -12,7 +13,7 @@ public class FunctionsHostingConfigOptions
1213

1314
public FunctionsHostingConfigOptions()
1415
{
15-
_features = new Dictionary<string, string>();
16+
_features = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
1617
}
1718

1819
/// <summary>

test/WebJobs.Script.Tests/Configuration/FunctionsHostingConfigOptionsTest.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@ namespace Microsoft.Azure.WebJobs.Script.Tests.Configuration
1616
{
1717
public class FunctionsHostingConfigOptionsTest
1818
{
19+
[Theory]
20+
[InlineData("FEATURE1", "value1")]
21+
[InlineData("FeAtUrE1", "value1")]
22+
[InlineData("feature1", "value1")]
23+
[InlineData("featuree1", null)]
24+
public async Task Case_Insensitive(string key, string expectedValue)
25+
{
26+
using (TempDirectory tempDir = new TempDirectory())
27+
{
28+
IHost host = GetScriptHostBuilder(Path.Combine(tempDir.Path, "settings.txt"), $"feature1=value1,feature2=value2").Build();
29+
var testService = host.Services.GetService<TestService>();
30+
31+
_ = Task.Run(async () =>
32+
{
33+
await TestHelpers.Await(() =>
34+
{
35+
return testService.Options.Value.GetFeature(key) == expectedValue;
36+
});
37+
await host.StopAsync();
38+
});
39+
40+
await host.RunAsync();
41+
Assert.Equal(testService.Options.Value.GetFeature(key), expectedValue);
42+
}
43+
}
44+
1945
[Fact]
2046
public async Task Inject_Succeded()
2147
{

0 commit comments

Comments
 (0)