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.
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using StellaOps.AirGap.Importer.Validation;
|
|
|
|
namespace StellaOps.AirGap.Importer.Tests;
|
|
|
|
public class RootRotationPolicyTests
|
|
{
|
|
[Fact]
|
|
public void RequiresTwoApprovers()
|
|
{
|
|
var policy = new RootRotationPolicy();
|
|
var result = policy.Validate(new Dictionary<string, byte[]>(), new Dictionary<string, byte[]> { ["k1"] = new byte[] { 1 } }, new[] { "a" });
|
|
Assert.False(result.IsValid);
|
|
Assert.Equal("rotation-dual-approval-required", result.Reason);
|
|
}
|
|
|
|
[Fact]
|
|
public void RejectsNoChange()
|
|
{
|
|
var policy = new RootRotationPolicy();
|
|
var result = policy.Validate(
|
|
new Dictionary<string, byte[]> { ["k1"] = new byte[] { 1 } },
|
|
new Dictionary<string, byte[]> { ["k1"] = new byte[] { 1 } },
|
|
new[] { "a", "b" });
|
|
Assert.False(result.IsValid);
|
|
Assert.Equal("rotation-no-change", result.Reason);
|
|
}
|
|
|
|
[Fact]
|
|
public void AcceptsRotationWithDualApproval()
|
|
{
|
|
var policy = new RootRotationPolicy();
|
|
var result = policy.Validate(
|
|
new Dictionary<string, byte[]> { ["old"] = new byte[] { 1 } },
|
|
new Dictionary<string, byte[]> { ["new"] = new byte[] { 2 } },
|
|
new[] { "a", "b" });
|
|
|
|
Assert.True(result.IsValid);
|
|
Assert.Equal("rotation-approved", result.Reason);
|
|
}
|
|
}
|