예제 #1
0
        public void GetFormsAuthenticationTicket_WithRequestHavingNoCookies_ReturnsNull()
        {
            // arrange
            var module = new AuthenticationModule();

            // act
            var authTicket = module.GetFormsAuthenticationTicket(null);

            // assert
            Assert.IsNull(authTicket);
        }
예제 #2
0
        public void GetFormsAuthenticationTicket_WithRequestHavingNullAuthTicket_ReturnsNull()
        {
            // arrange
            var module     = new AuthenticationModule();
            var authCookie = new HttpCookie(".ASPXAUTH.42")
            {
                Value = null
            };

            // act
            var ticket = module.GetFormsAuthenticationTicket(authCookie);

            // assert
            Assert.IsNull(ticket);
        }
예제 #3
0
        public void GetFormsAuthenticationTicket_WithRequestHavingIndecipherableAuthCookies_ReturnsNull()
        {
            // arrange
            var module    = new AuthenticationModule();
            var badCookie = new HttpCookie(".ASPXAUTH.42")
            {
                Value = "STEOHsuthosaeuthoes234234sThisIsGarbage", Expires = DateTime.Now
            };

            // act
            var ticket = module.GetFormsAuthenticationTicket(badCookie);

            // assert
            Assert.IsNull(ticket);
        }
예제 #4
0
        public void GetFormsAuthenticationTicket_WithRequestHavingExpiredAuthCookies_SetsUserToGenericPrincipalWithRoles()
        {
            // arrange
            var          module = new AuthenticationModule();
            const string roles  = "Admins|HostAdmins|Users";
            var          ticket = new FormsAuthenticationTicket(1, ".ASPXAUTH.42", DateTime.Now, DateTime.Now.AddDays(-10), true,
                                                                roles);

            Assert.IsTrue(ticket.Expired);
            string cookieValue = FormsAuthentication.Encrypt(ticket);
            var    authCookie  = new HttpCookie(".ASPXAUTH.42")
            {
                Value = cookieValue
            };

            // act
            var authTicket = module.GetFormsAuthenticationTicket(authCookie);

            // assert
            Assert.IsNull(authTicket);
        }