public void ForgotPasswordShouldSucceed() { UserTestTools.ClearAllUserInfo(); string userName = MethodBase.GetCurrentMethod().Name; string email = "*****@*****.**"; UserTestTools.SignUp(userName, email); User user = User.GetByEmail(email); Expect.AreEqual(0, user.PasswordResetsByUserId.Count); UserManager userMgr = UserTestTools.CreateTestUserManager("Stickerize"); userMgr.HttpContext = A.Fake <IHttpContext>(); userMgr.HttpContext.Request = new TestRequest(); ForgotPasswordResponse response = userMgr.ForgotPassword(email); Expect.IsTrue(response.Success); }
public void ForgotPasswordShouldCreatePasswordResetEntry() { string userName = MethodBase.GetCurrentMethod().Name; string email = "*****@*****.**"; UserTestTools.SignUp(userName, email); User user = User.GetByEmail(email); Expect.AreEqual(0, user.PasswordResetsByUserId.Count); UserManager userMgr = UserTestTools.CreateTestUserManager("Stickerize"); userMgr.HttpContext = A.Fake <IHttpContext>(); userMgr.HttpContext.Request = new TestRequest(); userMgr.ForgotPassword(email); user.PasswordResetsByUserId.Reload(); Expect.AreEqual(1, user.PasswordResetsByUserId.Count); }
public void ResetPasswordShouldBeLoginnable() { string userName = MethodBase.GetCurrentMethod().Name; string email = "*****@*****.**"; UserTestTools.SignUp(userName, email); User user = User.GetByEmail(email); Expect.AreEqual(0, user.PasswordResetsByUserId.Count); UserManager userMgr = UserTestTools.CreateTestUserManager("Stickerize"); userMgr.HttpContext = A.Fake <IHttpContext>(); userMgr.HttpContext.Request = new TestRequest(); string password = ServiceProxySystem.GenerateId(); ForgotPasswordResponse forgot = userMgr.ForgotPassword(email); PasswordResetResponse reset = userMgr.ResetPassword(password.Sha1(), (string)forgot.Data); LoginResponse login = userMgr.Login(user.UserName, password.Sha1()); Expect.IsTrue(login.Success, "Login failed"); }