Path: redb-identity/tests/redb.Identity.Tests/Infrastructure/ManagementCaller.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/Infrastructure/ManagementCaller.cs
----
using redb.Identity.Contracts.Configuration;
using redb.Route.Abstractions;
namespace redb.Identity.Tests.Infrastructure;
///
/// Who a fixture stands in for when it sends straight to a core management route.
///
/// The core routes (direct-vm://identity-manage-*, identity-me-*, identity-scim-*,
/// identity-revoked-sids) never see a bearer token themselves: a facade validates it on the
/// identity-auth-management hop and forwards the exchange with the identity:management-*
/// properties attached. A fixture that sends to those routes directly is therefore playing the facade,
/// and has to say which caller it plays — the routes refuse an exchange that carries no management
/// context at all, whatever transport it arrived on.
///
///
public enum ManagementCaller
{
/// A facade that validated a bearer carrying identity:manage: may target any user.
Admin,
///
/// No management context at all — what an in-process caller that never went through a facade looks
/// like. Only for tests that probe the gate itself.
///
None,
}
public static class ManagementCallerContext
{
public const string ScopesProperty = "identity:management-scopes";
///
/// Attaches what ManagementBearerAuthProcessor would have attached for .
///
public static T Apply(T exchange, ManagementCaller caller) where T : IExchange
{
switch (caller)
{
case ManagementCaller.Admin:
exchange.Properties[ScopesProperty] = new[] { IdentityScopes.Manage };
break;
case ManagementCaller.None:
exchange.Properties.Remove(ScopesProperty);
break;
}
return exchange;
}
}