Move TLS, OCSP, WebSocket, Networking, and IO test files from NATS.Server.Tests into a dedicated NATS.Server.Transport.Tests project. Update namespaces, replace private GetFreePort/ReadUntilAsync with shared TestUtilities helpers, extract TestCertHelper to TestUtilities, and replace Task.Delay polling loops with PollHelper.WaitUntilAsync/YieldForAsync for proper synchronization.
51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
using Shouldly;
|
|
using NATS.Server.WebSocket;
|
|
|
|
namespace NATS.Server.Transport.Tests.WebSocket;
|
|
|
|
public class WebSocketOptionsTests
|
|
{
|
|
[Fact]
|
|
public void DefaultOptions_PortIsNegativeOne_Disabled()
|
|
{
|
|
var opts = new WebSocketOptions();
|
|
opts.Port.ShouldBe(-1);
|
|
opts.Host.ShouldBe("0.0.0.0");
|
|
opts.Compression.ShouldBeFalse();
|
|
opts.NoTls.ShouldBeFalse();
|
|
opts.HandshakeTimeout.ShouldBe(TimeSpan.FromSeconds(2));
|
|
opts.AuthTimeout.ShouldBe(TimeSpan.FromSeconds(2));
|
|
}
|
|
|
|
[Fact]
|
|
public void NatsOptions_HasWebSocketProperty()
|
|
{
|
|
var opts = new NatsOptions();
|
|
opts.WebSocket.ShouldNotBeNull();
|
|
opts.WebSocket.Port.ShouldBe(-1);
|
|
}
|
|
|
|
[Fact]
|
|
public void WsAuthConfig_sets_auth_override_when_websocket_auth_fields_are_present()
|
|
{
|
|
var ws = new WebSocketOptions
|
|
{
|
|
Username = "u",
|
|
};
|
|
|
|
WsAuthConfig.Apply(ws);
|
|
|
|
ws.AuthOverride.ShouldBeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public void WsAuthConfig_keeps_auth_override_false_when_no_ws_auth_fields_are_present()
|
|
{
|
|
var ws = new WebSocketOptions();
|
|
|
|
WsAuthConfig.Apply(ws);
|
|
|
|
ws.AuthOverride.ShouldBeFalse();
|
|
}
|
|
}
|