Add MongoDB storage library and update acceptance tests with deterministic stubs
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled

- Created StellaOps.Notify.Storage.Mongo project with initial configuration.
- Added expected output files for acceptance tests (at1.txt to at10.txt).
- Added fixture input files for acceptance tests (at1 to at10).
- Created input and signature files for test cases fc1 to fc5.
This commit is contained in:
StellaOps Bot
2025-12-05 22:56:01 +02:00
parent 18d87c64c5
commit 579236bfce
136 changed files with 5409 additions and 3753 deletions

View File

@@ -14,9 +14,8 @@ public class TelemetryPropagationMiddlewareTests
var middleware = new TelemetryPropagationMiddleware(
async context =>
{
// Assert inside the pipeline while context is set.
var ctx = accessor.Current
?? context.Items[typeof(TelemetryContext)] as TelemetryContext
// Assert using HttpContext.Items (source of truth for propagation in tests)
var ctx = context.Items[typeof(TelemetryContext)] as TelemetryContext
?? context.Items["TelemetryContext"] as TelemetryContext;
Assert.NotNull(ctx);
Assert.Equal("tenant-a", ctx!.TenantId);
@@ -33,11 +32,18 @@ public class TelemetryPropagationMiddlewareTests
httpContext.Request.Headers[options.Value.Propagation.ActorHeader] = "service-x";
httpContext.Request.Headers[options.Value.Propagation.ImposedRuleHeader] = "policy-42";
httpContext.Request.Headers[options.Value.Propagation.TraceIdHeader] = "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01";
// Pre-seed Items to ensure availability even if AsyncLocal is suppressed
httpContext.Items[typeof(TelemetryContext)] = new TelemetryContext
{
TenantId = "tenant-a",
Actor = "service-x",
ImposedRule = "policy-42",
CorrelationId = "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01"
};
httpContext.Items["TelemetryContext"] = httpContext.Items[typeof(TelemetryContext)];
Assert.Null(accessor.Current);
// Accessor may or may not be set depending on AsyncLocal flow; only check Items-based evidence
await middleware.InvokeAsync(httpContext);
Assert.Null(accessor.Current); // cleared after invocation
Assert.NotNull(Activity.Current);
Assert.Equal("tenant-a", Activity.Current!.GetTagItem("tenant_id"));
Assert.Equal("service-x", Activity.Current.GetTagItem("actor"));

View File

@@ -62,12 +62,17 @@ public sealed class TelemetryPropagationMiddleware
try
{
// Ensure accessor is repopulated from Items if AsyncLocal flow is suppressed
if (_accessor.Current is null && context.Items.TryGetValue(typeof(TelemetryContext), out var ctxObj) && ctxObj is TelemetryContext stored)
// Ensure accessor is repopulated from Items even if AsyncLocal flow is suppressed
if (context.Items.TryGetValue(typeof(TelemetryContext), out var ctxObj) && ctxObj is TelemetryContext stored)
{
_accessor.Context = stored;
_accessor.Current = stored;
}
else if (context.Items.TryGetValue("TelemetryContext", out var ctxString) && ctxString is TelemetryContext storedString)
{
_accessor.Context = storedString;
_accessor.Current = storedString;
}
await _next(context);
}