Repair router frontdoor convergence and live route contracts

This commit is contained in:
master
2026-03-09 19:09:19 +02:00
parent 49d1c57597
commit bf937c9395
25 changed files with 740 additions and 61 deletions

View File

@@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using StellaOps.Gateway.WebService.Authorization;
using StellaOps.Gateway.WebService.Middleware;
using StellaOps.Router.Common.Models;
using StellaOps.Router.Gateway;
using Xunit;
@@ -232,6 +233,33 @@ public sealed class AuthorizationMiddlewareTests
_next.Verify(n => n(context), Times.Once);
}
[Fact]
public async Task InvokeAsync_ScopeRequirement_UsesResolvedGatewayScopes_WhenPresent()
{
var context = CreateHttpContextWithEndpoint(new[]
{
new Claim("scope", "orch:quota")
});
context.Items[GatewayContextKeys.Scopes] = new HashSet<string>(StringComparer.Ordinal)
{
"orch:quota",
"quota.read",
"quota.admin"
};
_claimsStore
.Setup(s => s.GetEffectiveClaims("test-service", "GET", "/api/test"))
.Returns(new List<ClaimRequirement>
{
new() { Type = "scope", Value = "quota.read" },
new() { Type = "scope", Value = "orch:quota" }
});
await _middleware.InvokeAsync(context);
_next.Verify(n => n(context), Times.Once);
}
[Fact]
public async Task InvokeAsync_ForbiddenResponse_ContainsErrorDetails()
{