Class TestUserStore
- Namespace
- Fdyay.IdentityServer.Test
- Assembly
- Fdyay.IdentityServer.Core.dll
An in-memory ITestUserStore. Intended for development and testing only.
public sealed class TestUserStore : ITestUserStore
- Inheritance
-
TestUserStore
- Implements
- Inherited Members
Constructors
TestUserStore(IEnumerable<TestUser>)
Creates the store holding a copy of users.
public TestUserStore(IEnumerable<TestUser> users)
Parameters
usersIEnumerable<TestUser>The initial users. The store keeps its own list, so later changes to this sequence are not seen.
Methods
AutoProvisionUser(string, string, IEnumerable<Claim>)
Creates and links a new local user from an external provider identity.
public TestUser AutoProvisionUser(string provider, string providerSubjectId, IEnumerable<Claim> claims)
Parameters
providerstringproviderSubjectIdstringclaimsIEnumerable<Claim>
Returns
Remarks
The new user gets a random subject id, the provider's claims less any sub, and as username the name
claim, else Name, else providerSubjectId. It has no password.
CreateUser(string, string, string?, string?)
Adds a local user with a password, for a development registration page. Duende's.
public TestUser CreateUser(string username, string password, string? name = null, string? email = null)
Parameters
usernamestringThe new user's username, which no user may have already.
passwordstringThe password, kept as given: this store is for development only.
namestringThe user's name, carried as a Name claim when given.
emailstringThe user's email address, carried as a Email claim when given.
Returns
Remarks
Duende 8.0.1's, measured: the subject 32 random bytes in hex, the name and email as claims when given, refused with "That username already exists." Where ours differs: taken means what FindByUsername(string) finds, ignoring case, where Duende's compares ordinally — two users whose names differ only in case would sign in as the first — and the refusal is an InvalidOperationException rather than an Exception.
Exceptions
- InvalidOperationException
A user already has
username.
FindByExternalProvider(string, string)
Finds a user previously linked to an external provider identity.
public TestUser? FindByExternalProvider(string provider, string providerSubjectId)
Parameters
Returns
FindBySubjectId(string)
Finds a user by subject identifier.
public TestUser? FindBySubjectId(string subjectId)
Parameters
subjectIdstringThe subject identifier, the
subclaim.
Returns
- TestUser
The user, or
nullwhen there is none.
Remarks
Compared ordinally.
FindByUsername(string)
Finds a user by username.
public TestUser? FindByUsername(string username)
Parameters
usernamestringThe username.
Returns
- TestUser
The user, or
nullwhen there is none.
Remarks
Compared ignoring case.
ValidateCredentials(string, string)
Checks a username and password for a local sign-in.
public TestUser? ValidateCredentials(string username, string password)
Parameters
Returns
- TestUser
The user, when the user is active and the password matches; otherwise
null.
Remarks
The username is matched ignoring case and the password ordinally; a user without a password (an external-only user) never validates.