示例#1
0
        public void GetFilePathTranslatedTest()
        {
            SimpleWorkerRequest reference = new SimpleWorkerRequest("/webapp", "c:\\webapp\\", "default.aspx", "", null);

            AspNetWorker worker = GetHttpWorker("/webapp", "c:\\webapp\\");

            Assert.AreEqual(reference.GetFilePathTranslated(), worker.GetFilePathTranslated());
        }
示例#2
0
        //
        // This tests the constructor when the user code creates an HttpContext
        //
        [Test] public void ConstructorTests()
        {
            StringWriter sw = new StringWriter();

            SimpleWorkerRequest swr;

            swr = new SimpleWorkerRequest("/appVirtualDir", cwd, "pageVirtualPath", "querystring", sw);
            Assert.AreEqual("/appVirtualDir", swr.GetAppPath(), "S1");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath", swr.GetFilePath(), "S2");
            Assert.AreEqual("GET", swr.GetHttpVerbName(), "S3");
            Assert.AreEqual("HTTP/1.0", swr.GetHttpVersion(), "S4");
            Assert.AreEqual("127.0.0.1", swr.GetLocalAddress(), "S5");
            Assert.AreEqual(80, swr.GetLocalPort(), "S6");
            Assert.AreEqual("querystring", swr.GetQueryString(), "S7");
            Assert.AreEqual("127.0.0.1", swr.GetRemoteAddress(), "S8");
            Assert.AreEqual(0, swr.GetRemotePort(), "S9");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath?querystring", swr.GetRawUrl(), "S10");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath", swr.GetUriPath(), "S11");
            Assert.AreEqual("0", swr.GetUserToken().ToString(), "S12");
            Assert.AreEqual(null, swr.MapPath("x"), "S13");
            Assert.AreEqual(null, swr.MachineConfigPath, "S14");
            Assert.AreEqual(null, swr.MachineInstallDirectory, "S15");
            Assert.AreEqual(Path.Combine(cwd, "pageVirtualPath"), swr.GetFilePathTranslated(), "S16");
            Assert.AreEqual("", swr.GetServerVariable("AUTH_TYPE"), "S18");
            Assert.AreEqual("", swr.GetServerVariable("AUTH_USER"), "S19");
            Assert.AreEqual("", swr.GetServerVariable("REMOTE_USER"), "S20");
            Assert.AreEqual("", swr.GetServerVariable("SERVER_SOFTWARE"), "S21");
            Assert.AreEqual("/appVirtualDir/pageVirtualPath", swr.GetUriPath(), "S22");

            //
            // MapPath
            //
            Assert.AreEqual(null, swr.MapPath("file.aspx"), "MP1");
            Assert.AreEqual(null, swr.MapPath("/appVirtualDir/pageVirtualPath"), "MP2");
            Assert.AreEqual(null, swr.MapPath("appVirtualDir/pageVirtualPath"), "MP3");
            Assert.AreEqual(null, swr.MapPath("/appVirtualDir/pageVirtualPath/page.aspx"), "MP4");
            Assert.AreEqual(null, swr.MapPath("/appVirtualDir/pageVirtualPath/Subdir"), "MP5");

            swr = new SimpleWorkerRequest("/appDir", cwd, "/Something/page.aspx", "querystring", sw);

            //Assert.AreEqual ("c:\\tmp\\page.aspx", swr.GetFilePathTranslated (), "S17");

            //
            // GetUriPath tests, veredict: MS implementation is a bit fragile on this interface
            //
            swr = new SimpleWorkerRequest("/appDir", cwd, "/page.aspx", null, sw);
            Assert.AreEqual("/appDir//page.aspx", swr.GetUriPath(), "S23");

            swr = new SimpleWorkerRequest("/appDir/", cwd, "/page.aspx", null, sw);
            Assert.AreEqual("/appDir///page.aspx", swr.GetUriPath(), "S24");

            swr = new SimpleWorkerRequest("/appDir/", cwd, "page.aspx", null, sw);
            Assert.AreEqual("/appDir//page.aspx", swr.GetUriPath(), "S25");

            swr = new SimpleWorkerRequest("/appDir", cwd, "page.aspx", null, sw);
            Assert.AreEqual("/appDir/page.aspx", swr.GetUriPath(), "S26");
        }
示例#3
0
 public void GetFilePathTranslated_Deny_FileIOPermission()
 {
     // path discovery
     swr.GetFilePathTranslated();
 }