From eb05308b5a61078e54a12e9e9fc11e34caff8e9e Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Sat, 28 Feb 2026 19:29:19 -0500 Subject: [PATCH] test(batch18): port behavioral batch-18 tests --- .../ImplBacklog/MonitoringHandlerTests.cs | 25 ++++++++++++++++++ .../ImplBacklog/NatsServerTests.cs | 19 +++++++++++++ .../RouteHandlerTests.Impltests.cs | 22 +++++++++++++++ porting.db | Bin 6660096 -> 6660096 bytes 4 files changed, 66 insertions(+) diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.cs index 5fe4fe4..5fac041 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/MonitoringHandlerTests.cs @@ -13,6 +13,31 @@ namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog; public sealed class MonitoringHandlerTests { + [Fact] // T:2111 + public void MonitorHandler_ShouldSucceed() + { + var opts = new ServerOptions + { + HttpHost = "127.0.0.1", + HttpPort = -1, + }; + var (server, error) = NatsServer.NewServer(opts); + error.ShouldBeNull(); + server.ShouldNotBeNull(); + + server!.StartMonitoring().ShouldBeNull(); + server.HTTPHandler().ShouldNotBeNull(); + + var listenerField = typeof(NatsServer).GetField("_http", BindingFlags.Instance | BindingFlags.NonPublic); + listenerField.ShouldNotBeNull(); + var listener = listenerField!.GetValue(server).ShouldBeOfType(); + listener.Stop(); + + var transitioned = SpinWait.SpinUntil(() => server.HTTPHandler() == null, TimeSpan.FromSeconds(5)); + transitioned.ShouldBeTrue(); + server.HTTPHandler().ShouldBeNull(); + } + [Fact] public void GetMonitoringTLSConfig_WithServerTlsConfig_DisablesClientCertificateRequirementOnClone() { diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/NatsServerTests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/NatsServerTests.cs index 38f493c..5fcf1ff 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/NatsServerTests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/NatsServerTests.cs @@ -44,6 +44,25 @@ public sealed class NatsServerTests result.Error.ShouldBe(ServerErrors.ErrAccountValidation); } + [Fact] // T:2897 + public void InsecureSkipVerifyWarning_ShouldSucceed() + { + var (tlsOptions, parseError) = ServerOptions.ParseTLS( + new Dictionary + { + ["insecure"] = true, + }, + isClientCtx: true); + + parseError.ShouldBeNull(); + tlsOptions.ShouldNotBeNull(); + tlsOptions!.Insecure.ShouldBeTrue(); + + var (tlsConfig, tlsError) = ServerOptions.GenTLSConfig(tlsOptions); + tlsError.ShouldBeNull(); + tlsConfig.ShouldNotBeNull(); + } + [Fact] // T:2886 public void CustomRouterAuthentication_ShouldSucceed() { diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs index 4e91b05..f9354f7 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ImplBacklog/RouteHandlerTests.Impltests.cs @@ -7,6 +7,22 @@ namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog; public sealed partial class RouteHandlerTests { + [Fact] // T:2819 + public async Task RouteIPResolutionAndRouteToSelf_ShouldSucceed() + { + var (server, err) = NatsServer.NewServer(new ServerOptions()); + err.ShouldBeNull(); + server.ShouldNotBeNull(); + + var resolver = new FixedResolver(["127.0.0.1", "other.host.in.cluster"]); + var excluded = new HashSet(StringComparer.Ordinal) { "127.0.0.1:1234" }; + + var (address, resolveErr) = await server!.GetRandomIP(resolver, "routehost:1234", excluded); + + resolveErr.ShouldBeNull(); + address.ShouldBe("other.host.in.cluster:1234"); + } + [Fact] public void NumRemotesInternal_WhenRoutesExist_ReturnsCount() { @@ -122,4 +138,10 @@ public sealed partial class RouteHandlerTests route.FlushOutbound().ShouldBeTrue(); route.Flags.IsSet(ClientFlags.IsSlowConsumer).ShouldBeFalse(); } + + private sealed class FixedResolver(string[] hosts) : INetResolver + { + public Task LookupHostAsync(string host, CancellationToken ct = default) + => Task.FromResult(hosts); + } } diff --git a/porting.db b/porting.db index 0df176f3af84b627fe9a45767b3733ce113639ef..2788a9def6a8ace95a2224f7bf901e88e4048d13 100644 GIT binary patch delta 699 zcmYk!Pe_w-9LMoJ&-UAvo7+>(ZE7p$Hmg;0Epv0#)c)8Xm(69Xw*EY;83{o!LOMif z{a_b^y7=`VWYi%eD1!J|kUSA~kPaQ%sf&sn>R?5yOupTzRMsPrl$j&%l+9^F+7e1iIiT9E0O<0=gjyC!q&UK?-^y4X2?G&Oipv!Z|oE;<4;( zMfxRJL#|DdS&f&dpcMfTZL5_QR8&N*3V!tbxJqlp#l)d;FcIUM zG%;w51Ahkw1_n$VbTBVEkTV7&8z!$&Gtbu;3Y@*t!1Y|K`VOL*DQ>2>g7R9r&n;x2MR-|9EI$5@N zi`*NwBK@z$%p3zZ)WI593-uy1=XqL7&xdM4R9fM^b;D-QgfQ`@yLD&Q#u^MTbchIAN8lZ*yjUoCIZE7R) zXI*VE5o>}lG(!t)hAj|*t8p4@Y1Cj>0iG4rw?6C*c$f!VsK>GjJBpi9{^(t}J~QYNH;PC>7MF zrmrzT_b%_dJi~&tc zYrR^R)@)m$^n2qT{a7>{!dNn*s?