stabilizaiton work - projects rework for maintenanceability and ui livening
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using StellaOps.Evidence.Models;
|
||||
using StellaOps.Replay.Engine;
|
||||
using StellaOps.Replay.Models;
|
||||
using StellaOps.Testing.Manifests.Models;
|
||||
using System.Collections.Immutable;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StellaOps.Replay.Tests;
|
||||
|
||||
internal sealed class FakeFeedLoader : IFeedLoader
|
||||
{
|
||||
public Task<FeedSnapshot> LoadByDigestAsync(string digest, CancellationToken ct = default)
|
||||
=> Task.FromResult(new FeedSnapshot("nvd", "v1", digest, ReplayEngineTestFixtures.FixedFeedSnapshotAt));
|
||||
}
|
||||
|
||||
internal sealed class FakePolicyLoader : IPolicyLoader
|
||||
{
|
||||
public Task<PolicySnapshot> LoadByDigestAsync(string digest, CancellationToken ct = default)
|
||||
=> Task.FromResult(new PolicySnapshot("1.0.0", digest, ImmutableArray<string>.Empty));
|
||||
}
|
||||
|
||||
internal sealed class FakeScannerFactory : IScannerFactory
|
||||
{
|
||||
public IScanner Create(ScannerOptions options) => new FakeScanner(options);
|
||||
}
|
||||
|
||||
internal sealed class FakeScanner : IScanner
|
||||
{
|
||||
private readonly ScannerOptions _options;
|
||||
public FakeScanner(ScannerOptions options) => _options = options;
|
||||
|
||||
public Task<ScanResult> ScanAsync(ImmutableArray<ArtifactDigest> artifacts, CancellationToken ct = default)
|
||||
{
|
||||
var verdict = new
|
||||
{
|
||||
feedVersion = _options.FeedSnapshot.Version,
|
||||
policyDigest = _options.PolicySnapshot.LatticeRulesDigest
|
||||
};
|
||||
var evidence = new EvidenceIndex
|
||||
{
|
||||
IndexId = ReplayEngineTestFixtures.EvidenceIndexId,
|
||||
SchemaVersion = "1.0.0",
|
||||
Verdict = new VerdictReference("v1", new string('d', 64), VerdictOutcome.Pass, null),
|
||||
Sboms = ImmutableArray<SbomEvidence>.Empty,
|
||||
Attestations = ImmutableArray<AttestationEvidence>.Empty,
|
||||
ToolChain = new ToolChainEvidence("1", "1", "1", "1", "1", ImmutableDictionary<string, string>.Empty),
|
||||
RunManifestDigest = new string('e', 64),
|
||||
CreatedAt = ReplayEngineTestFixtures.FixedTimestamp
|
||||
};
|
||||
return Task.FromResult(new ScanResult(verdict, evidence, 10));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user