using Shouldly; using ZB.MOM.NatsNet.Server; namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog; public sealed partial class LeafNodeProxyTests { [Fact] // T:1897 public void LeafNodeHttpProxyConfigParsing_ShouldSucceed() { var errors = new List(); var warnings = new List(); var remotes = ServerOptions.ParseRemoteLeafNodes( new List { new Dictionary { ["url"] = "ws://127.0.0.1:7422", ["proxy"] = new Dictionary { ["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(); var warnings = new List(); var cases = new[] { new Dictionary { ["url"] = "nats://127.0.0.1:7422", ["proxy"] = new Dictionary { ["url"] = "http://proxy.example.com:8080", }, }, new Dictionary { ["urls"] = new List { "nats://127.0.0.1:7422", "ws://127.0.0.1:8080" }, ["proxy"] = new Dictionary { ["url"] = "http://proxy.example.com:8080", }, }, new Dictionary { ["url"] = "ws://127.0.0.1:7422", ["proxy"] = new Dictionary { ["url"] = "http://proxy.example.com:8080", }, }, }; foreach (var remote in cases) { var parsed = ServerOptions.ParseRemoteLeafNodes(new List { remote }, errors, warnings); parsed.Count.ShouldBe(1); parsed[0].Proxy.Url.ShouldBe("http://proxy.example.com:8080"); } errors.ShouldBeEmpty(); } }