public async Task UnlockUserTest() { var user = await CreateRandomUser(true); var client = new HttpClientAuthenticationHelper(_factory.CreateClient()); for (var i = 0; i < 5; i++) { await client.Login(user.UserName, "NotMyPAssword"); } Assert.IsFalse((await client.Login(user.UserName, user.Password)).Value, "The user should be locked out"); var adminUser = await CreateRandomUser(true); await client.Login(adminUser.UserName, adminUser.Password); var unlockResponse = await client.UnlockUser(adminUser.UserName); Assert.IsTrue(unlockResponse.Error.ContainsAll("You are not authorized for action", "claim is not set")); AddClaimToUser(adminUser.UserName, AuthenticationServiceClaims.UnlockUserClaim); var unlockResponseAfterSetClaim = await client.UnlockUser(user.UserName); Assert.IsFalse(unlockResponseAfterSetClaim.IsError); Assert.IsTrue((await client.Login(user.UserName, user.Password)).Value, "The user should be able to log in after the account has been unlocked."); }
public async Task MethodsThatNeedAuthorizationTest() { var client = new HttpClientAuthenticationHelper(_factory.CreateClient()); ShouldReturnUnathorized(await client.ChangeMyPassword("test", "test")); ShouldReturnUnathorized(await client.SetPassword("test", "test", false)); ShouldReturnUnathorized(await client.UnlockUser("test")); }
public async Task CheckForClaimsTest() { var client = new HttpClientAuthenticationHelper(_factory.CreateClient()); var user = await CreateRandomUser(true); await client.Login(user.UserName, user.Password); ShouldReturnRequiresClaim(await client.SetPassword(user.UserName, "test", false), AuthenticationServiceClaims.SetPasswordClaim); AddClaimToUser(user.UserName, AuthenticationServiceClaims.SetPasswordClaim); ShouldReturnRequiresClaim(await client.SetPassword(user.UserName, "test", true), AuthenticationServiceClaims.IgnorePasswordStrengthPolicyClaim); ShouldReturnRequiresClaim(await client.UnlockUser(user.UserName), AuthenticationServiceClaims.UnlockUserClaim); ShouldReturnRequiresClaim(await client.GeneratePasswordResetToken(user.UserName), AuthenticationServiceClaims.GeneratePasswordResetTokenClaim); }