示例#1
0
        public void UserStorePublicNullCheckTest()
        {
            var store = new UserStore <IdentityUser>();

            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.CreateAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPasswordHashAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPasswordHashAsync(null, null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetSecurityStampAsync(null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.SetSecurityStampAsync(null, null)), "user");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.AddClaimAsync(new IdentityUser("fake"), null)), "claim");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.RemoveClaimAsync(new IdentityUser("fake"), null)), "claim");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.AddLoginAsync(new IdentityUser("fake"), null)), "login");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.RemoveLoginAsync(new IdentityUser("fake"), null)), "login");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.FindAsync(null)), "login");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetEmailAsync(null, null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPhoneNumberAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPhoneNumberAsync(null, null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)), "user");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)), "user");
            ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetTwoFactorEnabledAsync(null)),
                                               "user");
            ExceptionHelper.ThrowsArgumentNull(
                () => AsyncHelper.RunSync(() => store.SetTwoFactorEnabledAsync(null, true)), "user");
            ExceptionHelper.ThrowsArgumentNullOrEmpty(
                () => AsyncHelper.RunSync(() => store.AddToRoleAsync(new IdentityUser("fake"), null)), "roleName");
            ExceptionHelper.ThrowsArgumentNullOrEmpty(
                () => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(new IdentityUser("fake"), null)), "roleName");
            ExceptionHelper.ThrowsArgumentNullOrEmpty(
                () => AsyncHelper.RunSync(() => store.IsInRoleAsync(new IdentityUser("fake"), null)), "roleName");
        }
示例#2
0
        public async Task AddLoginAsync_CorrectUserAndLogin_LoginAdded()
        {
            var login = new UserLoginInfo("newLoginProvider", "newIdentityKey");
            var user  = new User(mMembershipFakeFactory.UserExternal);
            await mUserStore.AddLoginAsync(user, login);

            var logins = await mUserStore.GetLoginsAsync(user);

            Assert.AreEqual(2, logins.Count);
        }
示例#3
0
        public void ArgumentNullExceptions()
        {
            Assert.ThrowsAsync <ArgumentNullException>(() => _store.AddLoginAsync(null, new UserLoginInfo("x", "y", "z"), CancellationToken.None));
            Assert.ThrowsAsync <ArgumentNullException>(() => _store.AddLoginAsync(new ApplicationUser(), null, CancellationToken.None));

            Assert.ThrowsAsync <ArgumentNullException>(() => _store.FindByLoginAsync(null, "x", CancellationToken.None));
            Assert.ThrowsAsync <ArgumentNullException>(() => _store.FindByLoginAsync("x", null, CancellationToken.None));

            Assert.ThrowsAsync <ArgumentNullException>(() => _store.GetLoginsAsync(null, CancellationToken.None));

            Assert.ThrowsAsync <ArgumentNullException>(() => _store.RemoveLoginAsync(new ApplicationUser(), "x", null, CancellationToken.None));
            Assert.ThrowsAsync <ArgumentNullException>(() => _store.RemoveLoginAsync(new ApplicationUser(), null, "x", CancellationToken.None));
            Assert.ThrowsAsync <ArgumentNullException>(() => _store.RemoveLoginAsync(null, "x", "y", CancellationToken.None));
        }
示例#4
0
        public void UserStoreMethodsThrowWhenDisposedTest()
        {
            var db    = UnitTestHelper.CreateDefaultDb();
            var store = new UserStore <IdentityUser>(db);

            store.Dispose();
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(
                () => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindAsync(null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByIdAsync(null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByNameAsync(null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)));
            Assert.Throws <ObjectDisposedException>(
                () => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)));
            Assert.Throws <ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)));
            Assert.Throws <ObjectDisposedException>(
                () => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)));
            Assert.Throws <ObjectDisposedException>(
                () => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)));
        }
示例#5
0
 public void UserStoreMethodsThrowWhenDisposedTest()
 {
     var db = UnitTestHelper.CreateDefaultDb();
     var store = new UserStore<IdentityUser>(db);
     store.Dispose();
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByIdAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.FindByNameAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)));
     Assert.Throws<ObjectDisposedException>(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)));
     Assert.Throws<ObjectDisposedException>(
         () => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)));
 }
