Merge branch 'main' of https://git.stella-ops.org/stella-ops.org/git.stella-ops.org
This commit is contained in:
@@ -35,6 +35,7 @@ public sealed class S3ArtifactClientTests
|
||||
|
||||
var client = new S3ArtifactClient(mock.Object, Microsoft.Extensions.Logging.Abstractions.NullLogger<S3ArtifactClient>.Instance);
|
||||
using var stream = new MemoryStream(new byte[] { 1, 2, 3 });
|
||||
using StellaOps.TestKit;
|
||||
await client.PutObjectAsync("bucket", "key", stream, new Dictionary<string, string> { ["a"] = "b" }, default);
|
||||
|
||||
mock.Verify(x => x.PutObjectAsync(It.Is<PutObjectRequest>(r => r.Metadata["a"] == "b"), default), Times.Once);
|
||||
|
||||
@@ -92,6 +92,7 @@ public sealed class VexPolicyBinderTests
|
||||
public void Bind_Stream_SupportsEncoding()
|
||||
{
|
||||
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(JsonPolicy));
|
||||
using StellaOps.TestKit;
|
||||
var result = VexPolicyBinder.Bind(stream, VexPolicyDocumentFormat.Json);
|
||||
|
||||
Assert.True(result.Success);
|
||||
|
||||
@@ -79,6 +79,7 @@ public class VexPolicyDiagnosticsTests
|
||||
public void PolicyProvider_ComputesRevisionAndDigest_AndEmitsTelemetry()
|
||||
{
|
||||
using var listener = new MeterListener();
|
||||
using StellaOps.TestKit;
|
||||
var reloadMeasurements = 0;
|
||||
string? lastRevision = null;
|
||||
listener.InstrumentPublished += (instrument, _) =>
|
||||
|
||||
@@ -289,6 +289,7 @@ public sealed class MirrorBundlePublisherTests
|
||||
private static string ComputeSha256(byte[] bytes)
|
||||
{
|
||||
using var sha = SHA256.Create();
|
||||
using StellaOps.TestKit;
|
||||
var digest = sha.ComputeHash(bytes);
|
||||
return "sha256:" + Convert.ToHexString(digest).ToLowerInvariant();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public sealed class OfflineBundleArtifactStoreTests
|
||||
Assert.True(fs.FileExists(manifestPath));
|
||||
await using var manifestStream = fs.File.OpenRead(manifestPath);
|
||||
using var document = await JsonDocument.ParseAsync(manifestStream);
|
||||
using StellaOps.TestKit;
|
||||
var artifacts = document.RootElement.GetProperty("artifacts");
|
||||
Assert.True(artifacts.GetArrayLength() >= 1);
|
||||
var first = artifacts.EnumerateArray().First();
|
||||
|
||||
@@ -71,6 +71,7 @@ public sealed class S3ArtifactStoreTests
|
||||
public Task PutObjectAsync(string bucketName, string key, Stream content, IDictionary<string, string> metadata, CancellationToken cancellationToken)
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using StellaOps.TestKit;
|
||||
content.CopyTo(ms);
|
||||
var bytes = ms.ToArray();
|
||||
PutCalls.GetOrAdd(bucketName, _ => new List<S3Entry>()).Add(new S3Entry(key, bytes, new Dictionary<string, string>(metadata)));
|
||||
|
||||
@@ -60,6 +60,7 @@ public sealed class CsafExporterTests
|
||||
|
||||
stream.Position = 0;
|
||||
using var document = JsonDocument.Parse(stream);
|
||||
using StellaOps.TestKit;
|
||||
var root = document.RootElement;
|
||||
|
||||
root.GetProperty("document").GetProperty("tracking").GetProperty("id").GetString()!.Should().StartWith("stellaops:csaf");
|
||||
|
||||
@@ -44,6 +44,7 @@ public sealed class CycloneDxExporterTests
|
||||
|
||||
stream.Position = 0;
|
||||
using var document = JsonDocument.Parse(stream);
|
||||
using StellaOps.TestKit;
|
||||
var root = document.RootElement;
|
||||
|
||||
root.GetProperty("bomFormat").GetString().Should().Be("CycloneDX");
|
||||
|
||||
@@ -38,6 +38,7 @@ public sealed class OpenVexExporterTests
|
||||
|
||||
stream.Position = 0;
|
||||
using var document = JsonDocument.Parse(stream);
|
||||
using StellaOps.TestKit;
|
||||
var root = document.RootElement;
|
||||
root.GetProperty("document").GetProperty("author").GetString().Should().Be("StellaOps Excititor");
|
||||
root.GetProperty("statements").GetArrayLength().Should().Be(1);
|
||||
|
||||
@@ -50,6 +50,7 @@ public sealed class PostgresAppendOnlyLinksetStoreTests : IAsyncLifetime
|
||||
if (stream is not null)
|
||||
{
|
||||
using var reader = new StreamReader(stream);
|
||||
using StellaOps.TestKit;
|
||||
var sql = await reader.ReadToEndAsync();
|
||||
await _fixture.Fixture.ExecuteSqlAsync(sql);
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ public class AirgapImportEndpointTests
|
||||
});
|
||||
|
||||
using var client = factory.CreateClient(new WebApplicationFactoryClientOptions { AllowAutoRedirect = false });
|
||||
using StellaOps.TestKit;
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "vex.admin");
|
||||
|
||||
var request = new AirgapImportRequest
|
||||
|
||||
@@ -64,6 +64,7 @@ public class AirgapSignerTrustServiceTests
|
||||
public void Validate_Allows_On_Metadata_Match()
|
||||
{
|
||||
using var temp = ConnectorMetadataTempFile();
|
||||
using StellaOps.TestKit;
|
||||
Environment.SetEnvironmentVariable("STELLAOPS_CONNECTOR_SIGNER_METADATA_PATH", temp.Path);
|
||||
var service = new AirgapSignerTrustService(NullLogger<AirgapSignerTrustService>.Instance);
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ public sealed class AttestationVerifyEndpointTests
|
||||
{
|
||||
using var factory = new TestWebApplicationFactory(
|
||||
configureServices: services => TestServiceOverrides.Apply(services));
|
||||
using StellaOps.TestKit;
|
||||
var client = factory.CreateClient();
|
||||
|
||||
var request = new AttestationVerifyRequest
|
||||
|
||||
@@ -99,6 +99,7 @@ public sealed class EvidenceLockerEndpointTests : IAsyncLifetime
|
||||
|
||||
await _stubStore.SaveAsync(record, CancellationToken.None);
|
||||
using var client = _factory.WithWebHostBuilder(_ => { }).CreateClient();
|
||||
using StellaOps.TestKit;
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "vex.read");
|
||||
|
||||
var response = await client.GetAsync($"/evidence/vex/locker/{record.BundleId}/manifest/file");
|
||||
|
||||
@@ -43,6 +43,7 @@ public sealed class EvidenceTelemetryTests
|
||||
using var listener = CreateListener((instrument, value, tags) =>
|
||||
{
|
||||
measurements.Add((instrument.Name, value, tags.ToArray()));
|
||||
using StellaOps.TestKit;
|
||||
});
|
||||
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
|
||||
@@ -202,6 +202,7 @@ public sealed class IngestEndpointsTests
|
||||
|
||||
Assert.Equal(TimeSpan.FromDays(2), _orchestrator.LastReconcileOptions?.MaxAge);
|
||||
using var document = JsonDocument.Parse(JsonSerializer.Serialize(ok.Value));
|
||||
using StellaOps.TestKit;
|
||||
Assert.Equal("reconciled", document.RootElement.GetProperty("providers")[0].GetProperty("action").GetString());
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ public sealed class MirrorEndpointsTests : IDisposable
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
using var document = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
|
||||
using StellaOps.TestKit;
|
||||
var exports = document.RootElement.GetProperty("exports");
|
||||
Assert.Equal(1, exports.GetArrayLength());
|
||||
var entry = exports[0];
|
||||
|
||||
@@ -90,6 +90,7 @@ public sealed class ObservabilityEndpointTests : IDisposable
|
||||
private void SeedDatabase()
|
||||
{
|
||||
using var scope = _factory.Services.CreateScope();
|
||||
using StellaOps.TestKit;
|
||||
var rawStore = scope.ServiceProvider.GetRequiredService<IVexRawStore>();
|
||||
var linksetStore = scope.ServiceProvider.GetRequiredService<IAppendOnlyLinksetStore>();
|
||||
var providerStore = scope.ServiceProvider.GetRequiredService<IVexProviderStore>();
|
||||
|
||||
@@ -27,6 +27,7 @@ public sealed class PolicyEndpointsTests
|
||||
});
|
||||
|
||||
using var client = factory.CreateClient(new() { AllowAutoRedirect = false });
|
||||
using StellaOps.TestKit;
|
||||
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "vex.read");
|
||||
client.DefaultRequestHeaders.Add("X-Stella-Tenant", "test");
|
||||
|
||||
|
||||
@@ -157,6 +157,7 @@ public sealed class ResolveEndpointTests : IDisposable
|
||||
private async Task SeedClaimAsync(string vulnerabilityId, string productKey, string providerId)
|
||||
{
|
||||
await using var scope = _factory.Services.CreateAsyncScope();
|
||||
using StellaOps.TestKit;
|
||||
var store = scope.ServiceProvider.GetRequiredService<IVexClaimStore>();
|
||||
var timeProvider = scope.ServiceProvider.GetRequiredService<TimeProvider>();
|
||||
var observedAt = timeProvider.GetUtcNow();
|
||||
|
||||
@@ -141,6 +141,7 @@ public sealed class RiskFeedEndpointsTests
|
||||
});
|
||||
|
||||
using var client = factory.CreateClient(new() { AllowAutoRedirect = false });
|
||||
using StellaOps.TestKit;
|
||||
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", "vex.read");
|
||||
client.DefaultRequestHeaders.Add("X-Stella-Tenant", TestTenant);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ public sealed class VexAttestationLinkEndpointTests : IDisposable
|
||||
public async Task GetAttestationLink_ReturnsServiceUnavailable()
|
||||
{
|
||||
using var client = _factory.CreateClient(new WebApplicationFactoryClientOptions { AllowAutoRedirect = false });
|
||||
using StellaOps.TestKit;
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "vex.read");
|
||||
|
||||
var response = await client.GetAsync("/v1/vex/attestations/att-123");
|
||||
|
||||
@@ -57,6 +57,7 @@ public sealed class VexEvidenceChunksEndpointTests : IDisposable
|
||||
public async Task ChunksEndpoint_ReportsMigrationStatusHeaders()
|
||||
{
|
||||
using var client = _factory.CreateClient(new WebApplicationFactoryClientOptions { AllowAutoRedirect = false });
|
||||
using StellaOps.TestKit;
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "vex.read");
|
||||
client.DefaultRequestHeaders.Add("X-Stella-Tenant", "tests");
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ public sealed class VexGuardSchemaTests
|
||||
var node = JsonNode.Parse(json)!.AsObject();
|
||||
mutate?.Invoke(node);
|
||||
using var document = JsonDocument.Parse(node.ToJsonString());
|
||||
using StellaOps.TestKit;
|
||||
return Guard.Validate(document.RootElement);
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ public sealed class VexLinksetListEndpointTests : IDisposable
|
||||
private void SeedObservations()
|
||||
{
|
||||
using var scope = _factory.Services.CreateScope();
|
||||
using StellaOps.TestKit;
|
||||
var store = scope.ServiceProvider.GetRequiredService<IAppendOnlyLinksetStore>();
|
||||
|
||||
var scopeMetadata = new VexProductScope(
|
||||
|
||||
@@ -67,6 +67,7 @@ public sealed class VexObservationListEndpointTests : IDisposable
|
||||
private void SeedObservation()
|
||||
{
|
||||
using var scope = _factory.Services.CreateScope();
|
||||
using StellaOps.TestKit;
|
||||
var store = scope.ServiceProvider.GetRequiredService<IVexObservationStore>();
|
||||
|
||||
var now = DateTimeOffset.Parse("2025-12-01T00:00:00Z");
|
||||
|
||||
@@ -76,6 +76,7 @@ public sealed class VexRawEndpointsTests
|
||||
private static VexIngestRequest BuildVexIngestRequest()
|
||||
{
|
||||
using var contentDocument = JsonDocument.Parse("{\"vex\":\"payload\"}");
|
||||
using StellaOps.TestKit;
|
||||
return new VexIngestRequest(
|
||||
ProviderId: "excititor:test",
|
||||
Source: new VexIngestSourceRequest("vendor:test", "connector:test", "1.0.0", "csaf"),
|
||||
|
||||
@@ -22,6 +22,7 @@ public sealed class TenantAuthorityClientFactoryTests
|
||||
|
||||
using var client = factory.Create("tenant-a");
|
||||
|
||||
using StellaOps.TestKit;
|
||||
client.BaseAddress.Should().Be(new Uri("https://authority.example/"));
|
||||
client.DefaultRequestHeaders.TryGetValues("X-Tenant", out var values).Should().BeTrue();
|
||||
values.Should().ContainSingle().Which.Should().Be("tenant-a");
|
||||
|
||||
Reference in New Issue
Block a user