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.
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using StellaOps.AirGap.Time.Models;
|
|
using StellaOps.AirGap.Time.Parsing;
|
|
|
|
namespace StellaOps.AirGap.Time.Tests;
|
|
|
|
public class TimeTokenParserTests
|
|
{
|
|
[Fact]
|
|
public void EmptyTokenFails()
|
|
{
|
|
var parser = new TimeTokenParser();
|
|
var result = parser.TryParse(Array.Empty<byte>(), TimeTokenFormat.Roughtime, out var anchor);
|
|
|
|
Assert.False(result.IsValid);
|
|
Assert.Equal("token-empty", result.Reason);
|
|
Assert.Equal(TimeAnchor.Unknown, anchor);
|
|
}
|
|
|
|
[Fact]
|
|
public void RoughtimeTokenProducesDigest()
|
|
{
|
|
var parser = new TimeTokenParser();
|
|
var token = new byte[] { 0x01, 0x02, 0x03 };
|
|
|
|
var result = parser.TryParse(token, TimeTokenFormat.Roughtime, out var anchor);
|
|
|
|
Assert.True(result.IsValid);
|
|
Assert.Equal("Roughtime", anchor.Format);
|
|
Assert.Equal("roughtime-token", anchor.Source);
|
|
Assert.Equal("structure-stubbed", result.Reason);
|
|
Assert.Matches("^[0-9a-f]{64}$", anchor.TokenDigest);
|
|
Assert.NotEqual(DateTimeOffset.UnixEpoch, anchor.AnchorTime); // deterministic derivation
|
|
}
|
|
}
|