From aa1fb5ac4e934eaef3cc16e21293e675bdacbe44 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 26 Feb 2026 17:29:05 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20session=20A=20=E2=80=94=20NoSystemAccoun?= =?UTF-8?q?t=20guard,=20MaxControlLine=20default,=20URL/TLS=20converter=20?= =?UTF-8?q?tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/ServerOptionsConfiguration.cs | 5 +++ .../ZB.MOM.NatsNet.Server.csproj | 4 +- .../Config/ServerOptionsConfigurationTests.cs | 38 +++++++++++++++++++ reports/current.md | 2 +- reports/report_9c1ffc0.md | 38 +++++++++++++++++++ 5 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 reports/report_9c1ffc0.md diff --git a/dotnet/src/ZB.MOM.NatsNet.Server/Config/ServerOptionsConfiguration.cs b/dotnet/src/ZB.MOM.NatsNet.Server/Config/ServerOptionsConfiguration.cs index b6d03f5..ee3babf 100644 --- a/dotnet/src/ZB.MOM.NatsNet.Server/Config/ServerOptionsConfiguration.cs +++ b/dotnet/src/ZB.MOM.NatsNet.Server/Config/ServerOptionsConfiguration.cs @@ -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; } diff --git a/dotnet/src/ZB.MOM.NatsNet.Server/ZB.MOM.NatsNet.Server.csproj b/dotnet/src/ZB.MOM.NatsNet.Server/ZB.MOM.NatsNet.Server.csproj index c11f5bf..0c68720 100644 --- a/dotnet/src/ZB.MOM.NatsNet.Server/ZB.MOM.NatsNet.Server.csproj +++ b/dotnet/src/ZB.MOM.NatsNet.Server/ZB.MOM.NatsNet.Server.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Config/ServerOptionsConfigurationTests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Config/ServerOptionsConfigurationTests.cs index 1a0fcde..da16cf9 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Config/ServerOptionsConfigurationTests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Config/ServerOptionsConfigurationTests.cs @@ -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(() => TlsVersionJsonConverter.Parse("2.0")); + } +} diff --git a/reports/current.md b/reports/current.md index 0a855a4..9b41d56 100644 --- a/reports/current.md +++ b/reports/current.md @@ -1,6 +1,6 @@ # NATS .NET Porting Status Report -Generated: 2026-02-26 22:18:29 UTC +Generated: 2026-02-26 22:29:06 UTC ## Modules (12 total) diff --git a/reports/report_9c1ffc0.md b/reports/report_9c1ffc0.md new file mode 100644 index 0000000..9b41d56 --- /dev/null +++ b/reports/report_9c1ffc0.md @@ -0,0 +1,38 @@ +# NATS .NET Porting Status Report + +Generated: 2026-02-26 22:29:06 UTC + +## Modules (12 total) + +| Status | Count | +|--------|-------| +| complete | 11 | +| not_started | 1 | + +## Features (3673 total) + +| Status | Count | +|--------|-------| +| complete | 3570 | +| n_a | 77 | +| stub | 26 | + +## Unit Tests (3257 total) + +| Status | Count | +|--------|-------| +| complete | 319 | +| n_a | 181 | +| not_started | 2533 | +| stub | 224 | + +## Library Mappings (36 total) + +| Status | Count | +|--------|-------| +| mapped | 36 | + + +## Overall Progress + +**4158/6942 items complete (59.9%)**