public void SetToken_ReplacesValue() { var user = new IdentityUser(); user.SetToken("loginProvider", "tokenName", "tokenValue"); user.SetToken("loginProvider", "tokenName", "updatedValue"); Assert.Equal(1, user.Tokens.Count); Assert.Equal("updatedValue", user.GetTokenValue("loginProvider", "tokenName")); }
public void SetToken_ReplacesValue() { var user = new IdentityUser(); user.SetToken("loginProvider", "tokenName", "tokenValue"); user.SetToken("loginProvider", "tokenName", "updatedValue"); Expect(user.Tokens.Count, Is.EqualTo(1)); Expect(user.GetTokenValue("loginProvider", "tokenName"), Is.EqualTo("updatedValue")); }
public void GetToken_WithToken_ReturnsValueIfProviderAndNameMatch() { var user = new IdentityUser(); user.SetToken("loginProvider", "tokenName", "tokenValue"); Assert.Equal("tokenValue", user.GetTokenValue("loginProvider", "tokenName")); // "GetToken should match on both provider and name, but isn't" Assert.Null(user.GetTokenValue("wrongProvider", "tokenName")); // "GetToken should match on loginProvider, but isn't" Assert.Null(user.GetTokenValue("loginProvider", "wrongName")); // "GetToken should match on tokenName, but isn't" }
public void RemoveToken_OnlyRemovesIfNameAndProviderMatch() { var user = new IdentityUser(); user.SetToken("loginProvider", "tokenName", "tokenValue"); user.RemoveToken("wrongProvider", "tokenName"); Assert.Equal("tokenValue", user.GetTokenValue("loginProvider", "tokenName")); // "RemoveToken should match on loginProvider, but isn't" user.RemoveToken("loginProvider", "wrongName"); Assert.Equal("tokenValue", user.GetTokenValue("loginProvider", "tokenName")); // "RemoveToken should match on tokenName, but isn't" user.RemoveToken("loginProvider", "tokenName"); Assert.Null(user.GetTokenValue("loginProvider", "tokenName")); // "RemoveToken should match on both loginProvider and tokenName, but isn't" }
public void GetToken_WithToken_ReturnsValueIfProviderAndNameMatch() { var user = new IdentityUser(); user.SetToken("loginProvider", "tokenName", "tokenValue"); Expect(user.GetTokenValue("loginProvider", "tokenName"), Is.EqualTo("tokenValue"), "GetToken should match on both provider and name, but isn't"); Expect(user.GetTokenValue("wrongProvider", "tokenName"), Is.Null, "GetToken should match on loginProvider, but isn't"); Expect(user.GetTokenValue("loginProvider", "wrongName"), Is.Null, "GetToken should match on tokenName, but isn't"); }
public void RemoveToken_OnlyRemovesIfNameAndProviderMatch() { var user = new IdentityUser(); user.SetToken("loginProvider", "tokenName", "tokenValue"); user.RemoveToken("wrongProvider", "tokenName"); Expect(user.GetTokenValue("loginProvider", "tokenName"), Is.EqualTo("tokenValue"), "RemoveToken should match on loginProvider, but isn't"); user.RemoveToken("loginProvider", "wrongName"); Expect(user.GetTokenValue("loginProvider", "tokenName"), Is.EqualTo("tokenValue"), "RemoveToken should match on tokenName, but isn't"); user.RemoveToken("loginProvider", "tokenName"); Expect(user.GetTokenValue("loginProvider", "tokenName"), Is.Null, "RemoveToken should match on both loginProvider and tokenName, but isn't"); }
public UserStoreTests(MongoHelper mongoHelper) { testUser = new IdentityUser { Id = Guid.NewGuid().ToString(), Name = "name", NormalizedName = "normalizedName", PasswordHash = "hashypash", Email = "*****@*****.**", NormalizedEmail = "*****@*****.**", EmailConfirmed = true, SecurityStamp = "stampy", LockoutEndDate = new DateTimeOffset(DateTime.Now), PhoneNumber = "222222222222" }; testUser.AddLogin(new PersistedUserLoginInfo("gwar", "123")); testUser.AddClaim(new PersistedClaim("test", "data")); testUser.SetToken(new AuthToken("goog.goo", "garbage", "data")); testUser.AddToRole("blarg"); db = mongoHelper.Database; usersCollection = mongoHelper.Users; userStore = new MongoUserStore <IdentityUser>(usersCollection); }
private async Task AddUsers() { var adminUser = new IdentityUser(_guidGenerator.Create(), "administrator", "*****@*****.**"); adminUser.AddRole(_adminRole.Id); adminUser.AddClaim(_guidGenerator, new Claim("TestClaimType", "42")); await _userRepository.InsertAsync(adminUser); var john = new IdentityUser(_testData.UserJohnId, "john.nash", "*****@*****.**"); john.AddRole(_moderatorRole.Id); john.AddRole(_supporterRole.Id); john.AddOrganizationUnit(_ou111.Id); john.AddOrganizationUnit(_ou112.Id); john.AddLogin(new UserLoginInfo("github", "john", "John Nash")); john.AddLogin(new UserLoginInfo("twitter", "johnx", "John Nash")); john.AddClaim(_guidGenerator, new Claim("TestClaimType", "42")); john.SetToken("test-provider", "test-name", "test-value"); await _userRepository.InsertAsync(john); var david = new IdentityUser(_testData.UserDavidId, "david", "*****@*****.**"); david.AddOrganizationUnit(_ou112.Id); await _userRepository.InsertAsync(david); var neo = new IdentityUser(_testData.UserNeoId, "neo", "*****@*****.**"); neo.AddRole(_supporterRole.Id); neo.AddClaim(_guidGenerator, new Claim("TestClaimType", "43")); neo.AddOrganizationUnit(_ou111.Id); await _userRepository.InsertAsync(neo); var bob = new IdentityUser(_testData.UserBobId, "bob", "*****@*****.**"); bob.SetIsActive(false); await _userManager.CreateAsync(bob, "1q2w3E*"); }