nuget reorganization
This commit is contained in:
@@ -4,6 +4,12 @@
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<CollectCoverage>false</CollectCoverage>
|
||||
<RunAnalyzers>false</RunAnalyzers>
|
||||
<RunAnalyzersDuringBuild>false</RunAnalyzersDuringBuild>
|
||||
<UseSharedCompilation>false</UseSharedCompilation>
|
||||
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
|
||||
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Concelier.Core/StellaOps.Concelier.Core.csproj" />
|
||||
|
||||
@@ -69,6 +69,7 @@ public sealed class WebServiceEndpointsTests : IAsyncLifetime
|
||||
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
PrepareMongoEnvironment();
|
||||
_runner = MongoDbRunner.Start(singleNodeReplSet: true);
|
||||
_factory = new ConcelierApplicationFactory(_runner.ConnectionString);
|
||||
WarmupFactory(_factory);
|
||||
@@ -145,6 +146,12 @@ public sealed class WebServiceEndpointsTests : IAsyncLifetime
|
||||
Assert.Equal("https://example.test/advisory-1", references[0].GetProperty("url").GetString());
|
||||
Assert.Equal("patch", references[1].GetProperty("type").GetString());
|
||||
|
||||
var confidence = linkset.GetProperty("confidence").GetDouble();
|
||||
Assert.Equal(1.0, confidence);
|
||||
|
||||
var conflicts = linkset.GetProperty("conflicts").EnumerateArray().ToArray();
|
||||
Assert.Empty(conflicts);
|
||||
|
||||
Assert.False(root.GetProperty("hasMore").GetBoolean());
|
||||
Assert.True(root.GetProperty("nextCursor").ValueKind == JsonValueKind.Null);
|
||||
}
|
||||
@@ -2500,20 +2507,92 @@ public sealed class WebServiceEndpointsTests : IAsyncLifetime
|
||||
{
|
||||
_output.WriteLine($"[PROGRAM LOG] {entry.Level}: {entry.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void WarmupFactory(WebApplicationFactory<Program> factory)
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
}
|
||||
private static void WarmupFactory(WebApplicationFactory<Program> factory)
|
||||
{
|
||||
using var client = factory.CreateClient();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure Mongo2Go can start without external downloads by pointing it to cached binaries and OpenSSL 1.1 libs shipped in repo.
|
||||
/// </summary>
|
||||
private static void PrepareMongoEnvironment()
|
||||
{
|
||||
var repoRoot = FindRepoRoot();
|
||||
if (repoRoot is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var cacheDir = Path.Combine(repoRoot, ".cache", "mongodb-local");
|
||||
Directory.CreateDirectory(cacheDir);
|
||||
Environment.SetEnvironmentVariable("MONGO2GO_CACHE_LOCATION", cacheDir);
|
||||
Environment.SetEnvironmentVariable("MONGO2GO_DOWNLOADS", cacheDir);
|
||||
Environment.SetEnvironmentVariable("MONGO2GO_MONGODB_VERSION", "4.4.4");
|
||||
|
||||
var opensslPath = Path.Combine(repoRoot, "tests", "native", "openssl-1.1", "linux-x64");
|
||||
if (Directory.Exists(opensslPath))
|
||||
{
|
||||
// Prepend OpenSSL 1.1 path so Mongo2Go binaries find libssl/libcrypto.
|
||||
var existing = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");
|
||||
var combined = string.IsNullOrEmpty(existing) ? opensslPath : $"{opensslPath}:{existing}";
|
||||
Environment.SetEnvironmentVariable("LD_LIBRARY_PATH", combined);
|
||||
}
|
||||
|
||||
// Also drop the OpenSSL libs next to the mongod binary Mongo2Go will spawn, in case LD_LIBRARY_PATH is ignored.
|
||||
var mongoBin = Directory.Exists(Path.Combine(repoRoot, ".nuget"))
|
||||
? Directory.GetFiles(Path.Combine(repoRoot, ".nuget", "packages", "mongo2go"), "mongod", SearchOption.AllDirectories)
|
||||
.FirstOrDefault(path => path.Contains("mongodb-linux-4.4.4", StringComparison.OrdinalIgnoreCase))
|
||||
: null;
|
||||
if (mongoBin is not null && File.Exists(mongoBin) && Directory.Exists(opensslPath))
|
||||
{
|
||||
var binDir = Path.GetDirectoryName(mongoBin)!;
|
||||
foreach (var libName in new[] { "libssl.so.1.1", "libcrypto.so.1.1" })
|
||||
{
|
||||
var target = Path.Combine(binDir, libName);
|
||||
var source = Path.Combine(opensslPath, libName);
|
||||
if (File.Exists(source) && !File.Exists(target))
|
||||
{
|
||||
File.Copy(source, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string? FindRepoRoot()
|
||||
{
|
||||
var current = AppContext.BaseDirectory;
|
||||
while (!string.IsNullOrEmpty(current))
|
||||
{
|
||||
if (File.Exists(Path.Combine(current, "Directory.Build.props")))
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
var parent = Directory.GetParent(current);
|
||||
if (parent is null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
current = parent.FullName;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static AdvisoryIngestRequest BuildAdvisoryIngestRequest(
|
||||
string? contentHash,
|
||||
string upstreamId,
|
||||
bool enforceContentHash = true)
|
||||
bool enforceContentHash = true,
|
||||
IReadOnlyList<string>? purls = null,
|
||||
IReadOnlyList<string>? notes = null)
|
||||
{
|
||||
var raw = CreateJsonElement($@"{{""id"":""{upstreamId}"",""modified"":""{DefaultIngestTimestamp:O}""}}");
|
||||
var normalizedContentHash = NormalizeContentHash(contentHash, raw, enforceContentHash);
|
||||
var resolvedPurls = purls ?? new[] { "pkg:npm/demo@1.0.0" };
|
||||
var resolvedNotes = notes ?? Array.Empty<string>();
|
||||
var references = new[]
|
||||
{
|
||||
new AdvisoryLinksetReferenceRequest("advisory", $"https://example.test/advisories/{upstreamId}", null)
|
||||
@@ -2534,11 +2613,12 @@ public sealed class WebServiceEndpointsTests : IAsyncLifetime
|
||||
new[] { upstreamId, $"{upstreamId}-ALIAS" }),
|
||||
new AdvisoryLinksetRequest(
|
||||
new[] { upstreamId },
|
||||
new[] { "pkg:npm/demo@1.0.0" },
|
||||
resolvedPurls,
|
||||
Array.Empty<AdvisoryLinksetRelationshipRequest>(),
|
||||
Array.Empty<string>(),
|
||||
Array.Empty<string>(),
|
||||
references,
|
||||
Array.Empty<string>(),
|
||||
Array.Empty<string>(),
|
||||
resolvedNotes,
|
||||
new Dictionary<string, string> { ["note"] = "ingest-test" }));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user