fix(configdb): opt-in config-audit retention purge + after-state size cap (review 2026-10-21 08/G1)
This commit is contained in:
@@ -212,4 +212,20 @@ public class AuditServiceTests : IDisposable
|
||||
Assert.Contains("node", audit.AfterStateJson);
|
||||
Assert.Single(await _context.Templates.Where(t => t.Name == "CyclicAuditTemplate").ToListAsync());
|
||||
}
|
||||
|
||||
/// <summary>An oversized after-state is replaced by a small valid-JSON truncation marker (review 08/G1).</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task LogAsync_OversizedAfterState_IsTruncatedToMarker()
|
||||
{
|
||||
await _auditService.LogAsync("admin", "Update", "Template", "1", "Big",
|
||||
new { Code = new string('x', AuditService.MaxAfterStateChars + 10) });
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var json = _context.AuditLogEntries.Single().AfterStateJson!;
|
||||
Assert.True(json.Length < 16 * 1024);
|
||||
using var doc = JsonDocument.Parse(json);
|
||||
Assert.True(doc.RootElement.GetProperty("AuditTruncated").GetBoolean());
|
||||
Assert.True(doc.RootElement.GetProperty("OriginalLength").GetInt32() > AuditService.MaxAfterStateChars);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user