up
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
api-governance / spectral-lint (push) Has been cancelled
Some checks failed
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Docs CI / lint-and-preview (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
api-governance / spectral-lint (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FluentAssertions;
|
||||
using Mongo2Go;
|
||||
using MongoDB.Driver;
|
||||
using StellaOps.Concelier.Core.Linksets;
|
||||
using StellaOps.Concelier.Storage.Mongo.Linksets;
|
||||
|
||||
namespace StellaOps.Concelier.Storage.Mongo.Tests;
|
||||
|
||||
public sealed class AdvisoryLinksetStoreTests : IAsyncLifetime
|
||||
{
|
||||
private MongoDbRunner _runner = null!;
|
||||
private IMongoDatabase _database = null!;
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
_runner = MongoDbRunner.Start(singleNodeReplSet: true);
|
||||
var client = new MongoClient(_runner.ConnectionString);
|
||||
_database = client.GetDatabase("lnm-store-tests");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task DisposeAsync()
|
||||
{
|
||||
_runner.Dispose();
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpsertAndFetch_RetainsCpesInNormalizedShape()
|
||||
{
|
||||
var collection = _database.GetCollection<AdvisoryLinksetDocument>(MongoStorageDefaults.Collections.AdvisoryLinksets);
|
||||
var store = new ConcelierMongoLinksetStore(collection);
|
||||
|
||||
var linkset = new AdvisoryLinkset(
|
||||
TenantId: "TenantA",
|
||||
Source: "source-A",
|
||||
AdvisoryId: "ADV-1234",
|
||||
ObservationIds: ImmutableArray.Create("obs-1"),
|
||||
Normalized: new AdvisoryLinksetNormalized(
|
||||
Purls: new List<string> { "pkg:npm/lodash@4.17.21" },
|
||||
Cpes: new List<string> { "cpe:2.3:a:lodash:lodash:4.17.21:*:*:*:*:*:*:*" },
|
||||
Versions: new List<string> { "4.17.21" },
|
||||
Ranges: new List<Dictionary<string, object?>>(),
|
||||
Severities: null),
|
||||
Provenance: null,
|
||||
Confidence: null,
|
||||
Conflicts: null,
|
||||
CreatedAt: DateTimeOffset.Parse("2025-11-24T00:00:00Z"),
|
||||
BuiltByJobId: "job-001");
|
||||
|
||||
await store.UpsertAsync(linkset, CancellationToken.None);
|
||||
|
||||
var result = await store.FindByTenantAsync(
|
||||
tenantId: "TenantA",
|
||||
advisoryIds: new[] { "ADV-1234" },
|
||||
sources: new[] { "source-A" },
|
||||
cursor: null,
|
||||
limit: 10,
|
||||
cancellationToken: CancellationToken.None);
|
||||
|
||||
result.Should().ContainSingle();
|
||||
var returned = result.Single();
|
||||
returned.Normalized.Should().NotBeNull();
|
||||
returned.Normalized!.Cpes.Should().ContainSingle()
|
||||
.Which.Should().Be("cpe:2.3:a:lodash:lodash:4.17.21:*:*:*:*:*:*:*");
|
||||
}
|
||||
}
|
||||
15
tests/shared/OpenSslAutoInit.cs
Normal file
15
tests/shared/OpenSslAutoInit.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StellaOps.Testing;
|
||||
|
||||
/// <summary>
|
||||
/// Automatically ensures OpenSSL 1.1 shim is visible for Mongo2Go-based tests.
|
||||
/// </summary>
|
||||
internal static class OpenSslAutoInit
|
||||
{
|
||||
[ModuleInitializer]
|
||||
public static void Init()
|
||||
{
|
||||
OpenSslLegacyShim.EnsureOpenSsl11();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user