示例#1
0
        public void Select_Questions_Must_Update()
        {
            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.MustChangeSecurityQuestion, bool.TrueString));
            unAuthenticatedClaims.AddClaim(new Claim(AHP.Core.ClaimTypes.Company, "AHM"));
            unAuthenticatedClaims.AddClaim(new Claim(ClaimTypes.Role, "Admin"));
            unAuthenticatedClaims.AddClaim(new Claim(ClaimTypes.Email, "*****@*****.**"));
            MockControllerContext.SetupGet(context => context.HttpContext.User).Returns(new ClaimsPrincipal(unAuthenticatedClaims));

            mockRestClient.Setup(rst => rst.GetSecurityQuestionList()).Returns(new List <string>());
            mockRestClient.Setup(rst => rst.SetSecurityQuestionsForUser(It.IsAny <string>(), It.IsAny <List <AHP.Core.DTO.UserSecurityOption> >())).
            Returns(new GenericAjaxResponse <bool>()
            {
                Success = true, Data = true
            });
            _userSetupController = new SetupUserController(mockLogger.Object, mockRestClient.Object, _mockOwinAuthManager.Object);
            _userSetupController.ControllerContext = MockControllerContext.Object;

            ActionResult response = _userSetupController.SelectQuestions(new Web.ViewModel.SecurityQuestionsViewModel()
            {
                ThirdProvidedAnswer       = "ans",
                SecondaryProvidedAnswer   = "ans",
                PrimaryProvidedAnswer     = "ans",
                PrimarySelectedQuestion   = "ques",
                SecondarySelectedQuestion = "ques",
                ThirdSelectedQuestion     = "ques"
            });

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(ViewResult));
        }
示例#2
0
        public void Select_Questions_Must_DisplayView()
        {
            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.MustChangeSecurityQuestion, bool.TrueString));
            unAuthenticatedClaims.AddClaim(new Claim(AHP.Core.ClaimTypes.Company, "AHM"));
            unAuthenticatedClaims.AddClaim(new Claim(ClaimTypes.Role, "Admin"));
            unAuthenticatedClaims.AddClaim(new Claim(ClaimTypes.Email, "*****@*****.**"));
            MockControllerContext.SetupGet(context => context.HttpContext.User).Returns(new ClaimsPrincipal(unAuthenticatedClaims));

            mockRestClient.Setup(rst => rst.GetSecurityQuestionList()).Returns(new List <string>());
            _userSetupController = new SetupUserController(mockLogger.Object, mockRestClient.Object, _mockOwinAuthManager.Object);
            _userSetupController.ControllerContext = MockControllerContext.Object;

            ActionResult response = _userSetupController.SelectQuestions();

            Assert.IsNotNull(response);
            Assert.IsInstanceOfType(response, typeof(ViewResult));
        }