fix: filter domain assembly scans to Default ALC to prevent type identity mismatches
Plugin assemblies loaded via PluginHost into isolated AssemblyLoadContexts produce distinct types even from the same DLL. When AppDomain.GetAssemblies() returns both Default and plugin-ALC copies, DI registration and IOptions<T> resolution silently fail (e.g. ValkeyTransportOptions defaulting to localhost). Applied AssemblyLoadContext.Default filter to all 7 assembly discovery sites: - MessagingServiceCollectionExtensions (transport plugin scan) - StellaRouterIntegrationHelper (transport plugin loader) - Gateway.WebService Program.cs (startup transport scan) - GeneratedEndpointDiscoveryProvider (endpoint provider scan) - ReflectionEndpointDiscoveryProvider (endpoint attribute scan) - ServiceCollectionExtensions (schema provider scan) - MigrationModulePluginDiscovery (migration plugin scan) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# Cartographer Tests Charter
|
||||
|
||||
## Mission
|
||||
Own test coverage for Cartographer service configuration and behavior.
|
||||
|
||||
## Responsibilities
|
||||
- Maintain `StellaOps.Cartographer.Tests`.
|
||||
- Validate options defaults, validation, and integration wiring.
|
||||
- Surface open work on `TASKS.md`; update statuses (TODO/DOING/DONE/BLOCKED/REVIEW).
|
||||
|
||||
## Key Paths
|
||||
- `Options/CartographerAuthorityOptionsConfiguratorTests.cs`
|
||||
|
||||
## Coordination
|
||||
- Cartographer service owners.
|
||||
- Authority integration owners for scope contracts.
|
||||
|
||||
## Required Reading
|
||||
- `docs/modules/platform/architecture-overview.md`
|
||||
- `docs/modules/graph/architecture.md`
|
||||
|
||||
## Working Agreement
|
||||
- 1. Update task status to `DOING`/`DONE` in both corresponding sprint file `/docs/implplan/SPRINT_*.md` and the local `TASKS.md` when you start or finish work.
|
||||
- 2. Review this charter and the Required Reading documents before coding; confirm prerequisites are met.
|
||||
- 3. Keep changes deterministic (stable ordering, timestamps, hashes) and align with offline/air-gap expectations.
|
||||
- 4. Coordinate doc updates, tests, and cross-guild communication whenever contracts or workflows change.
|
||||
- 5. Revert to `TODO` if you pause the task without shipping changes; leave notes in commit/PR descriptions for context.
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Net;
|
||||
using FluentAssertions;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Cartographer.Tests;
|
||||
|
||||
public class CartographerProgramTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task HealthEndpoints_ReturnOk()
|
||||
{
|
||||
using var factory = new WebApplicationFactory<StellaOps.Cartographer.CartographerEntryPoint>();
|
||||
using var client = factory.CreateClient();
|
||||
var cancellationToken = TestContext.Current.CancellationToken;
|
||||
|
||||
var health = await client.GetAsync("/healthz", cancellationToken);
|
||||
var ready = await client.GetAsync("/readyz", cancellationToken);
|
||||
|
||||
health.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
ready.StatusCode.Should().Be(HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AuthorityOptions_InvalidIssuer_ThrowsOnStart()
|
||||
{
|
||||
using var factory = new WebApplicationFactory<StellaOps.Cartographer.CartographerEntryPoint>().WithWebHostBuilder(builder =>
|
||||
{
|
||||
builder.ConfigureAppConfiguration((_, config) =>
|
||||
{
|
||||
var settings = new Dictionary<string, string?>
|
||||
{
|
||||
["Cartographer:Authority:Enabled"] = "true",
|
||||
["Cartographer:Authority:Issuer"] = "invalid"
|
||||
};
|
||||
|
||||
config.AddInMemoryCollection(settings);
|
||||
});
|
||||
});
|
||||
|
||||
Action act = () => factory.CreateClient();
|
||||
act.Should().Throw<OptionsValidationException>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using StellaOps.Auth.Abstractions;
|
||||
using StellaOps.Cartographer.Options;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Cartographer.Tests.Options;
|
||||
|
||||
public class CartographerAuthorityOptionsConfiguratorTests
|
||||
{
|
||||
[Fact]
|
||||
public void ApplyDefaults_AddsGraphScopes()
|
||||
{
|
||||
var options = new CartographerAuthorityOptions();
|
||||
|
||||
CartographerAuthorityOptionsConfigurator.ApplyDefaults(options);
|
||||
|
||||
Assert.Contains(StellaOpsScopes.GraphRead, options.RequiredScopes);
|
||||
Assert.Contains(StellaOpsScopes.GraphWrite, options.RequiredScopes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ApplyDefaults_DoesNotDuplicateScopes()
|
||||
{
|
||||
var options = new CartographerAuthorityOptions();
|
||||
options.RequiredScopes.Add("GRAPH:READ");
|
||||
options.RequiredScopes.Add(StellaOpsScopes.GraphWrite);
|
||||
|
||||
CartographerAuthorityOptionsConfigurator.ApplyDefaults(options);
|
||||
|
||||
Assert.Equal(2, options.RequiredScopes.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_AllowsDisabledConfiguration()
|
||||
{
|
||||
var options = new CartographerAuthorityOptions();
|
||||
|
||||
options.Validate(); // should not throw when disabled
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Validate_ThrowsForInvalidIssuer()
|
||||
{
|
||||
var options = new CartographerAuthorityOptions
|
||||
{
|
||||
Enabled = true,
|
||||
Issuer = "invalid"
|
||||
};
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() => options.Validate());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../StellaOps.Cartographer/StellaOps.Cartographer.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
|
||||
<PackageReference Include="FluentAssertions" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
# Cartographer Tests Task Board
|
||||
|
||||
This board mirrors active sprint tasks for this module.
|
||||
Source of truth: `docs-archived/implplan/2025-12-29-csproj-audit/SPRINT_20251229_049_BE_csproj_audit_maint_tests.md`.
|
||||
|
||||
| Task ID | Status | Notes |
|
||||
| --- | --- | --- |
|
||||
| AUDIT-0135-M | DONE | Maintainability audit for StellaOps.Cartographer.Tests; revalidated 2026-01-06. |
|
||||
| AUDIT-0135-T | DONE | Test coverage audit for StellaOps.Cartographer.Tests; revalidated 2026-01-06. |
|
||||
| AUDIT-0135-A | DONE | Waived (test project; revalidated 2026-01-06). |
|
||||
| REMED-06 | DONE | SOLID review notes captured for SPRINT_20260130_002. |
|
||||
Reference in New Issue
Block a user