Exemple #1
0
        public void VerifyCodeTest()
        {
            AccountController acct = new AccountController();
            //var mockedPrincipal = new Mock<WindowsPrincipal>(WindowsIdentity.GetCurrent());

            //mockedPrincipal.SetupGet(x => x.Identity.IsAuthenticated).Returns(true);
            //mockedPrincipal.SetupGet(x => x.Identity.Name).Returns("HANNON\\phannon");
            //mockedPrincipal.Setup(x => x.IsInRole("Domain\\Group1")).Returns(true);
            //mockedPrincipal.Setup(x => x.IsInRole("Domain\\Group2")).Returns(false);


            var model = new VerifyCodeViewModel()
            {
                Code = "123456"
            };

            var mockHttpContext = MockHttpSession.FakeHttpContext();
            var mockSession     = mockHttpContext.Session;

            mockSession["AuthCode"] = "123456";
            var r = acct.VerifyCode(model);

            Assert.IsNotNull(r);

            //RedirectResult results = (RedirectResult)acct.LogOn(userName, password, rememberMe, returnUrl);
            //Assert.AreEqual(returnUrl, results.Url);
            //Assert.AreEqual(userName, acct.Session["txtUserName"]);
            //Assert.IsNotNull(acct.Session["SessionGUID"]);
        }
Exemple #2
0
 public void ValidateSMSIsSent()
 {
     try
     {
         var mockHttpContext = MockHttpSession.FakeHttpContext();
         var mockSession     = mockHttpContext.Session;
         var request         = new TwoFactorRequestModel()
         {
             Provider  = Provider.SMS,
             UserValue = "18174120313"
         };
         var response = _twoFactorAuth.CreateTwoFactorAuth(request, mockSession);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
Exemple #3
0
 public void ValidateEmailIsSent()
 {
     try
     {
         var mockHttpContext = MockHttpSession.FakeHttpContext();
         //get the mock session
         var mockSession = mockHttpContext.Session;
         var request     = new TwoFactorRequestModel()
         {
             Provider  = Provider.Email,
             UserValue = "*****@*****.**"
         };
         var response = _twoFactorAuth.CreateTwoFactorAuth(request, mockSession);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }