Path: redb-identity/tests/redb.Identity.Web.Tests/IsolationTests.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.Web.Tests/IsolationTests.cs ---- using System.Linq; using AwesomeAssertions; using Xunit; namespace redb.Identity.Web.Tests; /// /// Enforces the BFF isolation HARDLINE at runtime (in addition to the /// CI workflow at .github/workflows/identity-web-isolation.yml). /// /// redb.Identity.Web is contractually limited to consuming the public SDK /// surface — redb.Identity.Contracts and redb.Identity.Client. /// Pulling any other redb.Identity.* assembly into the Web binary /// breaks the "BFF talks to identity-server over HTTP" boundary and is a /// regression. /// /// /// This test inspects the actual referenced assemblies of the Web build /// output, so it catches the violation even if the CI grep over csproj/ /// using statements is bypassed (e.g. via a transitive package alias). /// /// public class IsolationTests { private static readonly string[] AllowedIdentityRefs = [ "redb.Identity.Contracts", "redb.Identity.Client", ]; [Fact] public void Web_AssemblyReferences_StayWithinSdkBoundary() { var webAssembly = typeof(Program).Assembly; var identityRefs = webAssembly .GetReferencedAssemblies() .Select(n => n.Name ?? string.Empty) .Where(n => n.StartsWith("redb.Identity", StringComparison.Ordinal)) .OrderBy(n => n, StringComparer.Ordinal) .ToArray(); var violations = identityRefs .Where(n => !AllowedIdentityRefs.Contains(n, StringComparer.Ordinal)) .ToArray(); violations.Should().BeEmpty( "redb.Identity.Web MUST only reference {0}; found forbidden refs: {1}. " + "The BFF talks to Identity only through Contracts and Client.", string.Join(", ", AllowedIdentityRefs), string.Join(", ", violations)); } }