using Eis.Infrastructure.Authentication;

namespace Eis.Infrastructure.Tests.Authentication;

public sealed class PasswordCompatibilityServiceTests
{
    [Fact]
    public void VerifiesNodePbkdf2PasswordHash()
    {
        const string stored = "00112233445566778899aabbccddeeff:7a69c21675902559aa0cae041a3b4ebb3bc1402bb70a753eff44f5b32543c270";
        var service = new PasswordCompatibilityService();

        Assert.True(service.Verify("兼容Password123!", stored));
        Assert.False(service.Verify("wrong-password", stored));
    }

    [Fact]
    public void CreatesHashUsingLegacySaltAndDigestShape()
    {
        var service = new PasswordCompatibilityService();
        var stored = service.Hash("Password123!");
        var parts = stored.Split(':');

        Assert.Equal(2, parts.Length);
        Assert.Equal(32, parts[0].Length);
        Assert.Equal(64, parts[1].Length);
        Assert.True(service.Verify("Password123!", stored));
    }
}
