59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using ScadaLink.CLI.Commands;
|
|
|
|
namespace ScadaLink.CLI.Tests.Commands;
|
|
|
|
/// <summary>
|
|
/// Tests for the <c>scadalink audit verify-chain</c> subcommand (Audit Log #23 M8-T4).
|
|
/// v1 is a no-op stub: a valid <c>--month</c> prints the documented "not enabled"
|
|
/// message and exits 0; a malformed month or a missing <c>--month</c> exits non-zero.
|
|
/// </summary>
|
|
[Collection("Console")]
|
|
public class AuditVerifyChainCommandTests
|
|
{
|
|
[Fact]
|
|
public void VerifyChain_ValidMonth_ExitsZeroWithDocumentedMessage()
|
|
{
|
|
var root = AuditCommandTestHarness.BuildRoot();
|
|
var (exit, output, _) = AuditCommandTestHarness.Invoke(
|
|
root, "audit", "verify-chain", "--month", "2026-05");
|
|
|
|
Assert.Equal(0, exit);
|
|
Assert.Contains("Hash-chain tamper-evidence is not enabled", output);
|
|
Assert.Contains("Component-AuditLog.md", output);
|
|
}
|
|
|
|
[Fact]
|
|
public void VerifyChain_MalformedMonth_ExitsNonZero()
|
|
{
|
|
var root = AuditCommandTestHarness.BuildRoot();
|
|
var (exit, _, _) = AuditCommandTestHarness.Invoke(
|
|
root, "audit", "verify-chain", "--month", "2026-13");
|
|
|
|
Assert.NotEqual(0, exit);
|
|
}
|
|
|
|
[Fact]
|
|
public void VerifyChain_MissingMonth_ProducesRequiredFlagError()
|
|
{
|
|
var root = AuditCommandTestHarness.BuildRoot();
|
|
var (exit, _, err) = AuditCommandTestHarness.Invoke(root, "audit", "verify-chain");
|
|
|
|
Assert.NotEqual(0, exit);
|
|
Assert.Contains("--month", err);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("2026-05", true)]
|
|
[InlineData("2026-01", true)]
|
|
[InlineData("2026-12", true)]
|
|
[InlineData("2026-13", false)]
|
|
[InlineData("2026-00", false)]
|
|
[InlineData("2026-5", false)]
|
|
[InlineData("not-a-month", false)]
|
|
[InlineData("", false)]
|
|
public void IsValidMonth_ValidatesYyyyMm(string month, bool expected)
|
|
{
|
|
Assert.Equal(expected, AuditVerifyChainHelpers.IsValidMonth(month));
|
|
}
|
|
}
|