Class TestJwtAuthorityOptions

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

Configures the local JWT authority used by end-to-end authentication tests.

public sealed class TestJwtAuthorityOptions
Inheritance
TestJwtAuthorityOptions
Inherited Members

Properties

Audience

Gets or sets the default token audience.

public string Audience { get; set; }

Property Value

string

The non-empty audience used for token creation and validation. The default is xbullet-easytesting.

ClockSkew

Gets or sets the validation clock skew.

public TimeSpan ClockSkew { get; set; }

Property Value

TimeSpan

A non-negative tolerance applied to lifetime validation. The default is Zero. Directly assigned values are validated when the authority is registered or created.

DiscoveryPath

Gets or sets the OIDC discovery endpoint path exposed by the test host.

public string DiscoveryPath { get; set; }

Property Value

string

A non-empty application path. The default is /.well-known/openid-configuration. A missing leading slash is added when the path is used.

Issuer

Gets or sets the default token issuer.

public string Issuer { get; set; }

Property Value

string

The non-empty issuer string used for metadata, token creation, and validation. The default is https://xbullet.easytesting.test.

JwksPath

Gets or sets the JWKS endpoint path exposed by the test host.

public string JwksPath { get; set; }

Property Value

string

A non-empty application path. The default is /.well-known/jwks.json. A missing leading slash is added when the path is used.

SaveToken

Gets or sets whether the validated bearer token is saved in authentication properties.

public bool SaveToken { get; set; }

Property Value

bool

true to save a successfully validated bearer token in the authentication ticket; otherwise, false. The default is false.

TokenLifetime

Gets or sets the default lifetime of newly created tokens.

public TimeSpan TokenLifetime { get; set; }

Property Value

TimeSpan

A positive duration measured from token build time. The default is five minutes. Directly assigned values are validated when the authority is registered or created.

UseAsDefaultScheme

Gets or sets whether this scheme becomes the host's default authentication scheme.

public bool UseAsDefaultScheme { get; set; }

Property Value

bool

true to replace the host's default authentication scheme with this JWT scheme; false to preserve the existing default. The default is true.

Methods

SaveAccessToken()

Saves validated access tokens in the real handler's authentication properties.

public TestJwtAuthorityOptions SaveAccessToken()

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.

WithAudience(string)

Sets the default audience.

public TestJwtAuthorityOptions WithAudience(string audience)

Parameters

audience string

The non-empty audience used for token creation and validation.

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.

Exceptions

ArgumentException

audience is empty or whitespace.

WithClockSkew(TimeSpan)

Sets the validation clock skew.

public TestJwtAuthorityOptions WithClockSkew(TimeSpan clockSkew)

Parameters

clockSkew TimeSpan

The non-negative tolerance applied to not-before and expiration validation. Use Zero for exact boundary checks.

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.

Exceptions

ArgumentOutOfRangeException

clockSkew is negative.

WithDiscoveryPath(string)

Sets the discovery endpoint path exposed by the test host.

public TestJwtAuthorityOptions WithDiscoveryPath(string discoveryPath)

Parameters

discoveryPath string

The non-empty application path. A leading slash is added when omitted.

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.

Exceptions

ArgumentException

discoveryPath is empty or whitespace.

WithIssuer(string)

Sets the default issuer.

public TestJwtAuthorityOptions WithIssuer(string issuer)

Parameters

issuer string

The non-empty issuer string. Trailing slash characters are removed; the remaining value is not otherwise normalized or validated as a URI.

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.

Exceptions

ArgumentException

issuer is empty or whitespace.

WithJwksPath(string)

Sets the JWKS endpoint path exposed by the test host.

public TestJwtAuthorityOptions WithJwksPath(string jwksPath)

Parameters

jwksPath string

The non-empty application path. A leading slash is added when omitted.

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.

Exceptions

ArgumentException

jwksPath is empty or whitespace.

WithTokenLifetime(TimeSpan)

Sets the default token lifetime.

public TestJwtAuthorityOptions WithTokenLifetime(TimeSpan tokenLifetime)

Parameters

tokenLifetime TimeSpan

The positive duration added to token build time when no explicit expiration is configured.

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.

Exceptions

ArgumentOutOfRangeException

tokenLifetime is zero or negative.

WithoutDefaultScheme()

Prevents this JWT scheme from replacing the application's default scheme.

public TestJwtAuthorityOptions WithoutDefaultScheme()

Returns

TestJwtAuthorityOptions

This options instance so additional settings can be configured.