forked from osmocom/wireshark
git: Add test cases
Add git dissection test cases to existing testing suite for: finding git packets, finding the Git Protocol version, finding the right amount of Flush and Delimiter packets, not finding Malformed packets. Part of #17093
This commit is contained in:
parent
853d55b871
commit
28dbab369d
|
@ -9,6 +9,9 @@
|
||||||
* Copied from packet-pop.c
|
* Copied from packet-pop.c
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
*
|
||||||
|
* Current testing suite 'case_dissect_git' can be found at
|
||||||
|
* test/suite_dissection.py
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
Binary file not shown.
|
@ -364,6 +364,31 @@ class case_dissect_tcp(subprocesstest.SubprocessTestCase):
|
||||||
'-Ytls', '-Tfields', '-eframe.number', '-etls.record.length', '-2'))
|
'-Ytls', '-Tfields', '-eframe.number', '-etls.record.length', '-2'))
|
||||||
self.assertEqual(proc.stdout_str, '2\t16\n')
|
self.assertEqual(proc.stdout_str, '2\t16\n')
|
||||||
|
|
||||||
|
@fixtures.mark_usefixtures('test_env')
|
||||||
|
@fixtures.uses_fixtures
|
||||||
|
class case_dissect_git(subprocesstest.SubprocessTestCase):
|
||||||
|
def test_git_prot(self, cmd_tshark, capture_file, features):
|
||||||
|
'''
|
||||||
|
Check for Git protocol version 2, flush and delimiter packets.
|
||||||
|
Ensure there are no malformed packets.
|
||||||
|
'''
|
||||||
|
proc = self.assertRun((cmd_tshark,
|
||||||
|
'-r', capture_file('gitOverTCP.pcap'),
|
||||||
|
'-Ygit', '-Tfields', '-egit.version', '-egit.packet_type',
|
||||||
|
'-zexpert', '-e_ws.expert',
|
||||||
|
))
|
||||||
|
# `epan/dissectors/packet-git.c` parses the Git Protocol version
|
||||||
|
# from ASCII '1' or '2' to integers 49 or 50 in grep output.
|
||||||
|
# 0x0000 are flush packets.
|
||||||
|
# 0x0001 are delimiter packets.
|
||||||
|
# Pre-existing git Malformed Packets in this pcap were addressed
|
||||||
|
# with the parsing of the delimiter packets. This test ensures
|
||||||
|
# pcap gitOverTCP's delim packets are parsed and that there are no
|
||||||
|
# malformed packets with "Expert Info/Errors" in the same pcap.
|
||||||
|
# Additional test cases for other scenarios, i.e actually malformed
|
||||||
|
# git packets, might be required.
|
||||||
|
self.assertEqual(proc.stdout_str, '50\t\t\n\t0\t\n\t\t\n\t1,0\t\n')
|
||||||
|
|
||||||
@fixtures.mark_usefixtures('test_env')
|
@fixtures.mark_usefixtures('test_env')
|
||||||
@fixtures.uses_fixtures
|
@fixtures.uses_fixtures
|
||||||
class case_dissect_tls(subprocesstest.SubprocessTestCase):
|
class case_dissect_tls(subprocesstest.SubprocessTestCase):
|
||||||
|
|
Loading…
Reference in New Issue