Class TestAzureAdUserBuilder

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

Fluently creates an Azure AD-shaped test principal.

public sealed class TestAzureAdUserBuilder
Inheritance
TestAzureAdUserBuilder
Inherited Members

Remarks

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

Constructors

TestAzureAdUserBuilder(string)

Creates an Azure AD test-user builder targeting the supplied application scheme.

public TestAzureAdUserBuilder(string authenticationScheme = "IntegrationTest")

Parameters

authenticationScheme string

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

Methods

Build()

Creates the Azure AD-shaped test user.

public TestUser Build()

Returns

TestUser

A new user containing snapshots of the configured identifiers, scopes, roles, and custom claims. Later builder changes do not modify the returned user.

WithAppRole(string)

Adds an application role recognized by ASP.NET Core role authorization.

public TestAzureAdUserBuilder WithAppRole(string role)

Parameters

role string

The non-empty role added both to role authorization and as a roles claim. Duplicates are retained.

Returns

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithAppRoles(params string[])

Adds application roles recognized by ASP.NET Core role authorization.

public TestAzureAdUserBuilder WithAppRoles(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

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithClaim(string, string)

Adds a custom token claim.

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

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithClientId(string)

Sets the authorized-party application identifier.

public TestAzureAdUserBuilder WithClientId(string clientId)

Parameters

clientId string

The non-empty azp claim value. The value is not required to use GUID syntax.

Returns

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithName(string)

Sets the principal's display name.

public TestAzureAdUserBuilder WithName(string name)

Parameters

name string

The non-empty primary name-claim value.

Returns

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithObjectId(string)

Sets the Azure AD object identifier.

public TestAzureAdUserBuilder WithObjectId(string objectId)

Parameters

objectId string

The non-empty oid claim and primary name-identifier value. The value is not required to use GUID syntax.

Returns

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithPreferredUsername(string)

Sets the preferred username claim.

public TestAzureAdUserBuilder WithPreferredUsername(string preferredUsername)

Parameters

preferredUsername string

The non-empty preferred_username claim value. Email-address syntax is not required.

Returns

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithScope(string)

Adds a delegated permission to the space-delimited scp claim.

public TestAzureAdUserBuilder WithScope(string scope)

Parameters

scope string

The non-empty scope value to append. Values are joined with a single space when built; duplicates are retained.

Returns

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithScopes(params string[])

Adds delegated permissions to the space-delimited scp claim.

public TestAzureAdUserBuilder WithScopes(params string[] scopes)

Parameters

scopes string[]

The non-null scope 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

TestAzureAdUserBuilder

This builder so additional identity values can be configured.

WithTenantId(string)

Sets the Azure AD tenant identifier.

public TestAzureAdUserBuilder WithTenantId(string tenantId)

Parameters

tenantId string

The non-empty tid claim value. The value is not required to use GUID syntax.

Returns

TestAzureAdUserBuilder

This builder so additional identity values can be configured.