feat(batch1): add init parity hooks for ciphers and constants
This commit is contained in:
@@ -56,6 +56,16 @@ public static class CipherSuites
|
||||
CipherMapById = byId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compatibility init hook for PortTracker parity with Go <c>init()</c>.
|
||||
/// Safe and idempotent.
|
||||
/// </summary>
|
||||
public static void Init()
|
||||
{
|
||||
_ = CipherMap;
|
||||
_ = CipherMapById;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the default set of TLS 1.2 cipher suites.
|
||||
/// .NET manages cipher suite selection at the OS/SChannel/OpenSSL level;
|
||||
|
||||
@@ -214,6 +214,15 @@ public static class ServerConstants
|
||||
GitCommit = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compatibility init hook for PortTracker parity with Go <c>init()</c>.
|
||||
/// Safe and idempotent.
|
||||
/// </summary>
|
||||
public static void Init()
|
||||
{
|
||||
_ = GitCommit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Truncates a VCS revision string to 7 characters for display.
|
||||
/// Mirrors <c>formatRevision</c> in const.go.
|
||||
|
||||
@@ -24,6 +24,19 @@ namespace ZB.MOM.NatsNet.Server.Tests.Auth;
|
||||
/// </summary>
|
||||
public class CipherSuitesTests
|
||||
{
|
||||
[Fact]
|
||||
public void Init_CalledMultipleTimes_RemainsIdempotent()
|
||||
{
|
||||
var beforeCount = CipherSuites.CipherMap.Count;
|
||||
var beforeByIdCount = CipherSuites.CipherMapById.Count;
|
||||
|
||||
CipherSuites.Init();
|
||||
CipherSuites.Init();
|
||||
|
||||
CipherSuites.CipherMap.Count.ShouldBe(beforeCount);
|
||||
CipherSuites.CipherMapById.Count.ShouldBe(beforeByIdCount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CipherMap_ContainsTls13Suites()
|
||||
{
|
||||
|
||||
@@ -32,6 +32,17 @@ namespace ZB.MOM.NatsNet.Server.Tests;
|
||||
/// </summary>
|
||||
public sealed class ServerTests
|
||||
{
|
||||
[Fact]
|
||||
public void Init_CalledMultipleTimes_RemainsIdempotent()
|
||||
{
|
||||
var before = ServerConstants.GitCommit;
|
||||
|
||||
ServerConstants.Init();
|
||||
ServerConstants.Init();
|
||||
|
||||
ServerConstants.GitCommit.ShouldBe(before);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// TestSemanticVersion — Test ID 2866
|
||||
// Validates that ServerConstants.Version matches semver format.
|
||||
|
||||
Reference in New Issue
Block a user