public void ParsingTestSource() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(5), "49826"); }
public void ParsingTestTimeDestination() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(6), "80"); }
public void ParsingTestSourceIp() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(3), "192.168.8.100"); }
public void ParsingTestTimeDestinationIp() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(4), "192.168.8.1"); }
public void ParsingTestInformation() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(7), "GET /lib/jquery.qtip.css HTTP/1.1\r"); }
public void ParsingTestTimeLen() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(2), "602"); }
public void ParsingTestTime() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(1), "20:18:33 22"); }
public void ParsingTestName() { var http = new HTTPParser(); PPacket pack = http.Parsing(httpPacket, time, len); Assert.AreEqual(pack.GetPacket(0), "HTTP"); }
public void HttpParserTest() { HTTPParser parser = new HTTPParser(); var result = parser.ParsePcapFile(@"../../../../TestFiles/newTest3.pcap"); // Common properties Assert.That(result[0].Protocol, Is.EqualTo("HTTP"));
public void HttpParser_should_return_http_request_properties_test() { var requestMessage = @"POST /foo.php HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://localhost/test.php Content-Type: application/x-www-form-urlencoded Content-Length: 43"; HTTPParser.ParseRequest(requestMessage).Should().BeOfType <RequestProperties>(); }
public void HttpParserTest() { HTTPParser parser = new HTTPParser(); var result = parser.ParsePcapFile(@"../../../../TestFiles/test.pcap"); // Common properties Assert.That(result[0].Protocol, Is.EqualTo("HTTP")); Assert.That(result[0].Length, Is.EqualTo(298)); Assert.That(result[0].DestinationAddress, Is.EqualTo("104.244.43.209")); Assert.That(result[0].DestinationPort, Is.EqualTo("443")); Assert.That(result[0].SourceAddress, Is.EqualTo("192.168.43.156")); Assert.That(result[0].SourcePort, Is.EqualTo("1434")); Assert.That(result[0].TimeStamp.ToString("yyyy-MM-dd"), Is.EqualTo("2017-11-23")); Assert.That(result.Count, Is.EqualTo(93)); result = parser.ParsePcapFile("../../../../TestFiles/newTest2.pcap"); Assert.That(result.Count, Is.EqualTo(378)); }
public override void HandleServerSide(Socket s) { byte[] buf = new byte[1] { GetID() }; while (buf.Last() != (byte)'\r') { buf = buf.Concat(NetUtils.Read(s, 1)).ToArray(); } buf = buf.Where(c => c != (byte)'\r').ToArray(); string req = Encoding.ASCII.GetString(buf); if (!req.StartsWith("GET /")) { s.Disconnect(false); return; } string res = HTTPParser.GetResponse(req); _ = s.Send(Encoding.ASCII.GetBytes(res), SocketFlags.None); s.Disconnect(false); }
public void HttpParser_should_return_null_for_null_request_test() { HTTPParser.ParseRequest(null).Should().BeNull(); }