Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ In addition to the [feature documentation](https://steeltoe.io/api), we have bui
| Steeltoe Version | .NET Version |
| --- | --- |
| 4.x | .NET 8 - 9 |
| 3.x | .NET Core 3.1 - .NET 6 |
| 3.x | .NET Core 3.1 - .NET 8 |
| 3.x (Steeltoe.Stream) | .NET Core 3.1 - .NET 6 |
| 2.x | .NET Framework 4.6.1+ |

For more details, see [Supported Versions on the Wiki](https://github.com/SteeltoeOSS/Steeltoe/wiki/Steeltoe-Support-Versions).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,11 +830,8 @@ public void Dispose()
_refreshTimer?.Dispose();
_refreshTimer = null;

if (_timerTickLock != null)
{
_timerTickLock.Dispose();
_timerTickLock = null;
}
_timerTickLock?.Dispose();
_timerTickLock = null;

if (_ownsHttpClientHandler)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ public void TryGet_Array()
provider.TryGet("a:b:c:2:s:t", out value).Should().BeTrue();
value.Should().BeEmpty();

provider.TryGet("a:b:c:3:u", out _).Should().BeFalse();
provider.TryGet("a:b:c:2:u", out _).Should().BeFalse();

provider.TryGet("a:b:c:3:v:w", out _).Should().BeFalse();
provider.TryGet("a:b:c:2:v:w", out _).Should().BeFalse();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public override void Configure(EnvironmentEndpointOptions options)

base.Configure(options);

// It's not possible to distinguish between null and an empty list in configuration.
// See https://github.com/dotnet/extensions/issues/1341.
// As a workaround, we interpret a single empty string element to clear the defaults.
if (options.KeysToSanitize.Count == 0)
{
foreach (string defaultKey in DefaultKeysToSanitize)
Expand All @@ -38,6 +35,9 @@ public override void Configure(EnvironmentEndpointOptions options)
}
else if (options.KeysToSanitize is [""])
{
// When binding a collection property from a JSON configuration file, setting the key to null or an empty
// collection is ignored. As a workaround, we interpret a single empty string element to clear the defaults.

options.KeysToSanitize.Clear();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public void Configure(Exposure options)
}
else
{
// When binding a collection property from a JSON configuration file, setting the key to null or an empty
// collection is ignored. As a workaround, we interpret a single empty string element to clear the defaults.

if (options.Include is [""])
{
includes.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,38 @@ public async Task Can_clear_default_keys_to_sanitize()
options.KeysToSanitize.Should().BeEmpty();
}

[Fact]
public async Task Can_clear_default_keys_to_sanitize_via_JSON()
{
const string appSettings = """
{
"Management": {
"Endpoints": {
"Env": {
"KeysToSanitize": [
""
]
}
}
}
}
""";

await using var stream = TextConverter.ToStream(appSettings);
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddJsonStream(stream);
IConfiguration configuration = configurationBuilder.Build();

var services = new ServiceCollection();
services.AddSingleton(configuration);
services.AddEnvironmentActuator();
await using ServiceProvider serviceProvider = services.BuildServiceProvider(true);

EnvironmentEndpointOptions options = serviceProvider.GetRequiredService<IOptions<EnvironmentEndpointOptions>>().Value;

options.KeysToSanitize.Should().BeEmpty();
}

[Theory]
[InlineData(HostBuilderType.Host)]
[InlineData(HostBuilderType.WebHost)]
Expand Down
39 changes: 39 additions & 0 deletions src/Management/test/Endpoint.Test/ManagementOptionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Steeltoe.Common.Json;
using Steeltoe.Common.TestResources;
using Steeltoe.Management.Endpoint.Actuators.Info;
using Steeltoe.Management.Endpoint.Actuators.Loggers;
using Steeltoe.Management.Endpoint.Actuators.Refresh;
Expand Down Expand Up @@ -186,6 +187,44 @@ public async Task Can_clear_default_exposure()
options.Exposure.Exclude.Should().BeEmpty();
}

[Fact]
public async Task Can_clear_default_exposure_via_JSON()
{
const string appSettings = """
{
"Management": {
"Endpoints": {
"Actuator": {
"Exposure": {
"Include": [
""
],
"Exclude": [
""
]
}
}
}
}
}
""";

await using var stream = TextConverter.ToStream(appSettings);
var configurationBuilder = new ConfigurationBuilder();
configurationBuilder.AddJsonStream(stream);
IConfiguration configuration = configurationBuilder.Build();

var services = new ServiceCollection();
services.AddSingleton(configuration);
services.AddInfoActuator();
await using ServiceProvider serviceProvider = services.BuildServiceProvider(true);

ManagementOptions options = serviceProvider.GetRequiredService<IOptions<ManagementOptions>>().Value;

options.Exposure.Include.Should().BeEmpty();
options.Exposure.Exclude.Should().BeEmpty();
}

[Fact]
public async Task Can_clear_default_exposure_with_Spring_syntax()
{
Expand Down
Loading