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:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using StellaOps.Concelier.Connector.Common.Cursors;
|
||||
using StellaOps.Concelier.Documents;
|
||||
|
||||
namespace StellaOps.Concelier.Connector.Ghsa.Internal;
|
||||
@@ -36,15 +37,8 @@ internal sealed record GhsaCursor(
|
||||
document["lastUpdatedExclusive"] = LastUpdatedExclusive.Value.UtcDateTime;
|
||||
}
|
||||
|
||||
if (CurrentWindowStart.HasValue)
|
||||
{
|
||||
document["currentWindowStart"] = CurrentWindowStart.Value.UtcDateTime;
|
||||
}
|
||||
|
||||
if (CurrentWindowEnd.HasValue)
|
||||
{
|
||||
document["currentWindowEnd"] = CurrentWindowEnd.Value.UtcDateTime;
|
||||
}
|
||||
new TimeWindowCursorState(CurrentWindowStart, CurrentWindowEnd)
|
||||
.WriteTo(document, startField: "currentWindowStart", endField: "currentWindowEnd");
|
||||
|
||||
return document;
|
||||
}
|
||||
@@ -59,12 +53,7 @@ internal sealed record GhsaCursor(
|
||||
var lastUpdatedExclusive = document.TryGetValue("lastUpdatedExclusive", out var lastUpdated)
|
||||
? ParseDate(lastUpdated)
|
||||
: null;
|
||||
var windowStart = document.TryGetValue("currentWindowStart", out var windowStartValue)
|
||||
? ParseDate(windowStartValue)
|
||||
: null;
|
||||
var windowEnd = document.TryGetValue("currentWindowEnd", out var windowEndValue)
|
||||
? ParseDate(windowEndValue)
|
||||
: null;
|
||||
var window = TimeWindowCursorState.FromDocumentObject(document, startField: "currentWindowStart", endField: "currentWindowEnd");
|
||||
var nextPage = document.TryGetValue("nextPage", out var nextPageValue) && nextPageValue.IsInt32
|
||||
? Math.Max(1, nextPageValue.AsInt32)
|
||||
: 1;
|
||||
@@ -74,8 +63,8 @@ internal sealed record GhsaCursor(
|
||||
|
||||
return new GhsaCursor(
|
||||
lastUpdatedExclusive,
|
||||
windowStart,
|
||||
windowEnd,
|
||||
window.LastWindowStart,
|
||||
window.LastWindowEnd,
|
||||
nextPage,
|
||||
pendingDocuments,
|
||||
pendingMappings);
|
||||
|
||||
Reference in New Issue
Block a user