using ZB.MOM.WW.MxGateway.Server.Dashboard;

namespace ZB.MOM.WW.MxGateway.Tests.Gateway.Dashboard;

public sealed class DashboardConnectionStringDisplayTests
{
    /// <summary>Verifies that Galaxy connection strings strip SQL credentials and keep only non-secret fields.</summary>
    [Fact]
    public void GalaxyRepositoryConnectionString_WithSqlCredentials_OnlyKeepsNonSecretFields()
    {
        string display = DashboardConnectionStringDisplay.GalaxyRepositoryConnectionString(
            "Server=localhost;Database=ZB;User ID=mxuser;Password=secret;Encrypt=True;Trust Server Certificate=False;");

        Assert.Contains("Data Source=localhost", display, StringComparison.Ordinal);
        Assert.Contains("Initial Catalog=ZB", display, StringComparison.Ordinal);
        Assert.Contains("Encrypt=True", display, StringComparison.Ordinal);
        Assert.DoesNotContain("User", display, StringComparison.OrdinalIgnoreCase);
        Assert.DoesNotContain("Password", display, StringComparison.OrdinalIgnoreCase);
        Assert.DoesNotContain("secret", display, StringComparison.OrdinalIgnoreCase);
        Assert.DoesNotContain("mxuser", display, StringComparison.OrdinalIgnoreCase);
    }
}
