fix: session A — NoSystemAccount guard, MaxControlLine default, URL/TLS converter tests
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// Licensed under the Apache License, Version 2.0
|
||||
namespace ZB.MOM.NatsNet.Server.Tests.Config;
|
||||
|
||||
using System.Security.Authentication;
|
||||
using ZB.MOM.NatsNet.Server.Config;
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
@@ -109,3 +110,40 @@ public class StorageSizeJsonConverterTests
|
||||
StorageSizeJsonConverter.Parse(input).ShouldBe(expectedBytes);
|
||||
}
|
||||
}
|
||||
|
||||
public class NatsUrlJsonConverterTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("nats://localhost:4222", "nats://localhost:4222")]
|
||||
[InlineData("localhost:4222", "nats://localhost:4222")]
|
||||
[InlineData("localhost", "nats://localhost")]
|
||||
public void Normalise_ValidUrls_NormalisesCorrectly(string input, string expected)
|
||||
{
|
||||
NatsUrlJsonConverter.Normalise(input).ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Normalise_EmptyString_ReturnsEmpty()
|
||||
{
|
||||
NatsUrlJsonConverter.Normalise(string.Empty).ShouldBe(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public class TlsVersionJsonConverterTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("1.2", SslProtocols.Tls12)]
|
||||
[InlineData("TLS12", SslProtocols.Tls12)]
|
||||
[InlineData("1.3", SslProtocols.Tls13)]
|
||||
[InlineData("TLS13", SslProtocols.Tls13)]
|
||||
public void Parse_ValidVersionStrings_ReturnsCorrectProtocol(string input, SslProtocols expected)
|
||||
{
|
||||
TlsVersionJsonConverter.Parse(input).ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Parse_InvalidVersion_ThrowsFormatException()
|
||||
{
|
||||
Should.Throw<FormatException>(() => TlsVersionJsonConverter.Parse("2.0"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user