using GmRelay.Bot.Infrastructure.Logging;

namespace GmRelay.Bot.Tests.Infrastructure.Logging;

public sealed class SecretRedactorTests
{
    [Fact]
    public void RedactConnectionString_ShouldMaskDatabasePassword()
    {
        var result = SecretRedactor.RedactConnectionString(
            "Host=localhost;Port=5432;Database=gmrelay;Username=gmrelay;Password=super-secret");

        Assert.Contains("Password=***", result);
        Assert.DoesNotContain("super-secret", result);
        Assert.Contains("Host=localhost", result);
    }

    [Fact]
    public void RedactText_ShouldMaskKnownSecretKeys()
    {
        var result = SecretRedactor.RedactText(
            "Password=super-secret Token=telegram-token apiKey=service-key");

        Assert.DoesNotContain("super-secret", result);
        Assert.DoesNotContain("telegram-token", result);
        Assert.DoesNotContain("service-key", result);
        Assert.Contains("Password=***", result);
        Assert.Contains("Token=***", result);
        Assert.Contains("apiKey=***", result);
    }
}
