Esempio n. 1
0
        public void AttemptsDigestAuth(bool isAuthenticated, int expected)
        {
            //Arrange
            var controller        = new DnnControllerHelper();
            var mockAuthenticator = new Mock <AuthenticatorBase>();

            DigestAuthenticator.SetTestableInstance(mockAuthenticator.Object);
            BasicAuthenticator.SetTestableInstance(new Mock <AuthenticatorBase>().Object);

            _mockHttpContext.Setup(x => x.Request.IsAuthenticated).Returns(isAuthenticated);

            //Act
            controller.PublicAuthenticate(_httpContext, 0);

            //Assert
            mockAuthenticator.Verify(x => x.TryToAuthenticate(_httpContext, 0), Times.Exactly(expected));
        }
Esempio n. 2
0
        public void OmittedTabIdWillNotLoadModule()
        {
            //Arrange
            var controller = new DnnControllerHelper();

            //no tabid
            _httpContext.Request.Headers.Add("moduleid", ValidModuleId.ToString(CultureInfo.InvariantCulture));

            //Act
            int tabId;

            controller.PublicValidateTabAndModuleContext(_httpContext, ValidPortalId, out tabId);

            //Assert
            _mockTabController.Verify(x => x.GetTab(It.IsAny <int>(), It.IsAny <int>()), Times.Never());
            _mockModuleController.Verify(x => x.GetModule(It.IsAny <int>(), It.IsAny <int>()), Times.Never());
            Assert.IsNull(controller.ActiveModule);
        }
Esempio n. 3
0
        public void LoadsActiveModule()
        {
            //Arrange
            var controller = new DnnControllerHelper();

            _httpContext.Request.Headers.Add("tabid", ValidTabId.ToString(CultureInfo.InvariantCulture));
            _httpContext.Request.Headers.Add("moduleid", ValidModuleId.ToString(CultureInfo.InvariantCulture));
            _mockTabController.Setup(x => x.GetTab(ValidTabId, ValidPortalId)).Returns(new TabInfo());
            var moduleInfo = new ModuleInfo();

            _mockModuleController.Setup(x => x.GetModule(ValidModuleId, ValidTabId)).Returns(moduleInfo);

            //Act
            int tabId;

            controller.PublicValidateTabAndModuleContext(_httpContext, ValidPortalId, out tabId);

            //Assert
            Assert.AreSame(moduleInfo, controller.ActiveModule);
        }