public async Task RemoveLogin_Test() { var store = new ElasticUserStore <ElasticUser, ElasticRole>(_nestClient, new ElasticOptions { UsersIndex = _userIndex }); var user = new ElasticUser { UserName = "******", PasswordHash = "phash", Logins = new List <ElasticUserLogin> { new ElasticUserLogin(new UserLoginInfo("prov1", "key1", "test1")), new ElasticUserLogin(new UserLoginInfo("prov2", "key2", "test2")) }, Email = new ElasticConfirmation("*****@*****.**") }; var createResult = await store.CreateAsync(user, NoCancellationToken); await store.RemoveLoginAsync(user, "prov1", "key1", NoCancellationToken); await store.UpdateAsync(user, NoCancellationToken); var elasticUser = await store.FindByIdAsync(user.Id, NoCancellationToken); Assert.Equal(createResult, IdentityResult.Success); Assert.Equal(elasticUser.Logins.Count, 1); }
public async Task CanRemoveLogin() { var loginInfo = new UserLoginInfo("loginProvider", "key-123", "Login Provider"); ElasticIdentityUser noLoginsUser = new ElasticIdentityUser(nameof(noLoginsUser)); await _store.AddLoginAsync(noLoginsUser, loginInfo, CancellationToken.None); await _store.CreateAsync(noLoginsUser, CancellationToken.None); var user = await _store.FindByNameAsync(noLoginsUser.NormalizedUserName, CancellationToken.None); Assert.NotEmpty(user.Logins); await _store.RemoveLoginAsync(user, loginInfo.LoginProvider, loginInfo.ProviderKey, CancellationToken.None); await SaveToElastic(user); user = await GetFromElastic(user.NormalizedUserName); Assert.Empty(user.Logins); }