513fa1aa16
Comment/XML-doc changes only: - add summaries to ~10k test methods, fixtures, fakes and helpers (+ <param> on theories, <returns> on async Task methods, <inheritdoc/> on interface implementations the checker can resolve) - strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N, #NN, Component-0NN) from comments, keeping the explanatory text; reword false positives in comments only - real docs on fakes implementing BCL/library interfaces (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime) - reword the last 5 src/ false positives (CWE-1236, failures-1, year-0001, M365) Only non-comment edits: four one-line nested classes split across lines so members can carry docs. Build 0 errors / 0 warnings.
65 lines
2.5 KiB
C#
65 lines
2.5 KiB
C#
using ZB.MOM.WW.ScadaBridge.CLI.Commands;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.CLI.Tests.Commands;
|
|
|
|
/// <summary>
|
|
/// Tests for the <c>scadabridge audit verify-chain</c> subcommand.
|
|
/// 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
|
|
{
|
|
/// <summary>Verifies that verifying the chain for a valid month exits with zero and prints the documented message.</summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>Verifies that a malformed month value makes the command exit with a non-zero code.</summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>Verifies that omitting the month option produces the required-option error.</summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>Verifies that month validation accepts only values in <c>yyyy-MM</c> format.</summary>
|
|
/// <param name="month">The month string to validate.</param>
|
|
/// <param name="expected">Whether the month is expected to be valid.</param>
|
|
[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));
|
|
}
|
|
}
|