Пример #1
0
 public void DeleteProxy()
 {
     Log.Message("Deleting proxy on port " + proxyPort);
     request.Method   = Method.DELETE;
     request.Resource = string.Format("/proxy/{0}", proxyPort);
     response         = client.Execute(request);
     if (response.StatusCode != HttpStatusCode.OK)
     {
         throw new Exception("Could not delete proxy at port : " + proxyPort + " : " + response.StatusCode);
     }
 }
Пример #2
0
 public void CreateHar()
 {
     Log.Message("Creating a new Har");
     request.Method   = Method.PUT;
     request.Resource = string.Format("/proxy/{0}/har", proxyPort);
     response         = client.Execute(request);
     if (response.ResponseStatus != ResponseStatus.Completed)
     {
         throw new Exception("Could not create Har on port " + proxyPort + ": " + response.StatusCode);
     }
 }
Пример #3
0
 public void CreatePage(string name)
 {
     Log.Message("Creating a new Proxy Page with name " + name);
     request.Method   = Method.PUT;
     request.Resource = string.Format("/proxy/{0}/har/pageRef", proxyPort);
     response         = client.Execute(request);
     if (response.StatusCode != HttpStatusCode.OK)
     {
         throw new Exception("Could not create Page : " + response.StatusCode);
     }
 }
Пример #4
0
 public void QuitProxy()
 {
     Log.Message("Quitting Proxy on Port " + proxyPort);
     request.Method   = Method.DELETE;
     request.Resource = "/proxy/" + proxyPort;
     response         = client.Execute(request);
     if (response.StatusCode != HttpStatusCode.OK)
     {
         Log.Warning("Could not quit proxy on port : " + proxyPort);
     }
 }
Пример #5
0
 public void UnzipProxy()
 {
     if (File.Exists(batchPath) == false)
     {
         Log.Message("BrowserMobProxy not found, unzipping");
         //using (var zf = ZipFile.Read(zipPath))
         //{
         //    zf.ExtractAll(extractPath);
         //}
     }
 }
Пример #6
0
 public void QuitServer()
 {
     try
     {
         Log.Message("Stopping BrowserMobProxy Server");
         serverProcess.CloseMainWindow();
         serverProcess.Kill();
         server_started = false;
     }
     catch (Exception e)
     {
         Log.Error(e.Message);
     }
 }
Пример #7
0
        public void CreateProxy()
        {
            if (server_started == false)
            {
                StartServer();
            }
            Log.Message("Creating Proxy on Port " + proxyPort);

            request.Method   = Method.POST;
            request.Resource = "/proxy?port=" + proxyPort;
            response         = client.Execute(request);
            if (response.StatusCode != HttpStatusCode.OK)
            {
                response = client.Execute(request);
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception("Could not start Proxy at port : " + proxyPort + " : " + response.ErrorMessage);
                }
            }
        }
Пример #8
0
 public void KillOldProxy()
 {
     if (Config.settings.httpProxy.killOldProxy)
     {
         var runningProcesses = Process.GetProcesses();
         foreach (var process in runningProcesses)
         {
             try
             {
                 if ((process.ProcessName == "java") && (process.StartInfo.CreateNoWindow == false))
                 {
                     Log.Message("Killing old BMP Proxy");
                     process.Kill();
                 }
             }
             catch (Exception)
             {
             }
         }
     }
 }
Пример #9
0
        public void VerifyRequestQueryString(string url, QueryStringItem queryString)
        {
            if (IsQueryStringInEntry(queryString, GetLastEntryForUrl(url)))
            {
                Log.Message(string.Format("!--Verification Passed. Request contains {0}={1}", queryString.Name,
                                          queryString.Value));
                return;
            }

            string message;
            var    value = GetValueForQueryStringWithName(queryString.Name, GetLastEntryForUrl(url));

            if (value != null)
            {
                message = string.Format("Expected {0}={1}. Actual {2}={3}", queryString.Name, queryString.Value,
                                        queryString.Name, value);
            }
            else
            {
                message = string.Format("No QueryString found with Description={0}", queryString.Name);
            }
            TestBase.AddVerificationError(string.Format("Request From {0} to {1} not correct. {2}",
                                                        TestBase.testData.driver.Url, url, message));
        }