示例#6
0
        public async void FindAsync_GivenUserLoginInfo_ReturnsTheCorrectUser()
        {
            var applicationDatabaseConfiguration = new ApplicationDatabaseConfiguration();
            var userStore = new UserStore <User>(applicationDatabaseConfiguration);

            var user = new User
            {
                Email                  = "*****@*****.**",
                IsEmailConfirmed       = true,
                PasswordHash           = "PasswordHash",
                PhoneNumber            = "PhoneNumber",
                IsPhoneNumberConfirmed = true,
                IsTwoFactorEnabled     = false,
                LockoutEndDateUtc      = null,
                IsLockoutEnabled       = false,
                AccessFailedCount      = 0,
                UserName               = "******",
                IsAccountActive        = true
            };

            var userLoginInfo = new UserLoginInfo("loginProvider", "providerKey");

            await userStore.CreateAsync(user);

            await userStore.AddLoginAsync(user, userLoginInfo);

            var foundUser = await userStore.FindAsync(userLoginInfo);

            foundUser.Email.Should().Be("*****@*****.**");
        }
        public async Task UserStoreMethodsThrowWhenDisposedTest()
        {
            var db = CreateDb();

            var userOnlyStore = new UserOnlyStore(db);
            var store         = new UserStore(db, userOnlyStore);

            store.Dispose();
            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.AddClaimsAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.AddLoginAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.AddToRoleAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetClaimsAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetLoginsAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetRolesAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.IsInRoleAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.RemoveClaimsAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.RemoveLoginAsync(null, null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.RemoveFromRoleAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.RemoveClaimsAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.ReplaceClaimAsync(null, null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.FindByLoginAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.FindByIdAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.FindByNameAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.CreateAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.UpdateAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.DeleteAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.SetEmailConfirmedAsync(null, true));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetEmailConfirmedAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.SetPhoneNumberConfirmedAsync(null, true));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.GetPhoneNumberConfirmedAsync(null));
        }
        public async Task SqlUserStoreMethodsThrowWhenDisposedTest()
        {
            var store = new UserStore(new IdentityDbContext
                                          (TestEnvironment.Config[TestEnvironment.TestIdentityDbConnectionString]));

            store.Dispose();
            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.AddClaimsAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.AddLoginAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.AddToRoleAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetClaimsAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetLoginsAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetRolesAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.IsInRoleAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.RemoveClaimsAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.RemoveLoginAsync(null, null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.RemoveFromRoleAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.RemoveClaimsAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.ReplaceClaimAsync(null, null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.FindByLoginAsync(null, null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.FindByIdAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.FindByNameAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.CreateAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.UpdateAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.DeleteAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.SetEmailConfirmedAsync(null, true));

            await Assert.ThrowsAsync <ObjectDisposedException>(async() => await store.GetEmailConfirmedAsync(null));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.SetPhoneNumberConfirmedAsync(null, true));

            await Assert.ThrowsAsync <ObjectDisposedException>(
                async() => await store.GetPhoneNumberConfirmedAsync(null));
        }
    protected static async Task CreateUser(TContext context, TUser user)
    {
        using var userStore =
                  new UserStore <TUser, TRole, TContext, TKey, TUserClaim, TUserRole, TUserLogin, TUserToken, TRoleClaim>(context);
        using var roleStore = new RoleStore <TRole, TContext, TKey, TUserRole, TRoleClaim>(context);

        await userStore.CreateAsync(user);

        await userStore.AddClaimsAsync(user, new[] { new Claim("T1", "V1"), new Claim("T1", "V2"), new Claim("T2", "V3") });

        var adminRole = new TRole {
            NormalizedName = "admin", Name = "Admin"
        };
        await roleStore.CreateAsync(adminRole);

        await userStore.AddToRoleAsync(user, "admin");

        await roleStore.AddClaimAsync(adminRole, new Claim("AC1", "V1"));

        await roleStore.AddClaimAsync(adminRole, new Claim("AC2", "V1"));

        var moderatorRole = new TRole {
            NormalizedName = "moderator", Name = "Moderator"
        };
        await roleStore.CreateAsync(moderatorRole);

        await userStore.AddToRoleAsync(user, "moderator");

        await roleStore.AddClaimAsync(moderatorRole, new Claim("MC1", "V1"));

        await roleStore.AddClaimAsync(moderatorRole, new Claim("MC2", "V1"));

        await userStore.AddLoginAsync(user, new UserLoginInfo("ISCABBS", "DrDave", "SSHFTW"));

        await userStore.AddLoginAsync(user, new UserLoginInfo("Local", "EekyBear", "PPS"));

        await userStore.SetTokenAsync(user, "ISCABBS", "DrDave", "SSHFTW", CancellationToken.None);

        await context.SaveChangesAsync();
    }
示例#10
0
        public async Task Set_Get_and_Remove_AuthToken()
        {
            var user = await CreateNewUser();

            var userLoginInfo = GetUserLoginInfo();

            Assert.DoesNotThrowAsync(() => _store.AddLoginAsync(user, userLoginInfo, CancellationToken.None));

            Assert.DoesNotThrowAsync(() => _store.SetTokenAsync(user, userLoginInfo.LoginProvider, "TokenName", "TheValue", CancellationToken.None));
            Assert.AreEqual("TheValue", await _store.GetTokenAsync(user, userLoginInfo.LoginProvider, "TokenName", CancellationToken.None));

            Assert.DoesNotThrowAsync(() => _store.RemoveTokenAsync(user, userLoginInfo.LoginProvider, "TokenName", CancellationToken.None));
            Assert.IsNull(await _store.GetTokenAsync(user, userLoginInfo.LoginProvider, "TokenName", CancellationToken.None));
        }
示例#11
0
        public async void GetLogins_GivenAUser_ReturnsAllLoginsForUser()
        {
            var applicationDatabaseConfiguration = new ApplicationDatabaseConfiguration();
            var userStore = new UserStore <User>(applicationDatabaseConfiguration);

            var user = new User
            {
                Email                  = "*****@*****.**",
                IsEmailConfirmed       = true,
                PasswordHash           = "PasswordHash",
                PhoneNumber            = "PhoneNumber",
                IsPhoneNumberConfirmed = true,
                IsTwoFactorEnabled     = false,
                LockoutEndDateUtc      = null,
                IsLockoutEnabled       = false,
                AccessFailedCount      = 0,
                UserName               = "******",
                IsAccountActive        = true
            };

            await userStore.CreateAsync(user);

            await userStore.AddLoginAsync(user, new UserLoginInfo("loginProvider", "providerKey"));

            await userStore.AddLoginAsync(user, new UserLoginInfo("loginProvider1", "providerKey1"));

            var userLoginInfo = new UserLoginInfo("loginProvider2", "providerKey2");

            await userStore.AddLoginAsync(user, userLoginInfo);

            await userStore.RemoveLoginAsync(user, userLoginInfo);

            var logins = await userStore.GetLoginsAsync(user);

            logins.Should().HaveCount(2);
        }
        public void WhenRemoveLoginAsync()
        {
            var user = new IdentityUser("Lukz 03");
            var login = new UserLoginInfo("ProviderTest03", "ProviderKey03");
            var store = new UserStore<IdentityUser>(_session);
            store.AddLoginAsync(user, login);

            Assert.IsTrue(user.Logins.Any());

            var result = store.RemoveLoginAsync(user, login);

            var actual = _session.Query<IdentityUser>().FirstOrDefault(x => x.UserName == user.UserName);
            Assert.IsNull(result.Exception);
            Assert.IsFalse(actual.Logins.Any());
        }
        public void WhenAddLoginAsync()
        {
            var user = new IdentityUser("Lukz");
            var login = new UserLoginInfo("ProviderTest02", "ProviderKey02");
            var store = new UserStore<IdentityUser>(_session);
            var result = store.AddLoginAsync(user, login);

            var actual = _session.Query<IdentityUser>().FirstOrDefault(x => x.UserName == user.UserName);
            var userStored = store.FindAsync(login).Result;

            Assert.IsNull(result.Exception);
            Assert.IsNotNull(actual);
            Assert.AreEqual(user.UserName, actual.UserName);
            Assert.AreEqual(user.UserName, userStored.UserName);
        }
示例#14
0
        private (IdentityRole, IdentityClaim, IdentityExternalLogin, IdentityUser) CreateTestData(IGraphClient client,
                                                                                                  UserStore <IdentityUser> us, RoleStore <IdentityRole> rs)
        {
            var user = CreateUser(client, us);
            var role = CreateRole(client, rs);

            us.AddClaimsAsync(user, new[] { new Claim("TEST_CLAIM", "TEST_CLAIM_VALUE") }, default).Wait();
            us.AddLoginAsync(user, new UserLoginInfo("GOOGLE", "KEY", "XGOOGLE"), default).Wait();
            us.AddToRoleAsync(user, role.Name, default).Wait();
            var res = us.UpdateAsync(user, default).Result;

            Assert.True(res.Succeeded);
            user = FetchTestUser(client, us);
            return(role, user.Claims.FirstOrDefault(), user.Logins.FirstOrDefault(), user);
        }
        public void WhenAddLoginAsync()
        {
            var user  = new IdentityUser("Lukz");
            var login = new UserLoginInfo("ProviderTest02", "ProviderKey02");
            var store = new UserStore <IdentityUser>(_session);

            using (var ts = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                var result = store.AddLoginAsync(user, login);
                ts.Complete();
                Assert.IsNull(result.Exception);
            }

            var actual     = _session.Query <IdentityUser>().FirstOrDefault(x => x.UserName == user.UserName);
            var userStored = store.FindAsync(login).Result;

            Assert.IsNotNull(actual);
            Assert.AreEqual(user.UserName, actual.UserName);
            Assert.AreEqual(user.UserName, userStored.UserName);
        }
示例#16
0
        public async Task WhenRemoveLoginAsync()
        {
            var user  = new IdentityUser("Lukz 03");
            var login = new UserLoginInfo("ProviderTest03", "ProviderKey03", "ProviderTest03");
            var store = new UserStore <IdentityUser>(this._session);
            await store.AddLoginAsync(user, login);

            Assert.True(user.Logins.Any());

            using (var ts = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                await store.RemoveLoginAsync(user, login.LoginProvider, login.ProviderKey);

                ts.Complete();
            }

            var actual = await this._session.Query <IdentityUser>().FirstOrDefaultAsync(x => x.UserName == user.UserName);

            Assert.False(actual.Logins.Any());
        }
示例#17
0
        public async Task WhenAddLoginAsync()
        {
            var user  = new IdentityUser("Lukz");
            var login = new UserLoginInfo("ProviderTest02", "ProviderKey02", "ProviderTest02");
            var store = new UserStore <IdentityUser>(this._session);

            using (var ts = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                await store.AddLoginAsync(user, login);

                ts.Complete();
            }

            var actual = await this._session.Query <IdentityUser>().FirstOrDefaultAsync(x => x.UserName == user.UserName);

            var userStored = await store.FindByLoginAsync(login.LoginProvider, login.ProviderKey);

            Assert.NotNull(actual);
            Assert.Equal(user.UserName, actual.UserName);
            Assert.Equal(user.UserName, userStored.UserName);
        }
        public void WhenRemoveLoginAsync()
        {
            var user  = new IdentityUser("Lukz 03");
            var login = new UserLoginInfo("ProviderTest03", "ProviderKey03");
            var store = new UserStore <IdentityUser>(_session);

            store.AddLoginAsync(user, login);

            Assert.IsTrue(user.Logins.Any());

            using (var ts = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                var result = store.RemoveLoginAsync(user, login);
                ts.Complete();
                Assert.IsNull(result.Exception);
            }

            var actual = _session.Query <IdentityUser>().FirstOrDefault(x => x.UserName == user.UserName);

            Assert.IsFalse(actual.Logins.Any());
        }
示例#19
0
        public async Task CanFindUserByLoginInfoAsync()
        {
            var testUser = new SuperIdentityUser
            {
                UserName = "******",
                Email    = "*****@*****.**"
            };

            await _userStore.CreateAsync(testUser);

            var user = await _userStore.FindByEmailAsync(testUser.Email);

            Assert.IsNotNull(user);

            var loginInfo = new UserLoginInfo("ATestLoginProvider", "ATestKey292929");
            await _userStore.AddLoginAsync(user, loginInfo);

            var userByLoginInfo = await _userStore.FindAsync(loginInfo);

            Assert.IsNotNull(userByLoginInfo);
        }
示例#20
0
        private async Task MigrateUser(dynamic userData)
        {
            var userId = userData.UserID.ToString();
            var user   = await _userStore.FindByIdAsync(userId);

            if (user == null)
            {
                await _userStore.CreateAsync(new T { Id = userId });

                user = await _userStore.FindByIdAsync(userId);

                if (user == null)
                {
                    Logger.Error("Unable to create user: "******"New user, adding login info...");
                await _userStore.AddLoginAsync(user, new UserLoginInfo(_loginProvider, userId));
            }
            IList <Claim> existingClaims = await _userStore.GetClaimsAsync(user);

            var data = (IDictionary <string, object>)userData;

            foreach (var property in _properties)
            {
                var type = ProfileClaimNamespace + property.ToLower();
                if (existingClaims.Any(x => x.Type == type))
                {
                    await _userStore.RemoveClaimAsync(user, existingClaims.First(x => x.Type == type));

                    Logger.Trace("Existing claim removed: " + type);
                }
                var value = data[property]?.ToString() ?? "";
                await _userStore.AddClaimAsync(user, new Claim(type, value));
            }
        }
 public void Should_throw_ObjectDisposedException_if_disposed()
 {
     _target.Dispose();
     Assert.Throws <ObjectDisposedException>(() => _target.AddLoginAsync(new IdentityUser(), new UserLoginInfo("", "")));
 }
 public async Task AddLoginAsync([FromBody] AddLoginDto loginDto)
 {
     await _userStore.AddLoginAsync(
         loginDto.User,
         loginDto.UserLoginInfo);
 }
示例#23
0
        public async Task AddLoginAsync([FromBody] AddLoginDTO loginDto)
        {
            await _userStore.AddLoginAsync(loginDto.User, loginDto.UserLoginInfo);

            await _userStore.Context.SaveChangesAsync();
        }
示例#24
0
 public Task AddLoginAsync(IUser user, UserLoginInfo login)
 {
     return(_userStore.AddLoginAsync((MongoApplicationUser)user, login));
 }
示例#25
0
 public async Task AddLoginAsync([FromBody] AddLoginDTO login)
 {
     _logger.LogInformation("User {0} successfully logged in", login.User);
     await _userStore.AddLoginAsync(login.User, login.UserLoginInfo);
 }
示例#26
0
        public async Task UserStorePublicNullCheckTest()
        {
            Assert.Throws <ArgumentNullException>("factory",
                                                  () => new UserStore <IdentityUser>(null));
            var store = new UserStore <IdentityUser>(CreateTestContext());
            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetUserIdAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetUserNameAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.SetUserNameAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.CreateAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.UpdateAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.DeleteAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.AddClaimsAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.ReplaceClaimAsync(null, null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.RemoveClaimsAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetClaimsAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetLoginsAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetRolesAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.AddLoginAsync(null, null));

            await
            Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.RemoveLoginAsync(null, null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.AddToRoleAsync(null, null));

            await
            Assert.ThrowsAsync <ArgumentNullException>("user",
                                                       async() => await store.RemoveFromRoleAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.IsInRoleAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetPasswordHashAsync(null));

            await
            Assert.ThrowsAsync <ArgumentNullException>("user",
                                                       async() => await store.SetPasswordHashAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetSecurityStampAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user",
                                                             async() => await store.SetSecurityStampAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("login",
                                                             async() => await store.AddLoginAsync(new IdentityUser("fake"), null));

            await Assert.ThrowsAsync <ArgumentNullException>("claims",
                                                             async() => await store.AddClaimsAsync(new IdentityUser("fake"), null));

            await Assert.ThrowsAsync <ArgumentNullException>("claims",
                                                             async() => await store.RemoveClaimsAsync(new IdentityUser("fake"), null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetEmailConfirmedAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user",
                                                             async() => await store.SetEmailConfirmedAsync(null, true));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetEmailAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.SetEmailAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetPhoneNumberAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.SetPhoneNumberAsync(null, null));

            await Assert.ThrowsAsync <ArgumentNullException>("user",
                                                             async() => await store.GetPhoneNumberConfirmedAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user",
                                                             async() => await store.SetPhoneNumberConfirmedAsync(null, true));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetTwoFactorEnabledAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user",
                                                             async() => await store.SetTwoFactorEnabledAsync(null, true));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetAccessFailedCountAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetLockoutEnabledAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.SetLockoutEnabledAsync(null, false));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.GetLockoutEndDateAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user",
                                                             async() => await store.SetLockoutEndDateAsync(null, new DateTimeOffset()));

            await Assert.ThrowsAsync <ArgumentNullException>("user", async() => await store.ResetAccessFailedCountAsync(null));

            await Assert.ThrowsAsync <ArgumentNullException>("user",
                                                             async() => await store.IncrementAccessFailedCountAsync(null));

            await Assert.ThrowsAsync <ArgumentException>("normalizedRoleName",
                                                         async() => await store.AddToRoleAsync(new IdentityUser("fake"), null));

            await Assert.ThrowsAsync <ArgumentException>("normalizedRoleName",
                                                         async() => await store.RemoveFromRoleAsync(new IdentityUser("fake"), null));

            await Assert.ThrowsAsync <ArgumentException>("normalizedRoleName",
                                                         async() => await store.IsInRoleAsync(new IdentityUser("fake"), null));

            await Assert.ThrowsAsync <ArgumentException>("normalizedRoleName",
                                                         async() => await store.AddToRoleAsync(new IdentityUser("fake"), ""));

            await Assert.ThrowsAsync <ArgumentException>("normalizedRoleName",
                                                         async() => await store.RemoveFromRoleAsync(new IdentityUser("fake"), ""));

            await Assert.ThrowsAsync <ArgumentException>("normalizedRoleName",
                                                         async() => await store.IsInRoleAsync(new IdentityUser("fake"), ""));
        }
        public void AddRemoveUserLogin()
        {
            using (UserStore <IdentityUser> store = new UserStore <IdentityUser>())
            {
                using (UserManager <IdentityUser> manager = new UserManager <IdentityUser>(store))
                {
                    var user = GenTestUser();
                    WriteLineObject <IdentityUser>(user);
                    var taskUser = manager.CreateAsync(user, DefaultUserPassword);
                    taskUser.Wait();
                    Assert.IsTrue(taskUser.Result.Succeeded, string.Concat(taskUser.Result.Errors));

                    var loginInfo        = GenGoogleLogin();
                    var userAddLoginTask = manager.AddLoginAsync(user.Id, loginInfo);
                    userAddLoginTask.Wait();
                    Assert.IsTrue(userAddLoginTask.Result.Succeeded, string.Concat(userAddLoginTask.Result.Errors));

                    var loginGetTask = manager.GetLoginsAsync(user.Id);
                    loginGetTask.Wait();
                    Assert.IsTrue(loginGetTask.Result
                                  .Any(log => log.LoginProvider == loginInfo.LoginProvider
                                       & log.ProviderKey == loginInfo.ProviderKey), "LoginInfo not found: GetLoginsAsync");

                    var loginGetTask2 = manager.FindAsync(loginGetTask.Result.First());
                    loginGetTask2.Wait();
                    Assert.IsNotNull(loginGetTask2.Result, "LoginInfo not found: FindAsync");

                    var userRemoveLoginTaskNeg1 = manager.RemoveLoginAsync(user.Id, new UserLoginInfo(string.Empty, loginInfo.ProviderKey));
                    userRemoveLoginTaskNeg1.Wait();

                    var userRemoveLoginTaskNeg2 = manager.RemoveLoginAsync(user.Id, new UserLoginInfo(loginInfo.LoginProvider, string.Empty));
                    userRemoveLoginTaskNeg2.Wait();

                    var userRemoveLoginTask = manager.RemoveLoginAsync(user.Id, loginInfo);
                    userRemoveLoginTask.Wait();
                    Assert.IsTrue(userRemoveLoginTask.Result.Succeeded, string.Concat(userRemoveLoginTask.Result.Errors));
                    var loginGetTask3 = manager.GetLoginsAsync(user.Id);
                    loginGetTask3.Wait();
                    Assert.IsTrue(!loginGetTask3.Result.Any(), "LoginInfo not removed");

                    //Negative cases

                    var loginFindNeg = manager.FindAsync(new UserLoginInfo("asdfasdf", "http://4343443dfaksjfaf"));
                    loginFindNeg.Wait();
                    Assert.IsNull(loginFindNeg.Result, "LoginInfo found: FindAsync");

                    try
                    {
                        var t1 = store.AddLoginAsync(null, loginInfo);
                        t1.Wait();
                    }
                    catch (AggregateException aggex) {
                        aggex.ValidateAggregateException <ArgumentNullException>();
                    }

                    try
                    {
                        var t2 = store.AddLoginAsync(user, null);
                        t2.Wait();
                    }
                    catch (AggregateException aggex)
                    {
                        aggex.ValidateAggregateException <ArgumentNullException>();
                    }
                    try
                    {
                        var t3 = store.RemoveLoginAsync(null, loginInfo);
                        t3.Wait();
                    }
                    catch (ArgumentException) { }

                    try
                    {
                        var t4 = store.RemoveLoginAsync(user, null);
                        t4.Wait();
                    }
                    catch (ArgumentException) { }

                    try
                    {
                        var t5 = store.FindAsync(null);
                        t5.Wait();
                    }
                    catch (AggregateException aggex) {
                        aggex.ValidateAggregateException <ArgumentNullException>();
                    }
                    try
                    {
                        var t6 = store.GetLoginsAsync(null);
                        t6.Wait();
                    }
                    catch (ArgumentException) { }
                }
            }
        }
