Skip to content

Phase 36: Auth, Observability & System Management Test Hardening (+33 unit tests)#71

Merged
devstress merged 5 commits intomainfrom
copilot/continue-eips-next-chunks
Apr 9, 2026
Merged

Phase 36: Auth, Observability & System Management Test Hardening (+33 unit tests)#71
devstress merged 5 commits intomainfrom
copilot/continue-eips-next-chunks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Audit identified zero dedicated tests for ApiKeyAuthenticationHandler (security-critical), LokiObservabilityEventLog (observability event storage with Loki HTTP + in-memory fallback), ControlBusPublisher (EIP Control Bus pattern), and DlqManagementService (DLQ replay). UnitTests: 1886 → 1919.

Chunk 360 — ApiKeyAuthenticationHandler (10 tests)

  • Missing header, invalid key, valid key with Admin role / Name / apikey_prefix claims
  • Case-sensitive ordinal comparison, multiple configured keys, empty config rejection, short key masking (****)
  • Added InternalsVisibleTo("UnitTests") to Admin.Api.csproj (handler is internal sealed)
  • Added FrameworkReference Microsoft.AspNetCore.App to UnitTests.csproj

Chunk 361 — LokiObservabilityEventLog (11 tests)

  • RecordAsync: Loki push endpoint, swallows HTTP errors without rethrowing, always persists to static fallback store
  • GetByCorrelationId / GetByBusinessKey: Loki query_range parsing, fallback on failure, case-insensitive business key match
  • Uses MockLokiHandler (DelegatingHandler) with separate push/query status codes; reflection clears static FallbackStore in [SetUp]

Chunk 362 — ControlBusPublisher & DlqManagementService (12 tests)

  • PublishCommandAsync: success result, topic routing, MessageIntent.Command on envelope, producer exception → Succeeded=false
  • SubscribeAsync: consumer registration on control topic, command type filtering
  • Argument guards: null command/handler, empty command type, null producer/consumer constructors
  • DlqManagementService: delegates to IMessageReplayer, passes ReplayFilter through
// Example: ControlBusPublisher wraps commands with Command intent
var result = await _sut.PublishCommandAsync<object>(
    new { Action = "restart" }, "RestartService");
Assert.That(capturedIntent, Is.EqualTo(MessageIntent.Command));
Assert.That(result.ControlTopic, Is.EqualTo("test.control"));

Copilot AI and others added 5 commits April 9, 2026 07:39
…d MessageTracer

Tests cover:
- CorrelationPropagator: inject/extract trace context with/without Activity
- PlatformMeters: all 5 Record* methods with MeterListener verification
- MessageTracer: all 4 Trace* stage methods plus CompleteSuccess/CompleteFailed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: devstress <30769729+devstress@users.noreply.github.com>
Tests cover DefaultMessageValidationService, DefaultCompensationActivityService,
MessageValidationResult, MessageHistoryEntry, and MessageHistoryStatus enum.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: devstress <30769729+devstress@users.noreply.github.com>
Add 12 comprehensive unit tests covering:
- HttpEnrichmentSource: constructor guards, successful fetch, URL placeholder
  replacement, and non-success status code handling
- DatabaseEnrichmentSource: constructor guards, no-rows returns null,
  and row-with-data returns populated JsonObject

Uses lightweight ADO.NET test doubles for database tests since DbCommand
non-virtual members prevent NSubstitute mocking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: devstress <30769729+devstress@users.noreply.github.com>
…g (Chunks 350–352)

43 new unit tests. UnitTests total: 1886 (was 1843).

Chunk 350: CorrelationPropagator, PlatformMeters & MessageTracer Tests (17 tests)
Chunk 351: Activity Service & Message Validation Tests (14 tests)
Chunk 352: HttpEnrichmentSource & DatabaseEnrichmentSource Tests (12 tests)

Agent-Logs-Url: https://github.com/devstress/My3DLearning/sessions/12fd4d83-5324-48f8-99d7-9365b3f569dc

Co-authored-by: devstress <30769729+devstress@users.noreply.github.com>
…ng (Chunks 360–362, +33 tests)

Chunk 360: ApiKeyAuthenticationHandler — 10 tests
Chunk 361: LokiObservabilityEventLog — 11 tests
Chunk 362: ControlBusPublisher & DlqManagementService — 12 tests

UnitTests: 1886 → 1919. Build: 0 errors.

Agent-Logs-Url: https://github.com/devstress/My3DLearning/sessions/7937c5ff-5a24-41bd-ad89-325a0dc71764

Co-authored-by: devstress <30769729+devstress@users.noreply.github.com>
@devstress devstress marked this pull request as ready for review April 9, 2026 11:20
@devstress devstress merged commit 6fbe1b2 into main Apr 9, 2026
3 checks passed
@devstress devstress deleted the copilot/continue-eips-next-chunks branch April 9, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants