refactor: extract NATS.Server.Transport.Tests project
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.
This commit is contained in:
90
tests/NATS.Server.Transport.Tests/OcspConfigTests.cs
Normal file
90
tests/NATS.Server.Transport.Tests/OcspConfigTests.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using NATS.Server.Tls;
|
||||
|
||||
namespace NATS.Server.Transport.Tests;
|
||||
|
||||
public class OcspConfigTests
|
||||
{
|
||||
[Fact]
|
||||
public void OcspMode_Auto_has_value_zero()
|
||||
{
|
||||
((int)OcspMode.Auto).ShouldBe(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OcspMode_Always_has_value_one()
|
||||
{
|
||||
((int)OcspMode.Always).ShouldBe(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OcspMode_Must_has_value_two()
|
||||
{
|
||||
((int)OcspMode.Must).ShouldBe(2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OcspMode_Never_has_value_three()
|
||||
{
|
||||
((int)OcspMode.Never).ShouldBe(3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OcspConfig_default_mode_is_Auto()
|
||||
{
|
||||
var config = new OcspConfig();
|
||||
config.Mode.ShouldBe(OcspMode.Auto);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OcspConfig_OverrideUrls_defaults_to_empty_array()
|
||||
{
|
||||
var config = new OcspConfig();
|
||||
config.OverrideUrls.ShouldNotBeNull();
|
||||
config.OverrideUrls.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OcspConfig_Mode_can_be_set_via_init()
|
||||
{
|
||||
var config = new OcspConfig { Mode = OcspMode.Must };
|
||||
config.Mode.ShouldBe(OcspMode.Must);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OcspConfig_OverrideUrls_can_be_set_via_init()
|
||||
{
|
||||
var urls = new[] { "http://ocsp.example.com", "http://backup.example.com" };
|
||||
var config = new OcspConfig { OverrideUrls = urls };
|
||||
config.OverrideUrls.ShouldBe(urls);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NatsOptions_OcspConfig_defaults_to_null()
|
||||
{
|
||||
var opts = new NatsOptions();
|
||||
opts.OcspConfig.ShouldBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NatsOptions_OcspPeerVerify_defaults_to_false()
|
||||
{
|
||||
var opts = new NatsOptions();
|
||||
opts.OcspPeerVerify.ShouldBeFalse();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NatsOptions_OcspConfig_can_be_assigned()
|
||||
{
|
||||
var config = new OcspConfig { Mode = OcspMode.Always };
|
||||
var opts = new NatsOptions { OcspConfig = config };
|
||||
opts.OcspConfig.ShouldNotBeNull();
|
||||
opts.OcspConfig!.Mode.ShouldBe(OcspMode.Always);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NatsOptions_OcspPeerVerify_can_be_set_to_true()
|
||||
{
|
||||
var opts = new NatsOptions { OcspPeerVerify = true };
|
||||
opts.OcspPeerVerify.ShouldBeTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user