IAppSurfaceAspNetCorePolicyEvaluator PolicyEvaluator { get; }
Source
Gets the host evaluator that continues to own real policy evaluation and result mapping.
Selects how the AppSurface test authentication scheme is registered with ASP.NET Core.
These modes exist so a test harness cannot silently change host authentication behavior. Use DefaultScheme for the quickest WebApplicationFactory path, NamedScheme when policies opt in to a specific scheme, and NoDefault when the test host must keep every existing default authentication setting untouched. The numeric values are explicit because this public enum may be persisted, serialized, or bound by applications. New values should be appended without changing the values documented here.
Holds the host policy evaluator registration that Auth.Testing decorates.
policyEvaluatorThe evaluator that was registered before AddAppSurfaceTestAuth installed test-only diagnostics.IAppSurfaceAspNetCorePolicyEvaluator PolicyEvaluator { get; }
Source
Gets the host evaluator that continues to own real policy evaluation and result mapping.
Exception thrown by framework-neutral AppSurface auth testing assertion helpers.
Stores the immutable per-factory persona lookup used by AppSurface test auth helpers.
Names use ordinal comparison and must be unique after AppSurfaceTestPersona trimming. Create the registry only after options are fully configured; later option changes are intentionally not observed by an existing registry.
AppSurfaceTestPersonaRegistry Create(AppSurfaceTestAuthOptions options)
Source
Creates a registry from configured personas and validates duplicate ordinal names.
optionsConfigured test auth options.An immutable registry snapshot.
InvalidOperationExceptionThrown when two personas share the same ordinal name.AppSurfaceTestPersona Require(string personaName)
Source
Gets a registered persona or throws a setup diagnostic for public helper failures.
personaNameOrdinal persona name. Leading and trailing whitespace is trimmed before lookup.The matching persona.
ArgumentExceptionThrown when personaName is blank.InvalidOperationExceptionThrown when the persona is not registered.bool TryGet(string? personaName, out AppSurfaceTestPersona persona)
Source
Attempts to get a persona by ordinal name without throwing for missing, blank, or null values.
personaNameOrdinal persona name. Leading and trailing whitespace is trimmed before lookup.personaThe matching persona when found.true when the persona exists; otherwise false.
Default names used by the AppSurface auth testing harness.
Request-level helpers for selecting AppSurface test auth personas.
HttpRequestMessage WithAppSurfaceTestPersona(this HttpRequestMessage request, string personaName)
Source
Selects a configured AppSurface test auth persona for a single request.
requestRequest to update.personaNameConfigured persona name to select.The same request for chaining.
Prefer CreateAppSurfaceClient(...) for whole-client persona selection. This helper is for tests that need several personas from one client. The harness still treats no selection as anonymous.
Describes one authenticated persona that the AppSurface auth testing harness can place on a request.
Persona names are matched with ordinal comparison. The subject is added with the configured subject claim type, and additional claims are copied into the generated principal. Do not put secrets, bearer tokens, cookies, or provider credentials in persona claims; this type models the already-authenticated principal a real ASP.NET Core handler would have produced.
string Name { get; }
Source
Gets the ordinal persona name.
string SubjectId { get; }
Source
Gets the subject identifier added to the generated principal.
IReadOnlyList<Claim> Claims { get; }
Source
Gets additional claim snapshots copied into the generated principal.
WebApplicationFactory helpers for AppSurface auth testing.
WebApplicationFactory<TEntryPoint> WithAppSurfaceTestAuth<TEntryPoint>(this WebApplicationFactory<TEntryPoint> factory, Action<AppSurfaceTestAuthOptions>? configure = null)
Source
Returns a WebApplicationFactory configured with AppSurface test authentication.
TEntryPointApplication entry point type used by WebApplicationFactory.factoryFactory to clone with test auth services.configureOptional test auth options callback.A cloned factory with AppSurface test auth registered.
The cloned factory uses the Testing environment and then registers the harness through AppSurfaceTestAuthServiceCollectionExtensions.AddAppSurfaceTestAuth.
HttpClient CreateAppSurfaceClient<TEntryPoint>(this WebApplicationFactory<TEntryPoint> factory, string personaName, WebApplicationFactoryClientOptions? options = null)
Source
Creates an HTTP client that selects a configured AppSurface test auth persona for every request.
TEntryPointApplication entry point type used by WebApplicationFactory.factoryFactory previously configured with WithAppSurfaceTestAuth{TEntryPoint}.personaNameConfigured persona name to select.optionsOptional WebApplicationFactory client options.A client whose default headers select the persona.
Configures the AppSurface auth testing harness.
Defaults are intentionally test-host oriented: the scheme name is stable, WebApplicationFactory quickstarts use the test scheme as the default, and production-like environments are blocked. Subject mapping is not changed unless SubjectClaimType is set.
AppSurfaceTestAuthOptions AddPersona(string name, string subjectId, IEnumerable<Claim>? claims = null)
Source
Adds a persona with the supplied subject and claims.
nameStable ordinal persona name.subjectIdStable host-owned subject identifier.claimsAdditional claims copied into the generated principal.The current options instance for chaining.
AppSurfaceTestAuthOptions AddPersona(AppSurfaceTestPersona persona)
Source
Adds a persona definition.
personaPersona to add to the registry.The current options instance for chaining.
string SchemeName { get; set; }
Source
Gets or sets the ASP.NET Core authentication scheme registered for test personas.
AppSurfaceTestAuthSchemeMode SchemeMode { get; set; }
Source
Gets or sets how the test scheme is applied to the host authentication setup.
string? SubjectClaimType { get; set; }
Source
Gets or sets the subject claim type used by generated principals and AppSurface subject mapping.
When this value is null, the harness leaves host AppSurface subject mapping alone and emits System.Security.Claims.ClaimTypes.NameIdentifier, matching the first default Auth.AspNetCore subject claim type.
bool AllowProductionEnvironmentForTestHost { get; set; }
Source
Gets or sets a value indicating whether the harness may run in a production-like environment.
Keep this false for normal tests. Set it only for production-like integration hosts that deliberately use test authentication and never receive real traffic.
IReadOnlyList<AppSurfaceTestPersona> Personas { get; }
Source
Gets the configured immutable persona definitions.
Framework-neutral assertion helpers for AppSurface auth results and ProblemDetails responses.
The helpers throw AppSurfaceTestAuthAssertionException instead of depending on a specific test framework. They are intended for package smoke tests, consumer examples, and teams that want stable AppSurface auth diagnostics without pulling xUnit into production package references.
AppSurfaceAuthResult HasOutcome(AppSurfaceAuthResult result, AppSurfaceAuthOutcome expectedOutcome, AppSurfaceAuthReason? expectedReason = null)
Source
Verifies an AppSurface auth result outcome and optional reason.
resultAuth result to inspect.expectedOutcomeExpected high-level outcome.expectedReasonOptional expected reason.The inspected result for fluent test code.
JsonElement HasProblemDetails(JsonElement problem, AppSurfaceAuthOutcome expectedOutcome, AppSurfaceAuthReason expectedReason, int expectedStatus, string? expectedPolicyName = null)
Source
Verifies AppSurface auth ProblemDetails extensions.
problemProblemDetails JSON element.expectedOutcomeExpected appsurfaceAuthOutcome extension value.expectedReasonExpected appsurfaceAuthReason extension value.expectedStatusExpected HTTP status in the ProblemDetails payload.expectedPolicyNameOptional expected appsurfacePolicyName extension value.The inspected JSON element for fluent test code.
Stable diagnostic codes emitted by the AppSurface auth testing harness.
Codes are safe to show in test output, troubleshooting documentation, and CI logs. They identify setup mistakes in the harness rather than production authentication decisions.
Registers AppSurface test authentication services for ASP.NET Core integration tests.
IServiceCollection AddAppSurfaceTestAuth(this IServiceCollection services, Action<AppSurfaceTestAuthOptions>? configure = null)
Source
Adds a test-only authentication scheme and immutable persona registry for AppSurface auth tests.
servicesService collection that receives the test harness.configureOptional test auth options callback.The same service collection for chaining.
This method composes ForgeTrust.AppSurface.Auth.AspNetCore so normal ASP.NET Core policy evaluation and AppSurface result mapping still run. It does not create production users, identity providers, cookies, tokens, or session freshness checks.
Decorates the host AppSurface policy evaluator with test-only persona diagnostics.
The inner evaluator remains responsible for real ASP.NET Core policy evaluation and AppSurface result mapping. This decorator pre-validates request-level persona selection from the private test transport and also converts late unknown-persona markers set by authentication handlers into setup failures after the inner evaluator runs.