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]); } } }
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); } }
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); } } }