Path: redb-identity/tests/redb.Identity.Tests/Security/ManagementSurfaceGateTests.cs
Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity
Page: https://redbase.app/src/dev-2026-12-06/redb-identity/tests/redb.Identity.Tests/Security/ManagementSurfaceGateTests.cs
----
using System.Reflection;
using System.Text;
using System.Text.Json;
using AwesomeAssertions;
using redb.Identity.Contracts.Routes;
using redb.Identity.Tests.Infrastructure;
using redb.Route.Abstractions;
using Xunit;
namespace redb.Identity.Tests.Security;
///
/// The core management surface trusts no transport.
///
/// direct-vm://identity-manage-*, identity-manage-mfa, identity-me-*,
/// identity-scim-* and identity-revoked-sids are reached by the facades after a bearer was
/// validated and the identity:management-* properties were attached. In a Tsak worker the same
/// direct-vm registry is shared by every module in the process, so an exchange that arrives
/// without that context is not "internal and trusted" — it is unauthenticated. Every route of the
/// surface must refuse it before any business processor runs, and the refusal must be the same
/// generic 403 the self-or-admin rule produces, so nothing about the target leaks.
///
///
[Collection("IdentityRoute")]
public sealed class ManagementSurfaceGateTests
{
private readonly IdentityRouteFixture _fx;
public ManagementSurfaceGateTests(IdentityRouteFixture fx) => _fx = fx;
///
/// Routes the fixture registers only when a feature is on. Absent in the fixture, they are skipped
/// by name; anything else that is absent fails the test — a new guarded route must be covered.
///
private static readonly HashSet ConditionalRoutes = new(StringComparer.Ordinal)
{
IdentityEndpoints.ManageSigningKeys,
IdentityEndpoints.ScimUsers,
IdentityEndpoints.ScimGroups,
IdentityEndpoints.ScimBulk,
IdentityEndpoints.MeWebAuthn,
IdentityEndpoints.MeEmailVerifySend,
IdentityEndpoints.MeChangeEmailRequest,
};
/// Every endpoint constant on the guarded surface, read off .
public static IEnumerable