Used to simulate an HttpRequest.
Inheritance: System.Web.Hosting.SimpleWorkerRequest
Exemplo n.º 1
0
        public void User_sensenet393_BugReproduction()
        {
            Test(true, () =>
            {
                Providers.Instance.CacheProvider = new SnMemoryCache();

                Group group;
                User user;
                using (new SystemAccount())
                {
                    var ed = SecurityHandler.CreateAclEditor();
                    ed.Set(Repository.Root.Id, User.Administrator.Id, false, PermissionBitMask.AllAllowed);
                    ed.Set(Repository.Root.Id, Group.Administrators.Id, false, PermissionBitMask.AllAllowed);
                    ed.Apply();

                    var portal = Node.LoadNode("/Root/IMS/BuiltIn/Portal");

                    group = new Group(portal)
                    {
                        Name = "TestGroup"
                    };
                    group.Save();

                    user = new User(portal)
                    {
                        Name        = "TestUser",
                        Enabled     = true,
                        Email       = "*****@*****.**",
                        DisplayName = "User_sensenet393_BugReproduction"
                    };
                    user.Save();

                    Group.Administrators.AddMember(user);
                    User.Current = user;
                }

                Providers.Instance.MembershipExtender = new TestMembershipExtender();

                var simulatedOutput        = new StringWriter();
                var simulatedWorkerRequest = new SimulatedHttpRequest(@"\", @"C:\Inetpub\wwwroot", user.Path, "",
                                                                      simulatedOutput, "localhost_forms");
                var simulatedHttpContext = new HttpContext(simulatedWorkerRequest);
                var portalContext        = PortalContext.Create(simulatedHttpContext);
                HttpContext.Current      = simulatedHttpContext;

                // This line caused StackOverflowException
                var additionalGroups = user.GetDynamicGroups(2);

                // The bug is fixed if the code can run up to this point
                // but we test the full feature.
                Assert.AreEqual(group.Id, additionalGroups.First());
            });
        }
Exemplo n.º 2
0
        public void PortalContext_RepositoryPathResolve_OnSite()
        {
            Test(() =>
            {
                CreateTestSite();

                string pagePath = "/Pictures/alma.jpg/";
                string expectedRepositoryPath = "/Root/Sites/Fake Test Site/Pictures/alma.jpg";

                System.IO.StringWriter simulatedOutput      = new System.IO.StringWriter();
                SimulatedHttpRequest simulatedWorkerRequest = new SimulatedHttpRequest(@"\", @"C:\Inetpub\wwwroot", pagePath, "", simulatedOutput, "localhost_windows");
                HttpContext simulatedHttpContext            = new HttpContext(simulatedWorkerRequest);
                PortalContext portalContext = PortalContext.Create(simulatedHttpContext);

                Assert.AreEqual(expectedRepositoryPath, portalContext.RepositoryPath);
                Assert.AreEqual("Windows", portalContext.AuthenticationMode);
            });
        }
Exemplo n.º 3
0
        public void PortalContext_RepositoryPathResolve_OffSite()
        {
            CleanupTestSite();
            CreateTestSite();

            string pagePath = "/fakesiteforms/Root/System/alma.jpg/";
            string expectedRepositoryPath = "/Root/System/alma.jpg";

            System.IO.StringWriter simulatedOutput        = new System.IO.StringWriter();
            SimulatedHttpRequest   simulatedWorkerRequest = new SimulatedHttpRequest(@"\", @"C:\Inetpub\wwwroot", pagePath, "", simulatedOutput, "localhost");
            HttpContext            simulatedHttpContext   = new HttpContext(simulatedWorkerRequest);
            PortalContext          portalContext          = PortalContext.Create(simulatedHttpContext);

            bool success_Path     = (portalContext.RepositoryPath == expectedRepositoryPath);
            bool success_AuthMode = (portalContext.AuthenticationMode == "Forms");

            CleanupTestSite();

            Assert.IsTrue(success_Path, "success_Path");
            Assert.IsTrue(success_AuthMode, "success_AuthMode");
        }
Exemplo n.º 4
0
        public void PortalContext_RepositoryPathResolve_OffSite()
        {
            CleanupTestSite();
            CreateTestSite();
            try
            {
                string pagePath = "/fakesiteforms/Root/System/alma.jpg/";
                string expectedRepositoryPath = "/Root/System/alma.jpg";

                System.IO.StringWriter simulatedOutput        = new System.IO.StringWriter();
                SimulatedHttpRequest   simulatedWorkerRequest = new SimulatedHttpRequest(@"\", @"C:\Inetpub\wwwroot", pagePath, "", simulatedOutput, "localhost");
                HttpContext            simulatedHttpContext   = new HttpContext(simulatedWorkerRequest);
                PortalContext          portalContext          = PortalContext.Create(simulatedHttpContext);

                Assert.AreEqual(expectedRepositoryPath, portalContext.RepositoryPath);
                Assert.AreEqual("Forms", portalContext.AuthenticationMode);
            }
            finally
            {
                CleanupTestSite();
            }
        }
Exemplo n.º 5
0
        public static SimulatedHttpRequest CreateRequest(string page, string query, TextWriter output = null)
        {
            var request = new SimulatedHttpRequest(@"\", @"C:\Inetpub\wwwroot", page, query, output ?? new StringWriter(), "testhost");

            return(request);
        }
Exemplo n.º 6
0
 public static HttpContext CreateHttpContext(SimulatedHttpRequest request)
 {
     return(new System.Web.HttpContext(request));
 }
Exemplo n.º 7
0
        public void PortalContext_RepositoryPathResolve_OffSite()
        {
            CleanupTestSite();
            CreateTestSite();

            string pagePath = "/fakesiteforms/Root/System/alma.jpg/";
            string expectedRepositoryPath = "/Root/System/alma.jpg";

            System.IO.StringWriter simulatedOutput = new System.IO.StringWriter();
            SimulatedHttpRequest simulatedWorkerRequest = new SimulatedHttpRequest(@"\", @"C:\Inetpub\wwwroot", pagePath, "", simulatedOutput, "localhost");
            HttpContext simulatedHttpContext = new HttpContext(simulatedWorkerRequest);
            PortalContext portalContext = PortalContext.Create(simulatedHttpContext);

            bool success_Path = (portalContext.RepositoryPath == expectedRepositoryPath);
            bool success_AuthMode = (portalContext.AuthenticationMode == "Forms");

            CleanupTestSite();

            Assert.IsTrue(success_Path, "success_Path");
            Assert.IsTrue(success_AuthMode, "success_AuthMode");
        }