test(batch26): port cross-module websocket-dependent tests
This commit is contained in:
@@ -1,11 +1,60 @@
|
||||
using Shouldly;
|
||||
using ZB.MOM.NatsNet.Server;
|
||||
using ZB.MOM.NatsNet.Server.Internal;
|
||||
using ZB.MOM.NatsNet.Server.WebSocket;
|
||||
|
||||
namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||
|
||||
public sealed partial class LeafNodeHandlerTests
|
||||
{
|
||||
[Fact] // T:1975
|
||||
public void LeafNodeTLSHandshakeFirstVerifyNoInfoSent_ShouldSucceed()
|
||||
{
|
||||
var errors = new List<Exception>();
|
||||
var warnings = new List<Exception>();
|
||||
|
||||
var remotes = ServerOptions.ParseRemoteLeafNodes(
|
||||
new List<object?>
|
||||
{
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["url"] = "wss://127.0.0.1:7422",
|
||||
["first_info_timeout"] = "2s",
|
||||
["tls"] = new Dictionary<string, object?>
|
||||
{
|
||||
["verify"] = true,
|
||||
["timeout"] = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
errors,
|
||||
warnings);
|
||||
|
||||
errors.ShouldBeEmpty();
|
||||
remotes.Count.ShouldBe(1);
|
||||
remotes[0].FirstInfoTimeout.ShouldBe(TimeSpan.FromSeconds(2));
|
||||
remotes[0].TlsConfig.ShouldNotBeNull();
|
||||
remotes[0].TlsTimeout.ShouldBe(1d);
|
||||
}
|
||||
|
||||
[Fact] // T:1986
|
||||
public void LeafNodeCompressionWithWSGetNeedsData_ShouldSucceed()
|
||||
{
|
||||
var frame = new byte[] { WsConstants.FinalBit, (byte)(WsConstants.MaskBit | 5), 1, 2, 3, 4, 0x31, 0x32, 0x33, 0x34, 0x35 };
|
||||
var initial = frame[..1];
|
||||
using var remainder = new MemoryStream(frame[1..]);
|
||||
|
||||
var (b1, nextPos) = WebSocketHelpers.WsGet(remainder, initial, 1, 1);
|
||||
b1[0].ShouldBe((byte)(WsConstants.MaskBit | 5));
|
||||
nextPos.ShouldBe(1);
|
||||
|
||||
var (mask, _) = WebSocketHelpers.WsGet(remainder, initial, 1, 4);
|
||||
var (payload, _) = WebSocketHelpers.WsGet(remainder, initial, 1, 5);
|
||||
WebSocketHelpers.WsMaskBuf(mask, payload);
|
||||
|
||||
payload.ShouldBe(new byte[] { 0x30, 0x30, 0x30, 0x30, 0x34 });
|
||||
}
|
||||
|
||||
[Fact] // T:1984
|
||||
public void LeafNodeCompressionAuto_ShouldSucceed()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user