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.Contracts;
|
|
using StellaOps.AirGap.Importer.Planning;
|
|
|
|
namespace StellaOps.AirGap.Importer.Tests;
|
|
|
|
public class BundleImportPlannerTests
|
|
{
|
|
[Fact]
|
|
public void ReturnsFailureWhenBundlePathMissing()
|
|
{
|
|
var planner = new BundleImportPlanner();
|
|
var result = planner.CreatePlan(string.Empty, TrustRootConfig.Empty("/tmp"));
|
|
|
|
Assert.False(result.InitialState.IsValid);
|
|
Assert.Equal("bundle-path-required", result.InitialState.Reason);
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnsFailureWhenTrustRootsMissing()
|
|
{
|
|
var planner = new BundleImportPlanner();
|
|
var result = planner.CreatePlan("bundle.tar", TrustRootConfig.Empty("/tmp"));
|
|
|
|
Assert.False(result.InitialState.IsValid);
|
|
Assert.Equal("trust-roots-required", result.InitialState.Reason);
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnsDefaultPlanWhenInputsProvided()
|
|
{
|
|
var planner = new BundleImportPlanner();
|
|
var trust = new TrustRootConfig("/tmp/trust.json", new[] { "abc" }, new[] { "ed25519" }, null, null, new Dictionary<string, byte[]>());
|
|
|
|
var result = planner.CreatePlan("bundle.tar", trust);
|
|
|
|
Assert.True(result.InitialState.IsValid);
|
|
Assert.Contains("verify-dsse-signature", result.Steps);
|
|
Assert.Equal("bundle.tar", result.Inputs["bundlePath"]);
|
|
}
|
|
}
|