Add tests for SBOM generation determinism across multiple formats
- Created `StellaOps.TestKit.Tests` project for unit tests related to determinism. - Implemented `DeterminismManifestTests` to validate deterministic output for canonical bytes and strings, file read/write operations, and error handling for invalid schema versions. - Added `SbomDeterminismTests` to ensure identical inputs produce consistent SBOMs across SPDX 3.0.1 and CycloneDX 1.6/1.7 formats, including parallel execution tests. - Updated project references in `StellaOps.Integration.Determinism` to include the new determinism testing library.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using StellaOps.AirGap.Importer.Reconciliation;
|
||||
|
||||
namespace StellaOps.AirGap.Importer.Tests.Reconciliation;
|
||||
|
||||
public sealed class ArtifactIndexDigestNormalizationTests
|
||||
{
|
||||
[Fact]
|
||||
public void NormalizeDigest_AcceptsBareHex()
|
||||
{
|
||||
var digest = new string('A', 64);
|
||||
|
||||
var normalized = ArtifactIndex.NormalizeDigest(digest);
|
||||
|
||||
Assert.Equal("sha256:" + new string('a', 64), normalized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NormalizeDigest_AcceptsPrefixedSha256()
|
||||
{
|
||||
var digest = "SHA256:" + new string('F', 64);
|
||||
|
||||
var normalized = ArtifactIndex.NormalizeDigest(digest);
|
||||
|
||||
Assert.Equal("sha256:" + new string('f', 64), normalized);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NormalizeDigest_RejectsUnsupportedAlgorithm()
|
||||
{
|
||||
var digest = "sha512:" + new string('a', 128);
|
||||
|
||||
Assert.Throws<FormatException>(() => ArtifactIndex.NormalizeDigest(digest));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NormalizeDigest_RejectsNonHex()
|
||||
{
|
||||
var digest = "sha256:" + new string('g', 64);
|
||||
|
||||
Assert.Throws<FormatException>(() => ArtifactIndex.NormalizeDigest(digest));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user