示例#28
0
        public async Task AddRemoveUserLogin(bool includeRoles)
        {
            UserStore <ApplicationUser, IdentityRole, IdentityCloudContext> store = CreateUserStore(includeRoles);
            UserManager <ApplicationUser> manager = CreateUserManager(includeRoles);

            var user = GenTestUser();

            WriteLineObject <IdentityUser>(user);
            var taskUser = await manager.CreateAsync(user, DefaultUserPassword);

            Assert.IsTrue(taskUser.Succeeded, string.Concat(taskUser.Errors));

            var loginInfo = GenGoogleLogin();

            user = await manager.FindByIdAsync(user.Id);

            var userAddLoginTask = await manager.AddLoginAsync(user, loginInfo);

            Assert.IsTrue(userAddLoginTask.Succeeded, string.Concat(userAddLoginTask.Errors));

            var loginGetTask = await manager.GetLoginsAsync(user);

            Assert.IsTrue(loginGetTask
                          .Any(log => log.LoginProvider == loginInfo.LoginProvider
                               & log.ProviderKey == loginInfo.ProviderKey), "LoginInfo not found: GetLoginsAsync");

            var loginGetTask2 = await manager.FindByLoginAsync(loginGetTask.First().LoginProvider, loginGetTask.First().ProviderKey);

            Assert.IsNotNull(loginGetTask2);

            var userRemoveLoginTaskNeg1 = await manager.RemoveLoginAsync(user, string.Empty, loginInfo.ProviderKey);

            var userRemoveLoginTaskNeg2 = await manager.RemoveLoginAsync(user, loginInfo.LoginProvider, string.Empty);

            var userRemoveLoginTask = await manager.RemoveLoginAsync(user, loginInfo.LoginProvider, loginInfo.ProviderKey);

            Assert.IsTrue(userRemoveLoginTask.Succeeded, string.Concat(userRemoveLoginTask.Errors));

            var loginGetTask3 = await manager.GetLoginsAsync(user);

            Assert.IsTrue(!loginGetTask3.Any(), "LoginInfo not removed");

            //Negative cases

            var loginFindNeg = await manager.FindByLoginAsync("asdfasdf", "http://4343443dfaksjfaf");

            Assert.IsNull(loginFindNeg);

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await store.AddLoginAsync(null, loginInfo));

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await store.AddLoginAsync(user, null));

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await store.RemoveLoginAsync(null, loginInfo.ProviderKey, loginInfo.LoginProvider));

            await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await store.GetLoginsAsync(null));
        }
