Class TestFederatedUserBuilder

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

Fluently creates a test principal with a primary Federation identity and an additional API-user identity.

public sealed class TestFederatedUserBuilder
Inheritance
TestFederatedUserBuilder
Inherited Members

Remarks

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

Constructors

TestFederatedUserBuilder(string)

Creates a federated test-user builder targeting the supplied application scheme.

public TestFederatedUserBuilder(string authenticationScheme = "IntegrationTest")

Parameters

authenticationScheme string

The non-empty simulated scheme targeted by the resulting principal. When omitted, the default XBullet test-authentication scheme is used.

Methods

Build()

Creates the Federation/API-user test principal definition.

public TestUser Build()

Returns

TestUser

A new user containing snapshots of the primary Federation identity, additional API-user identity, roles, claims, and ticket properties. Later builder changes do not modify it.

WithApiUserClaim(string, string)

Adds a claim to the additional API-user identity.

public TestFederatedUserBuilder WithApiUserClaim(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

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithApiUserIdentity(Action<TestIdentityBuilder>)

Configures the additional API-user identity.

public TestFederatedUserBuilder WithApiUserIdentity(Action<TestIdentityBuilder> configure)

Parameters

configure Action<TestIdentityBuilder>

The callback invoked synchronously once with the builder retained for the additional API-user identity. Repeated calls modify the same identity builder in call order. The callback is not retained.

Returns

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithAuthenticationProperty(string, string?)

Adds or replaces an authentication-ticket property.

public TestFederatedUserBuilder 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

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithFederationAuthenticationType(string)

Overrides the authentication type used for the Federation identity.

public TestFederatedUserBuilder WithFederationAuthenticationType(string authenticationType)

Parameters

authenticationType string

The non-empty authentication type exposed by the primary identity.

Returns

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithFederationClaim(string, string)

Adds a claim to the primary Federation identity.

public TestFederatedUserBuilder WithFederationClaim(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

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithName(string)

Sets the name exposed by the primary identity.

public TestFederatedUserBuilder WithName(string name)

Parameters

name string

The non-empty name-claim value for the primary Federation identity.

Returns

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithNameIdentifier(string)

Sets the subject identifier exposed by the primary identity.

public TestFederatedUserBuilder WithNameIdentifier(string nameIdentifier)

Parameters

nameIdentifier string

The non-empty name-identifier claim value for the primary Federation identity.

Returns

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithRole(string)

Adds a role to the primary Federation identity.

public TestFederatedUserBuilder WithRole(string role)

Parameters

role string

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

Returns

TestFederatedUserBuilder

This builder so additional identity values can be configured.

WithRoles(params string[])

Adds roles to the primary Federation identity.

public TestFederatedUserBuilder WithRoles(params string[] roles)

Parameters

roles string[]

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

Returns

TestFederatedUserBuilder

This builder so additional identity values can be configured.