public async Task CanAddLogins() { var loginInfo = new UserLoginInfo("loginProvider", "key-123", "Login Provider"); var user = await _store.FindByNameAsync(_user1.NormalizedUserName, CancellationToken.None); Assert.Empty(user.Logins); await _store.AddLoginAsync(user, loginInfo, CancellationToken.None); await SaveToElastic(user); user = await GetFromElastic(user.NormalizedUserName); Assert.NotEmpty(user.Logins); }
public async Task AddLogin_ShouldNotAdd_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")) }, Email = new ElasticConfirmation("*****@*****.**") }; var createResult = await store.CreateAsync(user, NoCancellationToken); await store.AddLoginAsync(user, new UserLoginInfo("prov1", "key1", "test1"), NoCancellationToken); var elasticUser = await store.FindByIdAsync(user.Id, NoCancellationToken); Assert.Equal(createResult, IdentityResult.Success); Assert.Equal(user.Logins.Count, 1); }