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 0df176f..2788a9d 100644 Binary files a/porting.db and b/porting.db differ