test(batch18): port behavioral batch-18 tests
This commit is contained in:
@@ -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<TcpListener>();
|
||||
listener.Stop();
|
||||
|
||||
var transitioned = SpinWait.SpinUntil(() => server.HTTPHandler() == null, TimeSpan.FromSeconds(5));
|
||||
transitioned.ShouldBeTrue();
|
||||
server.HTTPHandler().ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetMonitoringTLSConfig_WithServerTlsConfig_DisablesClientCertificateRequirementOnClone()
|
||||
{
|
||||
|
||||
@@ -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<string, object?>
|
||||
{
|
||||
["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()
|
||||
{
|
||||
|
||||
@@ -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<string>(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<string[]> LookupHostAsync(string host, CancellationToken ct = default)
|
||||
=> Task.FromResult(hosts);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user