- Implemented `MongoIndexModelTests` to verify index models for various stores. - Created `OpenApiMetadataFactory` with methods to generate OpenAPI metadata. - Added tests for `OpenApiMetadataFactory` to ensure expected defaults and URL overrides. - Introduced `ObserverSurfaceSecrets` and `WebhookSurfaceSecrets` for managing secrets. - Developed `RuntimeSurfaceFsClient` and `WebhookSurfaceFsClient` for manifest retrieval. - Added dependency injection tests for `SurfaceEnvironmentRegistration` in both Observer and Webhook contexts. - Implemented tests for secret resolution in `ObserverSurfaceSecretsTests` and `WebhookSurfaceSecretsTests`. - Created `EnsureLinkNotMergeCollectionsMigrationTests` to validate MongoDB migration logic. - Added project files for MongoDB tests and NuGet package mirroring.
59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using StellaOps.Scanner.Surface.FS;
|
|
using StellaOps.Zastava.Observer.Configuration;
|
|
using StellaOps.Zastava.Observer.Surface;
|
|
using Xunit;
|
|
|
|
namespace StellaOps.Zastava.Observer.Tests.Surface;
|
|
|
|
public sealed class RuntimeSurfaceFsClientTests
|
|
{
|
|
[Fact]
|
|
public async Task TryGetManifestAsync_ReturnsPublishedManifest()
|
|
{
|
|
var configuration = new ConfigurationBuilder()
|
|
.AddInMemoryCollection(new Dictionary<string, string?>
|
|
{
|
|
[$"{ZastavaObserverOptions.SectionName}:runtimes:0:engine"] = "Containerd",
|
|
[$"{ZastavaObserverOptions.SectionName}:backend:baseAddress"] = "https://scanner.internal"
|
|
})
|
|
.Build();
|
|
|
|
var services = new ServiceCollection();
|
|
services.AddLogging();
|
|
services.AddZastavaObserver(configuration);
|
|
|
|
using var provider = services.BuildServiceProvider();
|
|
var manifestWriter = provider.GetRequiredService<ISurfaceManifestWriter>();
|
|
var client = provider.GetRequiredService<IRuntimeSurfaceFsClient>();
|
|
|
|
var document = new SurfaceManifestDocument
|
|
{
|
|
Tenant = "default",
|
|
ImageDigest = "sha256:deadbeef",
|
|
GeneratedAt = DateTimeOffset.UtcNow,
|
|
Artifacts = new[]
|
|
{
|
|
new SurfaceManifestArtifact
|
|
{
|
|
Kind = "entry-trace",
|
|
Uri = "cas://surface-cache/manifest/entry-trace",
|
|
Digest = "sha256:abc123",
|
|
MediaType = "application/json",
|
|
Format = "ndsjon"
|
|
}
|
|
}
|
|
};
|
|
|
|
var published = await manifestWriter.PublishAsync(document, default);
|
|
var fetched = await client.TryGetManifestAsync(published.ManifestDigest, default);
|
|
|
|
Assert.NotNull(fetched);
|
|
Assert.Equal(document.Tenant, fetched!.Tenant);
|
|
Assert.Equal(document.ImageDigest, fetched.ImageDigest);
|
|
}
|
|
}
|