示例#29
0
        public async Task <IHttpActionResult> AddLoginAsync(string userId, UserLoginInfo login)
        {
            await UserStore.AddLoginAsync(await UserStore.FindByIdAsync(userId), login);

            return(Ok());
        }
示例#30
0
        public async Task _02_CanDoCurd()
        {
            var user = new NHIdentityUser {
                UserName           = "******",
                NormalizedUserName = "******",
                Email                = "*****@*****.**",
                PhoneNumber          = "02000000000",
                PhoneNumberConfirmed = true,
                LockoutEnabled       = false,
                LockoutEnd           = null,
                AccessFailedCount    = 0,
                NormalizedEmail      = "*****@*****.**",
                PasswordHash         = null,
                SecurityStamp        = null
            };
            var result = await store.CreateAsync(user);

            Assert.True(result.Succeeded);
            var id = user.Id;

            Assert.IsNotEmpty(id);
            Assert.IsNotEmpty(user.ConcurrencyStamp);

            user.LockoutEnabled = true;
            user.LockoutEnd     = DateTimeOffset.UtcNow.AddMinutes(20);
            result = await store.UpdateAsync(user);

            Assert.True(result.Succeeded);

            var lockouts = await store.Users
                           .Where(u => u.LockoutEnabled)
                           .CountAsync();

            Assert.True(lockouts > 0);

            user = await store.FindByEmailAsync(user.NormalizedEmail);

            Assert.True(user.Id == id);

            user = await store.FindByNameAsync(user.NormalizedUserName);

            Assert.True(user.Id == id);

            user = await store.FindByIdAsync(id);

            Assert.True(user.Id == id);

            var claim = new Claim("Test", Guid.NewGuid().ToString("N"));
            await store.AddClaimsAsync(user, new [] { claim });

            var claims = await store.GetClaimsAsync(user);

            Assert.True(claims.Count > 0);

            var users = await store.GetUsersForClaimAsync(claim);

            Assert.IsNotEmpty(users);

            await store.RemoveClaimsAsync(user, claims);

            var loginInfo = new Microsoft.AspNetCore.Identity.UserLoginInfo(
                "test",
                Guid.NewGuid().ToString("N"),
                "Test"
                );
            await store.AddLoginAsync(user, loginInfo);

            await store.SetTokenAsync(
                user,
                loginInfo.LoginProvider,
                loginInfo.ProviderDisplayName,
                loginInfo.ProviderKey,
                CancellationToken.None
                );

            await store.RemoveTokenAsync(
                user,
                loginInfo.LoginProvider,
                loginInfo.ProviderDisplayName,
                CancellationToken.None
                );

            await store.RemoveLoginAsync(
                user,
                loginInfo.LoginProvider,
                loginInfo.ProviderKey
                );

            result = await store.DeleteAsync(user);

            Assert.True(result.Succeeded);
        }
