test(batch7): implement t2 route leaf and proxy mapped tests

This commit is contained in:
Joseph Doherty
2026-02-28 11:22:17 -05:00
parent 390758e318
commit 007122a659
4 changed files with 405 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
using Shouldly;
using ZB.MOM.NatsNet.Server;
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
public sealed class LeafNodeProxyTests
{
[Fact] // T:1897
public void LeafNodeHttpProxyConfigParsing_ShouldSucceed()
{
var errors = new List<Exception>();
var warnings = new List<Exception>();
var remotes = ServerOptions.ParseRemoteLeafNodes(
new List<object?>
{
new Dictionary<string, object?>
{
["url"] = "ws://127.0.0.1:7422",
["proxy"] = new Dictionary<string, object?>
{
["url"] = "http://proxy.example.com:8080",
["username"] = "user",
["password"] = "pass",
["timeout"] = "10s",
},
},
},
errors,
warnings);
errors.ShouldBeEmpty();
remotes.Count.ShouldBe(1);
remotes[0].Proxy.Url.ShouldBe("http://proxy.example.com:8080");
remotes[0].Proxy.Username.ShouldBe("user");
remotes[0].Proxy.Password.ShouldBe("pass");
remotes[0].Proxy.Timeout.ShouldBe(TimeSpan.FromSeconds(10));
}
[Fact] // T:1898
public void LeafNodeHttpProxyConfigWarnings_ShouldSucceed()
{
var errors = new List<Exception>();
var warnings = new List<Exception>();
var cases = new[]
{
new Dictionary<string, object?>
{
["url"] = "nats://127.0.0.1:7422",
["proxy"] = new Dictionary<string, object?>
{
["url"] = "http://proxy.example.com:8080",
},
},
new Dictionary<string, object?>
{
["urls"] = new List<object?> { "nats://127.0.0.1:7422", "ws://127.0.0.1:8080" },
["proxy"] = new Dictionary<string, object?>
{
["url"] = "http://proxy.example.com:8080",
},
},
new Dictionary<string, object?>
{
["url"] = "ws://127.0.0.1:7422",
["proxy"] = new Dictionary<string, object?>
{
["url"] = "http://proxy.example.com:8080",
},
},
};
foreach (var remote in cases)
{
var parsed = ServerOptions.ParseRemoteLeafNodes(new List<object?> { remote }, errors, warnings);
parsed.Count.ShouldBe(1);
parsed[0].Proxy.Url.ShouldBe("http://proxy.example.com:8080");
}
errors.ShouldBeEmpty();
}
}