fix: session A — NoSystemAccount guard, MaxControlLine default, URL/TLS converter tests
This commit is contained in:
@@ -109,6 +109,9 @@ public static class ServerOptionsConfiguration
|
||||
// Apply default auth timeout.
|
||||
if (opts.AuthTimeout == 0) opts.AuthTimeout = ServerConstants.DefaultAuthTimeout;
|
||||
|
||||
// Apply default max control line size.
|
||||
if (opts.MaxControlLine == 0) opts.MaxControlLine = ServerConstants.MaxControlLineSize;
|
||||
|
||||
// Ensure SystemAccount defaults if not set.
|
||||
ConfigureSystemAccount(opts);
|
||||
}
|
||||
@@ -121,6 +124,8 @@ public static class ServerOptionsConfiguration
|
||||
{
|
||||
// If system account already set, nothing to do.
|
||||
if (!string.IsNullOrEmpty(opts.SystemAccount)) return;
|
||||
// Respect explicit opt-out.
|
||||
if (opts.NoSystemAccount) return;
|
||||
// Default to "$SYS" if not explicitly disabled.
|
||||
opts.SystemAccount = ServerConstants.DefaultSystemAccount;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="*" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="*" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="*" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="*" />
|
||||
<PackageReference Include="BCrypt.Net-Next" Version="*" />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Licensed under the Apache License, Version 2.0
|
||||
namespace ZB.MOM.NatsNet.Server.Tests.Config;
|
||||
|
||||
using System.Security.Authentication;
|
||||
using ZB.MOM.NatsNet.Server.Config;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
@@ -109,3 +110,40 @@ public class StorageSizeJsonConverterTests
|
||||
StorageSizeJsonConverter.Parse(input).ShouldBe(expectedBytes);
|
||||
}
|
||||
}
|
||||
|
||||
public class NatsUrlJsonConverterTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("nats://localhost:4222", "nats://localhost:4222")]
|
||||
[InlineData("localhost:4222", "nats://localhost:4222")]
|
||||
[InlineData("localhost", "nats://localhost")]
|
||||
public void Normalise_ValidUrls_NormalisesCorrectly(string input, string expected)
|
||||
{
|
||||
NatsUrlJsonConverter.Normalise(input).ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Normalise_EmptyString_ReturnsEmpty()
|
||||
{
|
||||
NatsUrlJsonConverter.Normalise(string.Empty).ShouldBe(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public class TlsVersionJsonConverterTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("1.2", SslProtocols.Tls12)]
|
||||
[InlineData("TLS12", SslProtocols.Tls12)]
|
||||
[InlineData("1.3", SslProtocols.Tls13)]
|
||||
[InlineData("TLS13", SslProtocols.Tls13)]
|
||||
public void Parse_ValidVersionStrings_ReturnsCorrectProtocol(string input, SslProtocols expected)
|
||||
{
|
||||
TlsVersionJsonConverter.Parse(input).ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_InvalidVersion_ThrowsFormatException()
|
||||
{
|
||||
Should.Throw<FormatException>(() => TlsVersionJsonConverter.Parse("2.0"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user