using ScadaLink.AuditLog.Configuration; namespace ScadaLink.AuditLog.Tests.Configuration; /// /// Task 1 of docs/plans/2026-05-23-inbound-api-full-response-audit.md: /// pins the default to 1 MiB and /// the validator bounds to [8 KiB, 16 MiB]. The inbound channel needs a /// much larger ceiling than the 8 KiB / 64 KiB default/error caps that other /// channels use, but unbounded would let any caller flood the central /// AuditLog table with arbitrarily large bodies — hence the upper bound. /// Companion to which covers the existing /// cap-bytes + retention invariants. /// public class AuditLogOptionsValidatorTests { [Fact] public void Validate_InboundMaxBytes_DefaultOptions_IsOneMebibyte() { // The doc'd default per docs/plans/2026-05-23-inbound-api-full-response-audit-design.md // is 1 048 576 bytes (1 MiB). Pin it so a config drift is a test failure, // not a silent operational surprise. var opts = new AuditLogOptions(); Assert.Equal(1_048_576, opts.InboundMaxBytes); } [Theory] [InlineData(8_192)] // documented min [InlineData(1_048_576)] // default [InlineData(16_777_216)] // documented max public void Validate_InboundMaxBytes_InRange_Passes(int value) { var validator = new AuditLogOptionsValidator(); var opts = new AuditLogOptions { InboundMaxBytes = value }; Assert.True(validator.Validate(null, opts).Succeeded); } [Theory] [InlineData(0)] [InlineData(8_191)] [InlineData(16_777_217)] [InlineData(int.MaxValue)] public void Validate_InboundMaxBytes_OutOfRange_Fails(int value) { var validator = new AuditLogOptionsValidator(); var opts = new AuditLogOptions { InboundMaxBytes = value }; var result = validator.Validate(null, opts); Assert.False(result.Succeeded); Assert.Contains( result.Failures!, f => f.Contains(nameof(AuditLogOptions.InboundMaxBytes), StringComparison.Ordinal)); } }