Merge all changes
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using StellaOps.Scanner.WebService.Contracts;
|
||||
using Xunit;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using StellaOps.Scanner.WebService.Endpoints;
|
||||
using Xunit;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Net;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using StellaOps.Scanner.WebService.Contracts;
|
||||
using Xunit;
|
||||
|
||||
|
||||
using StellaOps.TestKit;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Immutable;
|
||||
using Xunit;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
@@ -51,7 +52,7 @@ public sealed class LinksetResolverTests
|
||||
var result = await resolver.ResolveAsync(new[]
|
||||
{
|
||||
new PolicyPreviewFindingDto { Id = "CVE-2025-0001" }
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
var summary = Assert.Single(result);
|
||||
Assert.Equal("CVE-2025-0001", summary.AdvisoryId);
|
||||
@@ -79,7 +80,7 @@ public sealed class LinksetResolverTests
|
||||
new FakeSurfaceEnvironment(),
|
||||
NullLogger<LinksetResolver>.Instance);
|
||||
|
||||
var result = await resolver.ResolveAsync(Array.Empty<PolicyPreviewFindingDto>(), CancellationToken.None);
|
||||
var result = await resolver.ResolveAsync(Array.Empty<PolicyPreviewFindingDto>(), TestContext.Current.CancellationToken);
|
||||
Assert.Empty(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using Xunit;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -80,7 +80,7 @@ public sealed class ReachabilityDriftEndpointsTests
|
||||
Assert.Equal(DriftDirection.BecameReachable, sinksPayload.Direction);
|
||||
Assert.Equal(0, sinksPayload.Offset);
|
||||
Assert.Equal(10, sinksPayload.Limit);
|
||||
Assert.Equal(1, sinksPayload.Count);
|
||||
Assert.Single(sinksPayload.Sinks);
|
||||
Assert.Single(sinksPayload.Sinks);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
@@ -36,7 +37,7 @@ public sealed class ReportEventDispatcherTests
|
||||
var publisher = new RecordingEventPublisher();
|
||||
var tracker = new RecordingClassificationChangeTracker();
|
||||
var dispatcher = new ReportEventDispatcher(publisher, tracker, Microsoft.Extensions.Options.Options.Create(new ScannerWebServiceOptions()), TimeProvider.System, NullLogger<ReportEventDispatcher>.Instance);
|
||||
var cancellationToken = CancellationToken.None;
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
|
||||
var request = new ReportRequestDto
|
||||
{
|
||||
@@ -177,7 +178,7 @@ public sealed class ReportEventDispatcherTests
|
||||
var publisher = new RecordingEventPublisher();
|
||||
var tracker = new RecordingClassificationChangeTracker();
|
||||
var dispatcher = new ReportEventDispatcher(publisher, tracker, Microsoft.Extensions.Options.Options.Create(new ScannerWebServiceOptions()), TimeProvider.System, NullLogger<ReportEventDispatcher>.Instance);
|
||||
var cancellationToken = CancellationToken.None;
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
|
||||
var request = new ReportRequestDto
|
||||
{
|
||||
@@ -262,7 +263,7 @@ public sealed class ReportEventDispatcherTests
|
||||
ThrowOnTrack = true
|
||||
};
|
||||
var dispatcher = new ReportEventDispatcher(publisher, tracker, Microsoft.Extensions.Options.Options.Create(new ScannerWebServiceOptions()), TimeProvider.System, NullLogger<ReportEventDispatcher>.Instance);
|
||||
var cancellationToken = CancellationToken.None;
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
|
||||
var request = new ReportRequestDto
|
||||
{
|
||||
@@ -333,7 +334,7 @@ public sealed class ReportEventDispatcherTests
|
||||
var publisher = new RecordingEventPublisher();
|
||||
var tracker = new RecordingClassificationChangeTracker();
|
||||
var dispatcher = new ReportEventDispatcher(publisher, tracker, options, TimeProvider.System, NullLogger<ReportEventDispatcher>.Instance);
|
||||
var cancellationToken = CancellationToken.None;
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
|
||||
var request = new ReportRequestDto
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using Xunit;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
@@ -50,7 +51,7 @@ rules:
|
||||
var store = factory.Services.GetRequiredService<PolicySnapshotStore>();
|
||||
await store.SaveAsync(
|
||||
new PolicySnapshotContent(policyYaml, PolicyDocumentFormat.Yaml, "tester", "seed", "initial"),
|
||||
CancellationToken.None);
|
||||
TestContext.Current.CancellationToken);
|
||||
|
||||
using var client = factory.CreateClient();
|
||||
|
||||
@@ -179,7 +180,7 @@ rules:
|
||||
var store = factory.Services.GetRequiredService<PolicySnapshotStore>();
|
||||
var saveResult = await store.SaveAsync(
|
||||
new PolicySnapshotContent(policyYaml, PolicyDocumentFormat.Yaml, "tester", "seed", "initial"),
|
||||
CancellationToken.None);
|
||||
TestContext.Current.CancellationToken);
|
||||
var revisionId = saveResult.Snapshot?.RevisionId ?? string.Empty;
|
||||
|
||||
var recorder = factory.Services.GetRequiredService<RecordingPlatformEventPublisher>();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
@@ -72,7 +72,7 @@ public sealed class RubyPackagesEndpointsTests
|
||||
}
|
||||
};
|
||||
|
||||
await repository.UpsertAsync(document, CancellationToken.None);
|
||||
await repository.UpsertAsync(document, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
using var client = factory.CreateClient();
|
||||
@@ -108,10 +108,10 @@ public sealed class RubyPackagesEndpointsTests
|
||||
Force: false,
|
||||
ClientRequestId: null,
|
||||
Metadata: new Dictionary<string, string>());
|
||||
var result = await coordinator.SubmitAsync(submission, CancellationToken.None);
|
||||
var result = await coordinator.SubmitAsync(submission, TestContext.Current.CancellationToken);
|
||||
scanId = result.Snapshot.ScanId.Value;
|
||||
|
||||
var resolved = await coordinator.TryFindByTargetAsync(reference, digest, CancellationToken.None);
|
||||
var resolved = await coordinator.TryFindByTargetAsync(reference, digest, TestContext.Current.CancellationToken);
|
||||
Assert.NotNull(resolved);
|
||||
|
||||
var repository = scope.ServiceProvider.GetRequiredService<RubyPackageInventoryRepository>();
|
||||
@@ -132,7 +132,7 @@ public sealed class RubyPackagesEndpointsTests
|
||||
}
|
||||
};
|
||||
|
||||
await repository.UpsertAsync(document, CancellationToken.None);
|
||||
await repository.UpsertAsync(document, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
using var client = factory.CreateClient();
|
||||
@@ -166,10 +166,10 @@ public sealed class RubyPackagesEndpointsTests
|
||||
Force: false,
|
||||
ClientRequestId: "cli-test",
|
||||
Metadata: new Dictionary<string, string>());
|
||||
var result = await coordinator.SubmitAsync(submission, CancellationToken.None);
|
||||
var result = await coordinator.SubmitAsync(submission, TestContext.Current.CancellationToken);
|
||||
scanId = result.Snapshot.ScanId.Value;
|
||||
|
||||
var resolved = await coordinator.TryFindByTargetAsync(reference, digest, CancellationToken.None);
|
||||
var resolved = await coordinator.TryFindByTargetAsync(reference, digest, TestContext.Current.CancellationToken);
|
||||
Assert.NotNull(resolved);
|
||||
|
||||
var repository = scope.ServiceProvider.GetRequiredService<RubyPackageInventoryRepository>();
|
||||
@@ -190,7 +190,7 @@ public sealed class RubyPackagesEndpointsTests
|
||||
}
|
||||
};
|
||||
|
||||
await repository.UpsertAsync(document, CancellationToken.None);
|
||||
await repository.UpsertAsync(document, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
using var client = factory.CreateClient();
|
||||
@@ -262,7 +262,7 @@ public sealed class RubyPackagesEndpointsTests
|
||||
Force: false,
|
||||
ClientRequestId: null,
|
||||
Metadata: new Dictionary<string, string>());
|
||||
var result = await coordinator.SubmitAsync(submission, CancellationToken.None);
|
||||
var result = await coordinator.SubmitAsync(submission, TestContext.Current.CancellationToken);
|
||||
canonicalScanId = result.Snapshot.ScanId.Value;
|
||||
|
||||
var store = (RecordingEntryTraceResultStore)scope.ServiceProvider.GetRequiredService<IEntryTraceResultStore>();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System;
|
||||
using Xunit;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@@ -103,7 +104,7 @@ public sealed class RuntimeEndpointsTests
|
||||
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var repository = scope.ServiceProvider.GetRequiredService<RuntimeEventRepository>();
|
||||
var count = await repository.CountAsync(CancellationToken.None);
|
||||
var count = await repository.CountAsync(TestContext.Current.CancellationToken);
|
||||
Assert.Equal(0, count);
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ public sealed class RuntimeEndpointsTests
|
||||
var links = scope.ServiceProvider.GetRequiredService<LinkRepository>();
|
||||
var policyStore = scope.ServiceProvider.GetRequiredService<PolicySnapshotStore>();
|
||||
var runtimeRepository = scope.ServiceProvider.GetRequiredService<RuntimeEventRepository>();
|
||||
await runtimeRepository.TruncateAsync(CancellationToken.None);
|
||||
await runtimeRepository.TruncateAsync(TestContext.Current.CancellationToken);
|
||||
|
||||
const string policyYaml = """
|
||||
version: "1.0"
|
||||
@@ -137,10 +138,10 @@ rules:
|
||||
""";
|
||||
var saveResult = await policyStore.SaveAsync(
|
||||
new PolicySnapshotContent(policyYaml, PolicyDocumentFormat.Yaml, "tester", "tests", "seed"),
|
||||
CancellationToken.None);
|
||||
TestContext.Current.CancellationToken);
|
||||
Assert.True(saveResult.Success);
|
||||
|
||||
var snapshot = await policyStore.GetLatestAsync(CancellationToken.None);
|
||||
var snapshot = await policyStore.GetLatestAsync(TestContext.Current.CancellationToken);
|
||||
Assert.NotNull(snapshot);
|
||||
|
||||
var sbomArtifactId = CatalogIdFactory.CreateArtifactId(ArtifactDocumentType.ImageBom, "sha256:sbomdigest");
|
||||
@@ -154,7 +155,7 @@ rules:
|
||||
MediaType = "application/json",
|
||||
BytesSha256 = "sha256:sbomdigest",
|
||||
RefCount = 1
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
await artifacts.UpsertAsync(new ArtifactDocument
|
||||
{
|
||||
@@ -165,7 +166,7 @@ rules:
|
||||
BytesSha256 = "sha256:attdigest",
|
||||
RefCount = 1,
|
||||
Rekor = new RekorReference { Uuid = "rekor-uuid", Url = "https://rekor.example/uuid/rekor-uuid", Index = 7 }
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
@@ -174,7 +175,7 @@ rules:
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = sbomArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
@@ -183,7 +184,7 @@ rules:
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = attestationArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
var ingestRequest = new RuntimeEventsIngestRequestDto
|
||||
@@ -257,10 +258,10 @@ rules: []
|
||||
""";
|
||||
await policyStore.SaveAsync(
|
||||
new PolicySnapshotContent(policyYaml, PolicyDocumentFormat.Yaml, "tester", "tests", "baseline"),
|
||||
CancellationToken.None);
|
||||
TestContext.Current.CancellationToken);
|
||||
|
||||
// Intentionally skip artifacts/links to simulate missing metadata.
|
||||
await runtimeRepository.TruncateAsync(CancellationToken.None);
|
||||
await runtimeRepository.TruncateAsync(TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
var response = await client.PostAsJsonAsync("/api/v1/policy/runtime", new RuntimePolicyRequestDto
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System;
|
||||
using Xunit;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
@@ -128,7 +129,7 @@ public sealed class RuntimeReconciliationTests
|
||||
MediaType = "application/json",
|
||||
BytesSha256 = sbomHash,
|
||||
RefCount = 1
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
@@ -137,7 +138,7 @@ public sealed class RuntimeReconciliationTests
|
||||
FromDigest = TestImageDigest,
|
||||
ArtifactId = sbomArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
// Create SBOM content with matching hash
|
||||
@@ -219,7 +220,7 @@ public sealed class RuntimeReconciliationTests
|
||||
MediaType = "application/json",
|
||||
BytesSha256 = sbomHash,
|
||||
RefCount = 1
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
@@ -228,7 +229,7 @@ public sealed class RuntimeReconciliationTests
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = sbomArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
// Create SBOM with paths but different hashes (path matching)
|
||||
@@ -305,7 +306,7 @@ public sealed class RuntimeReconciliationTests
|
||||
MediaType = "application/json",
|
||||
BytesSha256 = sbomHash,
|
||||
RefCount = 1
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
@@ -314,7 +315,7 @@ public sealed class RuntimeReconciliationTests
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = sbomArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
var sbom = CreateSbomWithComponents(new[]
|
||||
@@ -433,7 +434,7 @@ public sealed class RuntimeReconciliationTests
|
||||
MediaType = "application/json",
|
||||
BytesSha256 = sbomHash,
|
||||
RefCount = 1
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
|
||||
await links.UpsertAsync(new LinkDocument
|
||||
{
|
||||
@@ -442,7 +443,7 @@ public sealed class RuntimeReconciliationTests
|
||||
FromDigest = imageDigest,
|
||||
ArtifactId = sbomArtifactId,
|
||||
CreatedAtUtc = DateTime.UtcNow
|
||||
}, CancellationToken.None);
|
||||
}, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
// SBOM has 2 components
|
||||
|
||||
Reference in New Issue
Block a user