using System;
using StellaOps.Authority.Plugins.Abstractions;

namespace StellaOps.Authority.Plugins.Abstractions.Tests;

public class AuthorityIdentityProviderCapabilitiesTests
{
    [Fact]
    public void FromCapabilities_SetsFlags_WhenTokensPresent()
    {
        var capabilities = AuthorityIdentityProviderCapabilities.FromCapabilities(new[]
        {
            "password",
            "mfa",
            "clientProvisioning"
        });

        Assert.True(capabilities.SupportsPassword);
        Assert.True(capabilities.SupportsMfa);
        Assert.True(capabilities.SupportsClientProvisioning);
    }

    [Fact]
    public void FromCapabilities_DefaultsToFalse_WhenEmpty()
    {
        var capabilities = AuthorityIdentityProviderCapabilities.FromCapabilities(Array.Empty<string>());

        Assert.False(capabilities.SupportsPassword);
        Assert.False(capabilities.SupportsMfa);
        Assert.False(capabilities.SupportsClientProvisioning);
    }

    [Fact]
    public void FromCapabilities_IgnoresNullSet()
    {
        var capabilities = AuthorityIdentityProviderCapabilities.FromCapabilities(null!);

        Assert.False(capabilities.SupportsPassword);
        Assert.False(capabilities.SupportsMfa);
        Assert.False(capabilities.SupportsClientProvisioning);
    }
}
