fix tests. new product advisories enhancements
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// PostgresCollectionDefinition.cs
|
||||
// Sprint: SPRINT_20260120_030_Platform_sbom_analytics_lake
|
||||
// Task: Test fixture registration
|
||||
// Description: xUnit collection definition for PostgreSQL fixture
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StellaOps.TestKit.Fixtures;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Platform.Analytics.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Collection definition for PostgreSQL fixture sharing across analytics test classes.
|
||||
/// This must be defined in the same assembly as the test classes that use it.
|
||||
/// </summary>
|
||||
[CollectionDefinition("Postgres")]
|
||||
public class PostgresCollectionDefinition : ICollectionFixture<PostgresFixture>
|
||||
{
|
||||
// This class has no code, and is never created. Its purpose is simply
|
||||
// to be the place to apply [CollectionDefinition] and all the
|
||||
// ICollectionFixture<> interfaces.
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StellaOps.Platform.WebService.Tests;
|
||||
@@ -8,14 +10,48 @@ public sealed class PlatformWebApplicationFactory : WebApplicationFactory<Progra
|
||||
{
|
||||
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
||||
{
|
||||
// Set environment variable before host builds to disable OpenTelemetry SDK
|
||||
Environment.SetEnvironmentVariable("OTEL_SDK_DISABLED", "true");
|
||||
|
||||
builder.UseSetting("Platform:Authority:Issuer", "https://authority.local");
|
||||
builder.UseSetting("Platform:Authority:RequireHttpsMetadata", "false");
|
||||
builder.UseSetting("Platform:Authority:BypassNetworks:0", "127.0.0.1/32");
|
||||
builder.UseSetting("Platform:Authority:BypassNetworks:1", "::1/128");
|
||||
|
||||
// Disable OpenTelemetry instrumentation for tests to avoid ConfigureServices after build
|
||||
builder.UseSetting("Telemetry:Enabled", "false");
|
||||
builder.UseSetting("OTEL_SDK_DISABLED", "true");
|
||||
|
||||
builder.ConfigureAppConfiguration((context, config) =>
|
||||
{
|
||||
// Add in-memory configuration to disable telemetry
|
||||
config.AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["Telemetry:Enabled"] = "false",
|
||||
["OTEL_SDK_DISABLED"] = "true"
|
||||
});
|
||||
});
|
||||
|
||||
builder.ConfigureLogging(logging =>
|
||||
{
|
||||
logging.ClearProviders();
|
||||
});
|
||||
|
||||
builder.ConfigureServices(services =>
|
||||
{
|
||||
// Remove OpenTelemetry tracer/meter provider configuration callbacks
|
||||
// These cause "Services cannot be configured after ServiceProvider has been created" errors
|
||||
var descriptorsToRemove = services
|
||||
.Where(d => d.ServiceType.FullName?.Contains("OpenTelemetry") == true
|
||||
|| d.ImplementationType?.FullName?.Contains("OpenTelemetry") == true
|
||||
|| d.ServiceType.FullName?.Contains("ConfigureTracerProviderBuilder") == true
|
||||
|| d.ServiceType.FullName?.Contains("ConfigureMeterProviderBuilder") == true)
|
||||
.ToList();
|
||||
|
||||
foreach (var descriptor in descriptorsToRemove)
|
||||
{
|
||||
services.Remove(descriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ public sealed class PolicyInteropEndpointsTests
|
||||
"apiVersion": "policy.stellaops.io/v1",
|
||||
"kind": "PolicyPack",
|
||||
"metadata": { "name": "test", "version": "1.0.0" },
|
||||
"spec": { "settings": {}, "gates": [] }
|
||||
"spec": { "settings": { "defaultAction": "allow", "scoring": { "enabled": false } }, "gates": [] }
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -300,7 +300,7 @@ public sealed class PolicyInteropEndpointsTests
|
||||
|
||||
Assert.False(result.Valid);
|
||||
Assert.NotNull(result.Errors);
|
||||
Assert.Contains(result.Errors, e => e.Code == "VERSION_MISMATCH");
|
||||
Assert.Contains(result.Errors, e => e.Code == "VERSION_MISMATCH" || e.Code == "UNSUPPORTED_API_VERSION");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -27,6 +27,7 @@ public sealed class ScoreEndpointsTests
|
||||
private readonly IWeightManifestLoader _manifestLoader;
|
||||
private readonly IReplayLogBuilder _replayLogBuilder;
|
||||
private readonly IReplayVerifier _replayVerifier;
|
||||
private readonly IScoreHistoryStore _scoreHistoryStore;
|
||||
private readonly ScoreEvaluationService _service;
|
||||
private readonly PlatformRequestContext _context = new("test-tenant", "test-actor", null);
|
||||
|
||||
@@ -36,6 +37,7 @@ public sealed class ScoreEndpointsTests
|
||||
_manifestLoader = Substitute.For<IWeightManifestLoader>();
|
||||
_replayLogBuilder = Substitute.For<IReplayLogBuilder>();
|
||||
_replayVerifier = Substitute.For<IReplayVerifier>();
|
||||
_scoreHistoryStore = Substitute.For<IScoreHistoryStore>();
|
||||
|
||||
// Default manifest setup
|
||||
var defaultManifest = WeightManifest.FromEvidenceWeights(EvidenceWeights.Default, "v-test");
|
||||
@@ -60,6 +62,7 @@ public sealed class ScoreEndpointsTests
|
||||
_manifestLoader,
|
||||
_replayLogBuilder,
|
||||
_replayVerifier,
|
||||
_scoreHistoryStore,
|
||||
NullLogger<ScoreEvaluationService>.Instance);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user