Files
git.stella-ops.org/src/Findings/StellaOps.Findings.Ledger.Tests/Exports/ExportPagingTests.cs
master 79b8e53441
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Add new features and tests for AirGap and Time modules
- 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.
2025-11-20 23:29:54 +02:00

52 lines
1.5 KiB
C#

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);
}
}