Beispiel #1
0
        [Ignore] // test no longer works since Framwork 3.0 installed
        public void RightSideHeader_FromCustomLeftSideHeader()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context =
                HttpContextHelper.CreateHttpContext("GET", "/localtest1/TestPage.aspx/someinfo", "name1=value1");


            RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);

            Assert.IsNotNull(remoteApplication, "remoteApplication");

            TrafficLogger       logger  = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
            NameValueCollection headers = new NameValueCollection();

            headers.Add("X-Custom", "CustomValue");
            headers.Add("Range", "messages=1-20,25-30");
            HttpRequestHelper.AddHeaders(context.Request, headers);
            using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
            {
                HttpWebRequest webRequest = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                Assert.IsNotNull(webRequest, "Request is null.");
                Assert.AreEqual("GET", webRequest.Method);
                Assert.IsNotNull(webRequest.Headers["X-Custom"], "CustomHeader");
                Assert.AreEqual("CustomValue", webRequest.Headers["X-Custom"]);
                Assert.IsNotNull(webRequest.Headers["Range"], "Range");
                Assert.AreEqual("messages=1-20,25-30", webRequest.Headers["Range"]);
            }
        }
Beispiel #2
0
        public void RemoteApplication_ByPass()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context = HttpContextHelper.CreateHttpContext("GET", "/zmrres/images/somepicture.png",
                                                                      "name1=value1");

            RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);
            TrafficLogger     logger            = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
            string            rightSideUrl      = remoteApplication.GetRightSideUrl(context.Request);

            Assert.AreEqual("https://portal.bmi.gv.at/images/somepicture.png?name1=value1", rightSideUrl,
                            "RightSideUrl");
            Assert.IsTrue(remoteApplication.ByPass(context.Request.Url.AbsolutePath));

            using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
            {
                HttpWebRequest request = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                Assert.IsNotNull(request, "Request is null.");
                Assert.AreEqual("GET", request.Method);
            }
        }
Beispiel #3
0
        public void RemoteApplication_GetRequest()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context = HttpContextHelper.CreateHttpContext("GET", "/localtest1/TestPage.aspx/someinfo", "name1=value1");

            using (new TraceScope(context))
            {
                RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);
                TrafficLogger     logger            = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
                string            rightSideUrl      = remoteApplication.GetRightSideUrl(context.Request);
                Assert.AreEqual("http://egoratest/PvpTestApplication/1/TestPage.aspx/someinfo?name1=value1", rightSideUrl,
                                "RightSideUrl");

                using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
                {
                    HttpWebRequest request = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                    Assert.IsNotNull(request, "Request is null.");
                    Assert.AreEqual("GET", request.Method);
                }
            }
        }
Beispiel #4
0
        public void RemoteApplication_PostRequest()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context         = HttpContextHelper.CreateHttpContext("POST", "/localtest1/", null);
            HttpRequest leftSideRequest = context.Request;

            RemoteApplication remoteApplication = RemoteApplication.GetRemoteApplication(context.Request);
            TrafficLogger     logger            = new TrafficLogger(remoteApplication.RemoteApplicationProxyPath, "UnitTest", new TraceScope(null), context.Request.Url);
            string            rightSideUrl      = remoteApplication.GetRightSideUrl(context.Request);

            Assert.AreEqual("http://egoratest/PvpTestApplication/1/", rightSideUrl, "RightSideUrl");

            using (Stream inputBuffer = CopyFilter.GetInputStream(context.Request))
            {
                HttpWebRequest rightSideRequest = remoteApplication.CreateRightSideRequest(context.Request, inputBuffer, logger);
                Assert.IsNotNull(rightSideRequest, "Request is null.");
                Assert.AreEqual("POST", rightSideRequest.Method);
                // currently empty collection
                foreach (HttpHeader header in leftSideRequest.Headers)
                {
                    Assert.IsNotNull(rightSideRequest.Headers[header.Name], "header");
                    Assert.AreEqual(header.Value, rightSideRequest.Headers[header.Name]);
                }
            }
        }
Beispiel #5
0
        public void RemoteApplication_GetRemoteApplication()
        {
            PathMap map =
                PathMap.CreateFromFile(
                    @"MappingTest\Mapping.xml");

            RemoteApplication.Initialize(map);

            HttpContext context1 = HttpContextHelper.CreateHttpContext("GET", "/localtest/TestPage.aspx/someinfo",
                                                                       "name1=value1");

            RemoteApplication app1 = RemoteApplication.GetRemoteApplication(context1.Request);

            Assert.IsNotNull(app1, "RemoteApplication");

            HttpContext context2 = HttpContextHelper.CreateHttpContext("GET", "/somepath/TestPage.aspx/someinfo",
                                                                       "name1=value1");
            RemoteApplication app2 = RemoteApplication.GetRemoteApplication(context2.Request);

            Assert.IsNotNull(app2);
            Assert.AreEqual("https://someserver/", app2.RootUrl);
        }