Build initial MCP SSH server
This commit is contained in:
31
tests/McpSsh.Tests/JsonLineAuditLoggerTests.cs
Normal file
31
tests/McpSsh.Tests/JsonLineAuditLoggerTests.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Text.Json;
|
||||
using McpSsh.Server.Audit;
|
||||
|
||||
namespace McpSsh.Tests;
|
||||
|
||||
public sealed class JsonLineAuditLoggerTests
|
||||
{
|
||||
[Fact]
|
||||
public void Log_WritesJsonLineAndRedactsSensitiveMarkers()
|
||||
{
|
||||
using var writer = new StringWriter();
|
||||
var logger = new JsonLineAuditLogger(writer);
|
||||
|
||||
logger.Log(new AuditEvent(
|
||||
DateTimeOffset.Parse("2026-05-24T12:00:00Z"),
|
||||
"ssh_exec",
|
||||
"prod-api",
|
||||
"deploy",
|
||||
"echo token=abc123",
|
||||
Success: true,
|
||||
DurationMs: 42));
|
||||
|
||||
using var document = JsonDocument.Parse(writer.ToString());
|
||||
var root = document.RootElement;
|
||||
|
||||
Assert.Equal("ssh_exec", root.GetProperty("tool").GetString());
|
||||
Assert.Equal("prod-api", root.GetProperty("host").GetString());
|
||||
Assert.Equal("echo token=***", root.GetProperty("command").GetString());
|
||||
Assert.True(root.GetProperty("success").GetBoolean());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user