示例#31
0
 public Task AddLoginAsync(IUser user, UserLoginInfo login, CancellationToken cancellationToken)
 {
     return(innerStore.AddLoginAsync((WrappedIdentityUser)user, login, cancellationToken));
 }
示例#32
0
 public async Task AddLoginAsync([FromBody] AddLoginDTO login)
 {
     await _UserStore.AddLoginAsync(login.User, login.UserLoginInfo);
 }
示例#33
0
        public async Task AddLoginAsync([FromBody] AddLoginDTO login, [FromServices] WebStoreDB db)
        {
            await _UserStore.AddLoginAsync(login.User, login.UserLoginInfo);

            await db.SaveChangesAsync();
        }
示例#34
0
 public void UserStorePublicNullCheckTest()
 {
     var store = new UserStore<IdentityUser>();
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.CreateAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.UpdateAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.DeleteAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddClaimAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveClaimAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetClaimsAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetLoginsAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetRolesAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddLoginAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveLoginAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.AddToRoleAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.IsInRoleAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPasswordHashAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPasswordHashAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetSecurityStampAsync(null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetSecurityStampAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.AddClaimAsync(new IdentityUser("fake"), null)), "claim");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.RemoveClaimAsync(new IdentityUser("fake"), null)), "claim");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.AddLoginAsync(new IdentityUser("fake"), null)), "login");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.RemoveLoginAsync(new IdentityUser("fake"), null)), "login");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.FindAsync(null)), "login");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailConfirmedAsync(null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetEmailConfirmedAsync(null, true)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetEmailAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetEmailAsync(null, null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetPhoneNumberAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.SetPhoneNumberAsync(null, null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.GetPhoneNumberConfirmedAsync(null)), "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetPhoneNumberConfirmedAsync(null, true)), "user");
     ExceptionHelper.ThrowsArgumentNull(() => AsyncHelper.RunSync(() => store.GetTwoFactorEnabledAsync(null)),
         "user");
     ExceptionHelper.ThrowsArgumentNull(
         () => AsyncHelper.RunSync(() => store.SetTwoFactorEnabledAsync(null, true)), "user");
     ExceptionHelper.ThrowsArgumentNullOrEmpty(
         () => AsyncHelper.RunSync(() => store.AddToRoleAsync(new IdentityUser("fake"), null)), "roleName");
     ExceptionHelper.ThrowsArgumentNullOrEmpty(
         () => AsyncHelper.RunSync(() => store.RemoveFromRoleAsync(new IdentityUser("fake"), null)), "roleName");
     ExceptionHelper.ThrowsArgumentNullOrEmpty(
         () => AsyncHelper.RunSync(() => store.IsInRoleAsync(new IdentityUser("fake"), null)), "roleName");
 }