Class TestUserBuilder

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

Fluently constructs an immutable TestUser.

public sealed class TestUserBuilder
Inheritance
TestUserBuilder
Inherited Members

Remarks

This mutable builder is not thread-safe. Each call to Build() returns a snapshot.

Methods

Build()

Creates the immutable user definition.

public TestUser Build()

Returns

TestUser

A new user containing snapshots of the builder's roles, claims, identities, and ticket properties. Later builder changes do not modify the returned user.

WithAuthenticationProperty(string, string?)

Adds or replaces an authentication-ticket property.

public TestUserBuilder WithAuthenticationProperty(string key, string? value)

Parameters

key string

The non-empty, ordinally compared property key.

value string

The property value, or null to store a property with a null value. Using an existing key replaces its value.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithAuthenticationScheme(string)

Targets an application-specific authentication scheme.

public TestUserBuilder WithAuthenticationScheme(string authenticationScheme)

Parameters

authenticationScheme string

The non-empty scheme name written to the transported user definition. Registration is not validated until the application processes a request.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithAuthenticationType(string)

Sets the authentication type exposed by the resulting claims identity.

public TestUserBuilder WithAuthenticationType(string authenticationType)

Parameters

authenticationType string

The non-empty value returned by the resulting identity's authentication-type property.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithClaim(string, string)

Adds a claim used by policy-based authorization.

public TestUserBuilder WithClaim(string type, string value)

Parameters

type string

The non-empty claim-type identifier.

value string

The non-null claim value; an empty value is accepted.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithIdentity(Action<TestIdentityBuilder>)

Adds another claims identity to the resulting principal.

public TestUserBuilder WithIdentity(Action<TestIdentityBuilder> configure)

Parameters

configure Action<TestIdentityBuilder>

The callback invoked synchronously once with a new identity builder. The built identity is snapshotted immediately; the callback and builder are not retained.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithName(string)

Sets the authenticated user's display name.

public TestUserBuilder WithName(string name)

Parameters

name string

The non-empty Name value.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithNameIdentifier(string)

Sets the value exposed through the name-identifier claim.

public TestUserBuilder WithNameIdentifier(string nameIdentifier)

Parameters

nameIdentifier string

The non-empty NameIdentifier value.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithRole(string)

Adds a role used by role-based authorization.

public TestUserBuilder WithRole(string role)

Parameters

role string

The non-empty role value to append. Duplicate roles are retained.

Returns

TestUserBuilder

This builder so additional identity values can be configured.

WithRoles(params string[])

Adds multiple roles used by role-based authorization.

public TestUserBuilder WithRoles(params string[] roles)

Parameters

roles string[]

The non-null role array to append in order. Every element must be non-empty; duplicate roles are retained. The builder copies the values and does not own the array.

Returns

TestUserBuilder

This builder so additional identity values can be configured.