29 lines
820 B
C#
29 lines
820 B
C#
using System.Collections.Generic;
|
|
using System.IO;
|
|
using MxGateway.Worker.Bootstrap;
|
|
|
|
namespace MxGateway.Worker.Tests.Bootstrap;
|
|
|
|
public sealed class WorkerConsoleLoggerTests
|
|
{
|
|
[Fact]
|
|
public void Information_RedactsNonceInStructuredOutput()
|
|
{
|
|
StringWriter writer = new();
|
|
WorkerConsoleLogger logger = new(writer);
|
|
|
|
logger.Information("WorkerBootstrapSucceeded", new Dictionary<string, object?>
|
|
{
|
|
["session_id"] = "session-1",
|
|
["nonce"] = "nonce-secret",
|
|
});
|
|
|
|
string output = writer.ToString();
|
|
|
|
Assert.Contains("event=WorkerBootstrapSucceeded", output);
|
|
Assert.Contains("session_id=session-1", output);
|
|
Assert.Contains("nonce=[redacted]", output);
|
|
Assert.DoesNotContain("nonce-secret", output);
|
|
}
|
|
}
|