Пример #1
0
        public void Change_Password_ShouldWork()
        {
            var userInfo = ((ClaimsPrincipal)MockControllerContext.Object.HttpContext.User);
            var unAuthenticatedClaims = new ClaimsIdentity(userInfo.Claims, "cookie");

            unAuthenticatedClaims.AddClaim(new Claim(AHP.Core.ClaimTypes.MustChangePassword, bool.TrueString));
            unAuthenticatedClaims.AddClaim(new Claim(AHP.Core.ClaimTypes.Company, "AHM"));
            unAuthenticatedClaims.AddClaim(new Claim(ClaimTypes.Role, "Admin"));
            unAuthenticatedClaims.AddClaim(new Claim(AHP.Core.ClaimTypes.MustChangeSecurityQuestion, bool.FalseString));
            unAuthenticatedClaims.AddClaim(new Claim(ClaimTypes.Email, "*****@*****.**"));
            MockControllerContext.SetupGet(context => context.HttpContext.User).Returns(new ClaimsPrincipal(unAuthenticatedClaims));


            mockRestClient.Setup(rst => rst.ChangePassword(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(new GenericAjaxResponse <bool>()
            {
                Data    = true,
                Success = true
            });
            _userSetupController = new SetupUserController(mockLogger.Object, mockRestClient.Object, _mockOwinAuthManager.Object);
            _userSetupController.ControllerContext = MockControllerContext.Object;

            AHP.Web.ViewModel.PasswordResetViewModel vModel = new Web.ViewModel.PasswordResetViewModel();
            vModel.OldPassword     = "******";
            vModel.ConfirmPassword = vModel.NewPassword = "******";

            ActionResult result = _userSetupController.ChangePassword(vModel);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }
Пример #2
0
        public void Change_Password_Should_Redirect_ToHome()
        {
            ActionResult result = _userSetupController.ChangePassword();

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }