using Fleet.Core; using MoShiro.Backend.Application; using MoShiro.Protocol; namespace MoShiro.Backend.Tests; public sealed class NodeRuntimeLogTests { [Fact] public void DiagnosticFieldsSurviveUpload_WhileSecretsAndOversizedFieldsRemainBounded() { var service = new NodeRuntimeLogService(TimeProvider.System); var node = new NodeId("agt_diagnostics"); Dictionary fields = Enumerable.Range(0, 18).ToDictionary(i => "field_" + i, _ => "value"); fields.Add("api_token", "must-not-survive"); fields.Add("detail", new string('x', 500)); fields.Add("overflow", "discard"); service.Append(node, [new NodeLogRecord(TimeProvider.System.GetUtcNow().ToUnixTimeMilliseconds(), "warn", "handshake failed", fields)], 0); NodeRuntimeLog entry = Assert.Single(service.List(node, 10).Items); Assert.Equal(20, entry.Fields.Count); Assert.Equal("value", entry.Fields["field_17"]); Assert.Equal("[redacted]", entry.Fields["api_token"]); Assert.Equal(128, entry.Fields["detail"].Length); Assert.False(entry.Fields.ContainsKey("overflow")); } }