using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace Bit.Identity.Test.Wrappers; public class UserManagerTestWrapper : UserManager where TUser : class { /// /// Modify this value to mock the responses from UserManager.GetTwoFactorEnabledAsync() /// public bool TWO_FACTOR_ENABLED { get; set; } = false; /// /// Modify this value to mock the responses from UserManager.GetValidTwoFactorProvidersAsync() /// public IList TWO_FACTOR_PROVIDERS { get; set; } = []; /// /// Modify this value to mock the responses from UserManager.GenerateTwoFactorTokenAsync() /// public string TWO_FACTOR_TOKEN { get; set; } = string.Empty; /// /// Modify this value to mock the responses from UserManager.VerifyTwoFactorTokenAsync() /// public bool TWO_FACTOR_TOKEN_VERIFIED { get; set; } = false; /// /// Modify this value to mock the responses from UserManager.SupportsUserTwoFactor /// public bool SUPPORTS_TWO_FACTOR { get; set; } = false; public override bool SupportsUserTwoFactor { get { return SUPPORTS_TWO_FACTOR; } } public UserManagerTestWrapper( IUserStore store, IOptions optionsAccessor, IPasswordHasher passwordHasher, IEnumerable> userValidators, IEnumerable> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger> logger) : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger) { } /// /// return class variable TWO_FACTOR_ENABLED /// /// /// public override async Task GetTwoFactorEnabledAsync(TUser user) { return TWO_FACTOR_ENABLED; } /// /// return class variable TWO_FACTOR_PROVIDERS /// /// /// public override async Task> GetValidTwoFactorProvidersAsync(TUser user) { return TWO_FACTOR_PROVIDERS; } /// /// return class variable TWO_FACTOR_TOKEN /// /// /// /// public override async Task GenerateTwoFactorTokenAsync(TUser user, string tokenProvider) { return TWO_FACTOR_TOKEN; } /// /// return class variable TWO_FACTOR_TOKEN_VERIFIED /// /// /// /// /// public override async Task VerifyTwoFactorTokenAsync(TUser user, string tokenProvider, string token) { return TWO_FACTOR_TOKEN_VERIFIED; } }