Add new features and tests for AirGap and Time modules
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Introduced `SbomService` tasks documentation. - Updated `StellaOps.sln` to include new projects: `StellaOps.AirGap.Time` and `StellaOps.AirGap.Importer`. - Added unit tests for `BundleImportPlanner`, `DsseVerifier`, `ImportValidator`, and other components in the `StellaOps.AirGap.Importer.Tests` namespace. - Implemented `InMemoryBundleRepositories` for testing bundle catalog and item repositories. - Created `MerkleRootCalculator`, `RootRotationPolicy`, and `TufMetadataValidator` tests. - Developed `StalenessCalculator` and `TimeAnchorLoader` tests in the `StellaOps.AirGap.Time.Tests` namespace. - Added `fetch-sbomservice-deps.sh` script for offline dependency fetching.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
using StellaOps.Findings.Ledger.Infrastructure.Exports;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Findings.Ledger.Tests.Exports;
|
||||
|
||||
public class ExportPagingTests
|
||||
{
|
||||
[Fact]
|
||||
public void ComputeFiltersHash_IsDeterministic()
|
||||
{
|
||||
var left = new Dictionary<string, string?>
|
||||
{
|
||||
["shape"] = "canonical",
|
||||
["since_sequence"] = "10",
|
||||
["until_sequence"] = "20"
|
||||
};
|
||||
|
||||
var right = new Dictionary<string, string?>
|
||||
{
|
||||
["until_sequence"] = "20",
|
||||
["shape"] = "canonical",
|
||||
["since_sequence"] = "10"
|
||||
};
|
||||
|
||||
var leftHash = ExportPaging.ComputeFiltersHash(left);
|
||||
var rightHash = ExportPaging.ComputeFiltersHash(right);
|
||||
|
||||
Assert.Equal(leftHash, rightHash);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PageToken_RoundTrips()
|
||||
{
|
||||
var key = new ExportPaging.ExportPageKey(5, "v1", "abc123");
|
||||
var filtersHash = ExportPaging.ComputeFiltersHash(new Dictionary<string, string?>
|
||||
{
|
||||
["shape"] = "canonical"
|
||||
});
|
||||
|
||||
var token = ExportPaging.CreatePageToken(key, filtersHash);
|
||||
|
||||
var parsed = ExportPaging.TryParsePageToken(token, filtersHash, out var recovered, out var error);
|
||||
|
||||
Assert.True(parsed);
|
||||
Assert.Null(error);
|
||||
Assert.NotNull(recovered);
|
||||
Assert.Equal(key.SequenceNumber, recovered!.SequenceNumber);
|
||||
Assert.Equal(key.PolicyVersion, recovered.PolicyVersion);
|
||||
Assert.Equal(key.CycleHash, recovered.CycleHash);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user