Class TestAuthenticationSchemeBuilder

Namespace
XBullet.EasyTesting.Authentication
Assembly
XBullet.EasyTesting.dll

Maps test authentication profiles to scheme names used by the application.

public sealed class TestAuthenticationSchemeBuilder
Inheritance
TestAuthenticationSchemeBuilder
Inherited Members

Remarks

This mutable builder is configured once during test-factory initialization and is not thread-safe. Scheme names are matched using ordinal, case-sensitive comparison.

Methods

MapApiKey(string)

Maps API-key test identities to the application's API-key authentication scheme.

public TestAuthenticationSchemeBuilder MapApiKey(string authenticationScheme)

Parameters

authenticationScheme string

The non-empty application scheme selected for users built with TestApiKeyBuilder. Registration of the scheme is not validated here.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

MapAzureAd(string)

Maps Azure AD test identities to an application scheme such as Bearer.

public TestAuthenticationSchemeBuilder MapAzureAd(string authenticationScheme)

Parameters

authenticationScheme string

The non-empty application scheme selected for users built with TestAzureAdUserBuilder. Registration of the scheme is not validated here.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

MapFederation(string)

Maps Federation test identities to the application's authentication scheme.

public TestAuthenticationSchemeBuilder MapFederation(string authenticationScheme)

Parameters

authenticationScheme string

The non-empty application scheme selected for users built with TestFederatedUserBuilder. Registration of the scheme is not validated here.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

MapScheme(string)

Adds an application-specific authentication scheme handled by test identities.

public TestAuthenticationSchemeBuilder MapScheme(string authenticationScheme)

Parameters

authenticationScheme string

The non-empty application scheme that may accept simulated test-user headers. Adding an existing scheme again has no additional effect.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

MapTestAuthentication(string)

Adds a dedicated simulated-authentication scheme without changing an application scheme. Use this together with PreserveDefaultAuthenticationScheme() when simulated identities and the application's real authentication handlers must coexist.

public TestAuthenticationSchemeBuilder MapTestAuthentication(string authenticationScheme)

Parameters

authenticationScheme string

The non-empty, test-only scheme that accepts simulated identity headers. Adding an existing scheme again has no additional effect.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

PreserveDefaultAuthenticationScheme()

Keeps the default authentication, challenge, and forbid schemes selected by the application. Simulated identities remain available through mapped test schemes.

public TestAuthenticationSchemeBuilder PreserveDefaultAuthenticationScheme()

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

UseEndToEndApiKey(string, Action<TestApiKeyInjectionOptions>?)

Uses the application's real API-key authentication scheme and configures client-side key injection.

public TestAuthenticationSchemeBuilder UseEndToEndApiKey(string authenticationScheme, Action<TestApiKeyInjectionOptions>? configure = null)

Parameters

authenticationScheme string

The non-empty application scheme handled by the real API-key authentication handler. The scheme is removed from simulated-header handling and becomes the API-key client profile's target.

configure Action<TestApiKeyInjectionOptions>

The callback invoked synchronously once with new injection options. When null, header X-Api-Key, query parameter api_key, and a non-default scheme are used. The callback is not retained or invoked concurrently.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

UseEndToEndClientCertificate(string, Action<TestClientCertificateOptions>?)

Uses the application's real certificate authentication scheme and transports a certificate to TestServer. The application must register the named scheme with AddCertificate.

public TestAuthenticationSchemeBuilder UseEndToEndClientCertificate(string authenticationScheme, Action<TestClientCertificateOptions>? configure = null)

Parameters

authenticationScheme string

The non-empty, case-sensitive application scheme registered with AddCertificate. The scheme is removed from simulated-header handling.

configure Action<TestClientCertificateOptions>

The callback invoked synchronously once with new certificate-transport options. When null, the scheme does not replace the application's default. The callback is not retained or invoked concurrently.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

Exceptions

InvalidOperationException

The scheme is already registered for end-to-end client-certificate authentication.

UseEndToEndJwt(string, Action<TestJwtAuthorityOptions>?)

Uses the application's real JWT bearer scheme with tokens signed by a local test authority. The application must register the named scheme with AddJwtBearer.

public TestAuthenticationSchemeBuilder UseEndToEndJwt(string authenticationScheme, Action<TestJwtAuthorityOptions>? configure = null)

Parameters

authenticationScheme string

The non-empty, case-sensitive application scheme registered with AddJwtBearer. The scheme is removed from simulated-header handling and becomes the Azure AD client profile's target.

configure Action<TestJwtAuthorityOptions>

The callback invoked synchronously once with a new local-authority options instance. When null, the documented TestJwtAuthorityOptions defaults are used. The callback is not retained or invoked concurrently.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.

Exceptions

InvalidOperationException

The scheme is already registered for end-to-end JWT authentication, or its discovery or JWKS path conflicts with another local authority.

UseHybridDefaultAuthentication(string)

Uses a policy scheme that authenticates test-identity headers with the supplied simulated scheme and otherwise forwards to the application's original default authentication scheme. The application's original challenge and forbid schemes remain unchanged.

public TestAuthenticationSchemeBuilder UseHybridDefaultAuthentication(string testAuthenticationScheme)

Parameters

testAuthenticationScheme string

The non-empty, test-only scheme used when a request carries a simulated test-user header. Requests without that header are forwarded to the application's original default authentication scheme.

Returns

TestAuthenticationSchemeBuilder

This builder so additional authentication mappings can be configured.