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();
    }
}
