Exemplo n.º 1
0
        //[TestMethod]
        public void TestLoginExportType()
        {
            TempFile temp = new TempFile();

            temp.Write(Resources.AltoroLogin);

            TrafficViewerFile origFile = new TrafficViewerFile();

            origFile.Open(temp.Path);

            Assert.AreEqual(4, origFile.RequestCount);

            //export

            IList <ITrafficExporter> exporters = TrafficViewer.Instance.TrafficExporters;

            ITrafficExporter loginExporter = null;

            foreach (ITrafficExporter exporter in exporters)
            {
                if (exporter.Caption == "ASE Login Files (.login)")
                {
                    loginExporter = exporter;
                }
            }

            Assert.IsNotNull(loginExporter);

            TempFile exportedFile = new TempFile("exporttest.login");
            Stream   stream       = exportedFile.OpenStream();

            loginExporter.Export(origFile, stream, "demo.testfire.net", 80);

            stream.Close();

            //import the exported file

            TrafficViewerFile import = new TrafficViewerFile();

            ITrafficParser configurationParser = TrafficViewer.Instance.GetParser("Configuration Parser");

            Assert.IsNotNull(configurationParser);

            configurationParser.Parse(exportedFile.Path, import, ParsingOptions.GetLegacyAppScanProfile());


            Assert.AreEqual(origFile.RequestCount, import.RequestCount);

            int           i = -1;
            TVRequestInfo origInfo;

            while ((origInfo = origFile.GetNext(ref i)) != null)
            {
                TVRequestInfo importInfo      = import.GetRequestInfo(origInfo.Id);
                string        origRequest     = Constants.DefaultEncoding.GetString(origFile.LoadRequestData(origInfo.Id));
                string        importedRequest = Constants.DefaultEncoding.GetString(import.LoadRequestData(origInfo.Id));

                Assert.AreEqual(origRequest, importedRequest);
            }
        }
Exemplo n.º 2
0
        private void ExportClick(object sender, EventArgs e)
        {
            int    newPort = 0;
            string newHost = _textNewHost.Text;

            if (_checkReplaceHost.Checked)
            {
                if (!String.IsNullOrEmpty(_textNewPort.Text) && !int.TryParse(_textNewPort.Text, out newPort))
                {
                    MessageBox.Show(Resources.ErrorPort, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (Uri.CheckHostName(newHost) == UriHostNameType.Unknown)
                {
                    MessageBox.Show(Resources.ErrorHost, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            try
            {
                _buttonExport.Enabled = false;
                ITrafficExporter currentExporter = TrafficViewer.Instance.TrafficExporters[_listExporters.SelectedIndex];
                _stream = File.Open(_fileName.Text, FileMode.Create, FileAccess.Write, FileShare.None);
                TrafficViewer.Instance.BeginExport(currentExporter, _stream, newHost, newPort, _callback);
                _progressDialog.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format(Resources.ExportError, ex.Message), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="exporter"></param>
        /// <param name="stream"></param>
        /// <param name="isSSL"></param>
        /// <param name="newHost"></param>
        /// <param name="newPort"></param>
        /// <param name="callback"></param>
        public void BeginExport(ITrafficExporter exporter, Stream stream, string newHost, int newPort, AsyncCallback callback)
        {
            TVAsyncOperation thread = new TVAsyncOperation(Export, _exceptionMessageHandler, callback, callback);

            thread.Start(new object[4] {
                exporter, stream, newHost, newPort
            });
        }
Exemplo n.º 4
0
 private void SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_listExporters.SelectedIndex >= 0 && _listExporters.SelectedIndex < TrafficViewer.Instance.TrafficExporters.Count)
     {
         ITrafficExporter currentExporter = TrafficViewer.Instance.TrafficExporters[_listExporters.SelectedIndex];
         _fileName.Filter = String.Format("{0} file|*.{1}", currentExporter.Caption, currentExporter.Extension);
     }
 }
Exemplo n.º 5
0
        private void Export(object param)
        {
            object[]         paramArray = (object[])param;
            ITrafficExporter exporter   = (ITrafficExporter)paramArray[0];
            Stream           stream     = (Stream)paramArray[1];
            string           newHost    = (string)paramArray[2];
            int newPort = (int)paramArray[3];

            exporter.Export(_trafficViewerFile, stream, newHost, newPort);
        }
Exemplo n.º 6
0
        //[TestMethod]
        public void TestVariableDefinitions()
        {
            TempFile temp = new TempFile();

            temp.Write(Resources.AltoroLogin);

            TrafficViewerFile origFile = new TrafficViewerFile();

            origFile.Open(temp.Path);

            Assert.AreEqual(4, origFile.RequestCount);

            //export

            IList <ITrafficExporter> exporters = TrafficViewer.Instance.TrafficExporters;

            ITrafficExporter loginExporter = null;

            foreach (ITrafficExporter exporter in exporters)
            {
                if (exporter.Caption == "AppScan Login Files (.login)")
                {
                    loginExporter = exporter;
                }
            }

            Assert.IsNotNull(loginExporter);

            TempFile exportedFile = new TempFile("exporttest.xml");
            Stream   stream       = exportedFile.OpenStream();

            loginExporter.Export(origFile, stream, "demo.testfire.net", 80);

            stream.Close();

            //import the exported file
            XmlDocument loginDoc = new XmlDocument();

            loginDoc.XmlResolver = null;

            loginDoc.Load(exportedFile.Path);

            XmlNode varDef = loginDoc.SelectSingleNode("//VariableDefinition[@Name='amSessionId']");

            Assert.IsNotNull(varDef);
            Assert.AreEqual("Cookie", varDef.SelectSingleNode("VariableType").InnerText);
            Assert.AreEqual("True", varDef.SelectSingleNode("SessionIDEnabled").InnerText);
        }