Logout() private method

private Logout ( ) : System.Web.Mvc.ActionResult
return System.Web.Mvc.ActionResult
コード例 #1
0
        public void Logout_Redirects_To_Home_Page()
        {
            // Arrange
            var controller = new IdentityController();
            controller.IdentitySources.AddMock(UnusedMockIdentitySource);

            var mockSessionManager = new Mock<ISessionIdentityManager>();
            controller.SessionIdentityManager = mockSessionManager.Object;

            // Act
            ActionResult result = controller.Logout();

            // Assert
            ResultAssert.IsRedirectToRoute(result, new {controller = "Page", action = "View", page = (Page)null});
        }
コード例 #2
0
        public void Logout_Removes_Session_Token()
        {
            // Arrange
            var controller = new IdentityController();
            controller.IdentitySources.AddMock(UnusedMockIdentitySource);

            var mockSessionManager = new Mock<ISessionIdentityManager>();
            controller.SessionIdentityManager = mockSessionManager.Object;

            // Act
            controller.Logout();

            // Assert
            mockSessionManager.Verify(s => s.ClearSessionPrincipal());
        }
コード例 #3
0
        public void Logout_Calls_IdentitySource_To_Logout_If_Token_Contains_IdentifiedBy_Claim_Matching_Valid_IdentitySource()
        {
            // Arrange
            var controller = new IdentityController();
            controller.IdentitySources.AddMock(UnusedMockIdentitySource);

            var mockSource = controller.IdentitySources.AddMock(SelectedMockIdentitySource);

            var mockSessionManager = new Mock<ISessionIdentityManager>();
            controller.SessionIdentityManager = mockSessionManager.Object;

            Claim claim = new Claim(MaverickClaimTypes.IdentifiedBy, SelectedMockIdentitySource);
            IPrincipal oldPrincipal = Thread.CurrentPrincipal;
            Thread.CurrentPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claim));

            // Act
            controller.Logout();

            // Assert
            mockSource.Verify(s => s.Logout(controller.ControllerContext));

            // Cleanup
            Thread.CurrentPrincipal = oldPrincipal;
        }