up
Some checks failed
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Manifest Integrity / Validate Schema Integrity (push) Has been cancelled
Manifest Integrity / Validate Contract Documents (push) Has been cancelled
Manifest Integrity / Validate Pack Fixtures (push) Has been cancelled
Manifest Integrity / Audit SHA256SUMS Files (push) Has been cancelled
Manifest Integrity / Verify Merkle Roots (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Some checks failed
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
Manifest Integrity / Validate Schema Integrity (push) Has been cancelled
Manifest Integrity / Validate Contract Documents (push) Has been cancelled
Manifest Integrity / Validate Pack Fixtures (push) Has been cancelled
Manifest Integrity / Audit SHA256SUMS Files (push) Has been cancelled
Manifest Integrity / Verify Merkle Roots (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
This commit is contained in:
@@ -6,10 +6,9 @@ using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MongoDB.Driver;
|
||||
using StellaOps.Policy;
|
||||
using StellaOps.Scanner.Storage.Catalog;
|
||||
using StellaOps.Scanner.Storage.Mongo;
|
||||
using StellaOps.Scanner.Storage.Repositories;
|
||||
using StellaOps.Scanner.WebService.Contracts;
|
||||
using StellaOps.Zastava.Core.Contracts;
|
||||
|
||||
@@ -42,8 +41,8 @@ public sealed class RuntimeEndpointsTests
|
||||
Assert.Equal(0, payload.Duplicates);
|
||||
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var collections = scope.ServiceProvider.GetRequiredService<MongoCollectionProvider>();
|
||||
var stored = await collections.RuntimeEvents.Find(FilterDefinition<RuntimeEventDocument>.Empty).ToListAsync();
|
||||
var repository = scope.ServiceProvider.GetRequiredService<RuntimeEventRepository>();
|
||||
var stored = await repository.ListAsync(CancellationToken.None);
|
||||
Assert.Equal(2, stored.Count);
|
||||
Assert.Contains(stored, doc => doc.EventId == "evt-001");
|
||||
Assert.All(stored, doc =>
|
||||
@@ -98,8 +97,8 @@ public sealed class RuntimeEndpointsTests
|
||||
Assert.NotNull(response.Headers.RetryAfter);
|
||||
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var collections = scope.ServiceProvider.GetRequiredService<MongoCollectionProvider>();
|
||||
var count = await collections.RuntimeEvents.CountDocumentsAsync(FilterDefinition<RuntimeEventDocument>.Empty);
|
||||
var repository = scope.ServiceProvider.GetRequiredService<RuntimeEventRepository>();
|
||||
var count = await repository.CountAsync(CancellationToken.None);
|
||||
Assert.Equal(0, count);
|
||||
}
|
||||
|
||||
@@ -117,8 +116,11 @@ public sealed class RuntimeEndpointsTests
|
||||
|
||||
using (var scope = factory.Services.CreateScope())
|
||||
{
|
||||
var collections = scope.ServiceProvider.GetRequiredService<MongoCollectionProvider>();
|
||||
var artifacts = scope.ServiceProvider.GetRequiredService<ArtifactRepository>();
|
||||
var links = scope.ServiceProvider.GetRequiredService<LinkRepository>();
|
||||
var policyStore = scope.ServiceProvider.GetRequiredService<PolicySnapshotStore>();
|
||||
var runtimeRepository = scope.ServiceProvider.GetRequiredService<RuntimeEventRepository>();
|
||||
await runtimeRepository.TruncateAsync(CancellationToken.None);
|
||||
|
||||
const string policyYaml = """
|
||||
version: "1.0"
|
||||
@@ -138,52 +140,44 @@ rules:
|
||||
var sbomArtifactId = CatalogIdFactory.CreateArtifactId(ArtifactDocumentType.ImageBom, "sha256:sbomdigest");
|
||||
var attestationArtifactId = CatalogIdFactory.CreateArtifactId(ArtifactDocumentType.Attestation, "sha256:attdigest");
|
||||
|
||||
await collections.Artifacts.InsertManyAsync(new[]
|
||||
await artifacts.UpsertAsync(new ArtifactDocument
|
||||
{
|
||||
new ArtifactDocument
|
||||
{
|
||||
Id = sbomArtifactId,
|
||||
Type = ArtifactDocumentType.ImageBom,
|
||||
Format = ArtifactDocumentFormat.CycloneDxJson,
|
||||
MediaType = "application/json",
|
||||
BytesSha256 = "sha256:sbomdigest",
|
||||
RefCount = 1,
|
||||
CreatedAtUtc = DateTime.UtcNow,
|
||||
UpdatedAtUtc = DateTime.UtcNow
|
||||
},
|
||||
new ArtifactDocument
|
||||
{
|
||||
Id = attestationArtifactId,
|
||||
Type = ArtifactDocumentType.Attestation,
|
||||
Format = ArtifactDocumentFormat.DsseJson,
|
||||
MediaType = "application/vnd.dsse.envelope+json",
|
||||
BytesSha256 = "sha256:attdigest",
|
||||
RefCount = 1,
|
||||
CreatedAtUtc = DateTime.UtcNow,
|
||||
UpdatedAtUtc = DateTime.UtcNow,
|
||||
Rekor = new RekorReference { Uuid = "rekor-uuid", Url = "https://rekor.example/uuid/rekor-uuid", Index = 7 }
|
||||
}
|
||||
});
|
||||
Id = sbomArtifactId,
|
||||
Type = ArtifactDocumentType.ImageBom,
|
||||
Format = ArtifactDocumentFormat.CycloneDxJson,
|
||||
MediaType = "application/json",
|
||||
BytesSha256 = "sha256:sbomdigest",
|
||||
RefCount = 1
|
||||
}, CancellationToken.None);
|
||||
|
||||
await collections.Links.InsertManyAsync(new[]
|
||||
await artifacts.UpsertAsync(new ArtifactDocument
|
||||
{
|
||||
new LinkDocument
|
||||
{
|
||||
Id = Guid.NewGuid().ToString("N"),
|
||||
FromType = LinkSourceType.Image,
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = sbomArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
},
|
||||
new LinkDocument
|
||||
{
|
||||
Id = Guid.NewGuid().ToString("N"),
|
||||
FromType = LinkSourceType.Image,
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = attestationArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}
|
||||
});
|
||||
Id = attestationArtifactId,
|
||||
Type = ArtifactDocumentType.Attestation,
|
||||
Format = ArtifactDocumentFormat.DsseJson,
|
||||
MediaType = "application/vnd.dsse.envelope+json",
|
||||
BytesSha256 = "sha256:attdigest",
|
||||
RefCount = 1,
|
||||
Rekor = new RekorReference { Uuid = "rekor-uuid", Url = "https://rekor.example/uuid/rekor-uuid", Index = 7 }
|
||||
}, CancellationToken.None);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
Id = Guid.NewGuid().ToString("N"),
|
||||
FromType = LinkSourceType.Image,
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = sbomArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
Id = Guid.NewGuid().ToString("N"),
|
||||
FromType = LinkSourceType.Image,
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = attestationArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
}
|
||||
|
||||
var ingestRequest = new RuntimeEventsIngestRequestDto
|
||||
@@ -247,7 +241,7 @@ rules:
|
||||
|
||||
using (var scope = factory.Services.CreateScope())
|
||||
{
|
||||
var collections = scope.ServiceProvider.GetRequiredService<MongoCollectionProvider>();
|
||||
var runtimeRepository = scope.ServiceProvider.GetRequiredService<RuntimeEventRepository>();
|
||||
var policyStore = scope.ServiceProvider.GetRequiredService<PolicySnapshotStore>();
|
||||
|
||||
const string policyYaml = """
|
||||
@@ -259,7 +253,7 @@ rules: []
|
||||
CancellationToken.None);
|
||||
|
||||
// Intentionally skip artifacts/links to simulate missing metadata.
|
||||
await collections.RuntimeEvents.DeleteManyAsync(Builders<RuntimeEventDocument>.Filter.Empty);
|
||||
await runtimeRepository.TruncateAsync(CancellationToken.None);
|
||||
}
|
||||
|
||||
var response = await client.PostAsJsonAsync("/api/v1/policy/runtime", new RuntimePolicyRequestDto
|
||||
|
||||
Reference in New Issue
Block a user