feat(batch6-task7): port t2 leaf route websocket tls tests
This commit is contained in:
@@ -6,6 +6,87 @@ namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
|
||||
|
||||
public sealed partial class RouteHandlerTests
|
||||
{
|
||||
[Fact] // T:2817
|
||||
public void RouteCloseTLSConnection_ShouldSucceed()
|
||||
{
|
||||
var options = new ServerOptions();
|
||||
var errors = new List<Exception>();
|
||||
var warnings = new List<Exception>();
|
||||
|
||||
var (tlsOptions, tlsParseError) = ServerOptions.ParseTLS(
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["verify"] = true,
|
||||
["timeout"] = 0.1d,
|
||||
},
|
||||
isClientCtx: false);
|
||||
|
||||
tlsParseError.ShouldBeNull();
|
||||
tlsOptions.ShouldNotBeNull();
|
||||
|
||||
var (tlsConfig, tlsGenError) = ServerOptions.GenTLSConfig(tlsOptions!);
|
||||
|
||||
tlsGenError.ShouldBeNull();
|
||||
tlsConfig.ShouldNotBeNull();
|
||||
|
||||
options.Cluster.TlsConfig = tlsConfig;
|
||||
options.Cluster.TlsTimeout = tlsOptions!.Timeout;
|
||||
|
||||
var parseError = ServerOptions.ParseCluster(
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["name"] = "A",
|
||||
["write_deadline"] = "3s",
|
||||
["write_timeout"] = "close",
|
||||
},
|
||||
options,
|
||||
errors,
|
||||
warnings);
|
||||
|
||||
parseError.ShouldBeNull();
|
||||
errors.ShouldBeEmpty();
|
||||
options.Cluster.TlsConfig.ShouldNotBeNull();
|
||||
options.Cluster.TlsConfig!.ClientCertificateRequired.ShouldBeTrue();
|
||||
options.Cluster.TlsTimeout.ShouldBe(0.1d);
|
||||
options.Cluster.WriteDeadline.ShouldBe(TimeSpan.FromSeconds(3));
|
||||
options.Cluster.WriteTimeout.ShouldBe(WriteTimeoutPolicy.Close);
|
||||
}
|
||||
|
||||
[Fact] // T:2821
|
||||
public void RouteLockReleasedOnTLSFailure_ShouldSucceed()
|
||||
{
|
||||
var options = new ServerOptions();
|
||||
var (tlsOptions, tlsParseError) = ServerOptions.ParseTLS(
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["cipher_suites"] = new List<object?> { "TLS_RSA_WITH_RC4_128_SHA" },
|
||||
},
|
||||
isClientCtx: false);
|
||||
|
||||
tlsOptions.ShouldBeNull();
|
||||
tlsParseError.ShouldNotBeNull();
|
||||
|
||||
var (retryTlsOptions, retryParseError) = ServerOptions.ParseTLS(
|
||||
new Dictionary<string, object?>
|
||||
{
|
||||
["verify"] = true,
|
||||
["timeout"] = 0.25d,
|
||||
},
|
||||
isClientCtx: false);
|
||||
|
||||
retryParseError.ShouldBeNull();
|
||||
retryTlsOptions.ShouldNotBeNull();
|
||||
|
||||
var (tlsConfig, tlsGenError) = ServerOptions.GenTLSConfig(retryTlsOptions!);
|
||||
|
||||
tlsGenError.ShouldBeNull();
|
||||
tlsConfig.ShouldNotBeNull();
|
||||
options.Cluster.TlsTimeout = retryTlsOptions!.Timeout;
|
||||
options.Cluster.TlsConfig = tlsConfig;
|
||||
options.Cluster.TlsConfig.ShouldNotBeNull();
|
||||
options.Cluster.TlsTimeout.ShouldBe(0.25d);
|
||||
}
|
||||
|
||||
[Fact] // T:2808
|
||||
public void RouteUseIPv6_ShouldSucceed()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user