Files
natsnet/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/Auth/OcspResponseCacheParserTests.cs

55 lines
1.5 KiB
C#

using Shouldly;
using ZB.MOM.NatsNet.Server;
namespace ZB.MOM.NatsNet.Server.Tests.Auth;
public sealed class OcspResponseCacheParserTests
{
[Fact]
public void NewOCSPResponseCacheConfig_Defaults_ReturnExpectedValues()
{
var config = OcspHandler.NewOCSPResponseCacheConfig();
config.Type.ShouldBe("local");
config.LocalStore.ShouldBe("_rc_");
config.PreserveRevoked.ShouldBeFalse();
config.SaveInterval.ShouldBe(TimeSpan.FromMinutes(5).TotalSeconds);
}
[Fact]
public void ParseOCSPResponseCache_StringDurationBelowMinimum_ClampsToOneSecond()
{
var input = new Dictionary<string, object?>
{
["type"] = "local",
["save_interval"] = "500ms",
};
var (config, error) = OcspHandler.ParseOCSPResponseCache(input);
error.ShouldBeNull();
config.ShouldNotBeNull();
config.SaveInterval.ShouldBe(1);
}
[Fact]
public void ParseOCSPResponseCache_NoneType_AcceptsConfiguration()
{
var input = new Dictionary<string, object?>
{
["type"] = "none",
["local_store"] = "_rc_",
["preserve_revoked"] = true,
["save_interval"] = 25.0,
};
var (config, error) = OcspHandler.ParseOCSPResponseCache(input);
error.ShouldBeNull();
config.ShouldNotBeNull();
config.Type.ShouldBe("none");
config.PreserveRevoked.ShouldBeTrue();
config.SaveInterval.ShouldBe(25.0);
}
}