Class TestUser

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

Describes the identity attached to one integration-test request.

public sealed record TestUser : IEquatable<TestUser>
Inheritance
TestUser
Implements
Inherited Members

Properties

AdditionalIdentities

Gets additional identities attached to the resulting principal.

public IReadOnlyCollection<TestIdentity> AdditionalIdentities { get; init; }

Property Value

IReadOnlyCollection<TestIdentity>

Additional claims identities appended after the primary identity. The default is an empty collection.

AuthenticationProperties

Gets authentication-ticket properties exposed by the simulated handler.

public IReadOnlyDictionary<string, string?> AuthenticationProperties { get; init; }

Property Value

IReadOnlyDictionary<string, string>

Ticket-property values keyed with ordinal comparison. Values may be null. The default dictionary is empty.

AuthenticationScheme

Gets the application authentication scheme this identity targets.

public string AuthenticationScheme { get; init; }

Property Value

string

The scheme selected by the simulated authentication handler. The default is AuthenticationScheme.

AuthenticationType

Gets the authentication type exposed by the resulting claims identity.

public string AuthenticationType { get; init; }

Property Value

string

The value returned by AuthenticationType. The default is AuthenticationScheme.

Claims

Gets additional claims used by policy-based authorization.

public IReadOnlyCollection<TestClaim> Claims { get; init; }

Property Value

IReadOnlyCollection<TestClaim>

Claims appended after the built-in name, name-identifier, and role claims. The default is an empty collection.

Name

Gets the authenticated user's display name.

public string Name { get; init; }

Property Value

string

integration-test-user by default.

NameIdentifier

Gets the value exposed through NameIdentifier.

public string NameIdentifier { get; init; }

Property Value

string

A per-instance GUID in N format by default.

Roles

Gets the roles used by role-based authorization.

public IReadOnlyCollection<string> Roles { get; init; }

Property Value

IReadOnlyCollection<string>

The role values converted to Role claims. The default is an empty collection.

Methods

Create(string, string?, IEnumerable<string>?, IEnumerable<TestClaim>?, string, string)

Creates a test user with optional roles and claims.

public static TestUser Create(string name = "integration-test-user", string? nameIdentifier = null, IEnumerable<string>? roles = null, IEnumerable<TestClaim>? claims = null, string authenticationScheme = "IntegrationTest", string authenticationType = "IntegrationTest")

Parameters

name string

The display-name claim value. When omitted, integration-test-user is used. This method does not normalize or validate the value.

nameIdentifier string

The name-identifier claim value. When null, a new GUID in N format is generated.

roles IEnumerable<string>

Role values to copy into the user. When null, no roles are added. The returned user owns the copied collection.

claims IEnumerable<TestClaim>

Additional claims to copy into the user. When null, no additional claims are added. The returned user owns the copied collection.

authenticationScheme string

The target application scheme. When omitted, the default simulated scheme is used. This method does not validate that the scheme is registered.

authenticationType string

The authentication type exposed by the resulting identity. When omitted, the default simulated scheme name is used.

Returns

TestUser

A new immutable test-user definition containing snapshots of the supplied values.

CreateBuilder()

Starts a fluent test-user definition.

public static TestUserBuilder CreateBuilder()

Returns

TestUserBuilder

A new mutable builder initialized with the default simulated identity values.