summaryrefslogtreecommitdiffstats
path: root/test/suite_sharkd.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/suite_sharkd.py')
-rw-r--r--test/suite_sharkd.py117
1 files changed, 109 insertions, 8 deletions
diff --git a/test/suite_sharkd.py b/test/suite_sharkd.py
index d8c1ef2f..1d4adcde 100644
--- a/test/suite_sharkd.py
+++ b/test/suite_sharkd.py
@@ -237,6 +237,23 @@ class TestSharkd:
},
))
+ def test_sharkd_req_frames_comments(self, check_sharkd_session, capture_file):
+ check_sharkd_session((
+ {"jsonrpc":"2.0", "id":1, "method":"load",
+ "params":{"file": capture_file('comments.pcapng')}
+ },
+ {"jsonrpc":"2.0", "id":2, "method":"frames","params":{"filter":"frame.number==3||frame.number==4||frame.number==5"}},
+ ), (
+ {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
+ {"jsonrpc":"2.0","id":2,"result":
+ [
+ {"c":["3","0.610021","::","ff02::1:ffdc:6277","ICMPv6","78","Neighbor Solicitation for fe80::c2c1:c0ff:fedc:6277"],"num":3,"ct":True,"comments":["hello hello"],"bg":"fce0ff","fg":"12272e"},
+ {"c":["4","0.760023","::","ff02::1:ffdc:6277","ICMPv6","78","Neighbor Solicitation for fec0::c2c1:c0ff:fedc:6277"],"num":4,"ct":True,"comments":["goodbye goodbye"],"bg":"fce0ff","fg":"12272e"},
+ {"c":["5","0.802338","10.0.0.1","224.0.0.251","MDNS","138","Standard query response 0x0000 A, cache flush 10.0.0.1 PTR, cache flush Cisco29401.local NSEC, cache flush Cisco29401.local"],"num":5,"bg":"daeeff","fg":"12272e"}
+ ],
+ },
+ ))
+
def test_sharkd_req_tap_invalid(self, check_sharkd_session, capture_file):
# XXX Unrecognized taps result in an empty line, modify
# run_sharkd_session such that checking for it is possible.
@@ -1107,6 +1124,9 @@ class TestSharkd:
{"jsonrpc":"2.0", "id":4, "method":"follow",
"params":{"follow": "HTTP", "filter": "garbage filter"}
},
+ {"jsonrpc":"2.0", "id":5, "method":"follow",
+ "params":{"follow": "HTTP", "filter": "http", "sub_stream": "garbage sub_stream"}
+ },
), (
{"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
{"jsonrpc":"2.0","id":2,"error":{"code":-32600,"message":"Mandatory parameter follow is missing"}},
@@ -1114,6 +1134,9 @@ class TestSharkd:
{"jsonrpc":"2.0","id":4,
"error":{"code":-12002,"message":"sharkd_session_process_follow() name=HTTP error=Filter \"garbage filter\" is invalid - \"filter\" was unexpected in this context."}
},
+ {"jsonrpc":"2.0","id":5,
+ "error":{"code":-32600,"message":"The data type for member sub_stream is not valid"}
+ },
))
def test_sharkd_req_follow_no_match(self, check_sharkd_session, capture_file):
@@ -1151,6 +1174,34 @@ class TestSharkd:
},
))
+ def test_sharkd_req_follow_http2(self, check_sharkd_session, capture_file, features):
+ # If we don't have nghttp2, we output the compressed headers.
+ # We could test against the expected output in that case, but
+ # just skip for now.
+ if not features.have_nghttp2:
+ pytest.skip('Requires nghttp2.')
+
+ check_sharkd_session((
+ {"jsonrpc":"2.0", "id":1, "method":"load",
+ "params":{"file": capture_file('quic-with-secrets.pcapng')}
+ },
+ {"jsonrpc":"2.0", "id":2, "method":"follow",
+ "params":{"follow": "HTTP2", "filter": "tcp.stream eq 0 and http2.streamid eq 1", "sub_stream": 1}
+ },
+ ), (
+ {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
+ {"jsonrpc":"2.0","id":2,
+ "result":{
+ "shost": "2606:4700:10::6816:826", "sport": "443", "sbytes": 656,
+ "chost": "2001:db8:1::1", "cport": "57098", "cbytes": 109643,
+ "payloads": [
+ {"n": 12, "d": MatchRegExp(r'^.*VuLVVTLGVuO3E9MC45Cgo.*$')},
+ {"n": 19, "s": 1, "d": MatchRegExp(r'^.*7IG1hPTg2NDAwCgo.*$')},
+ {"n": 44, "s": 1, "d": MatchRegExp(r'^.*Pgo8L2h0bWw.*$')},
+ ]}
+ },
+ ))
+
def test_sharkd_req_iograph_bad(self, check_sharkd_session, capture_file):
check_sharkd_session((
{"jsonrpc":"2.0", "id":1, "method":"load",
@@ -1160,10 +1211,16 @@ class TestSharkd:
{"jsonrpc":"2.0", "id":3, "method":"iograph",
"params":{"graph0": "garbage graph name"}
},
+ {"jsonrpc":"2.0", "id":4, "method":"iograph",
+ "params":{"graph0": "max:udp.length", "filter0": "udp.length", "interval": 0}},
+ {"jsonrpc":"2.0", "id":5, "method":"iograph",
+ "params":{"graph0": "max:udp.length", "filter0": "udp.length", "interval_units": "garbage units"}},
), (
{"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
{"jsonrpc":"2.0","id":2,"error":{"code":-32600,"message":"Mandatory parameter graph0 is missing"}},
{"jsonrpc":"2.0","id":3,"result":{"iograph": []}},
+ {"jsonrpc":"2.0","id":4,"error":{"code":-32600,"message":"The value for interval must be a positive integer"}},
+ {"jsonrpc":"2.0","id":5,"error":{"code":-7003,"message":"Invalid interval_units parameter: 'garbage units', must be 's', 'ms' or 'us'"}},
))
def test_sharkd_req_iograph_basic(self, check_sharkd_session, capture_file):
@@ -1171,20 +1228,41 @@ class TestSharkd:
{"jsonrpc":"2.0", "id":1, "method":"load",
"params":{"file": capture_file('dhcp.pcap')}
},
- {"jsonrpc":"2.0", "id":1, "method":"iograph",
+ {"jsonrpc":"2.0", "id":2, "method":"iograph",
"params":{"graph0": "max:udp.length", "filter0": "udp.length"}
},
- {"jsonrpc":"2.0", "id":2, "method":"iograph",
+ {"jsonrpc":"2.0", "id":3, "method":"iograph",
"params":{"graph0": "packets", "graph1": "bytes"}
},
- {"jsonrpc":"2.0", "id":3, "method":"iograph",
+ {"jsonrpc":"2.0", "id":4, "method":"iograph",
"params":{"graph0": "packets", "filter0": "garbage filter"}
},
+ {"jsonrpc":"2.0", "id":5, "method":"iograph",
+ "params":{"graph0": "packets", "graph1": "bytes", "interval": 1, "interval_units": "us"}
+ },
+ {"jsonrpc":"2.0", "id":6, "method":"iograph",
+ "params":{"graph0": "packets", "graph1": "bytes", "interval": 1, "interval_units": "ms"}
+ },
+ {"jsonrpc":"2.0", "id":7, "method":"iograph",
+ "params":{"graph0": "packets", "graph1": "bytes", "interval": 1, "interval_units": "s"}
+ },
), (
{"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
- {"jsonrpc":"2.0","id":1,"result":{"iograph": [{"items": [308.000000]}]}},
- {"jsonrpc":"2.0","id":2,"result":{"iograph": [{"items": [4.000000]}, {"items": [1312.000000]}]}},
- {"jsonrpc":"2.0","id":3,"error":{"code":-6001,"message":"Filter \"garbage filter\" is invalid - \"filter\" was unexpected in this context."}},
+ {"jsonrpc":"2.0","id":2,"result":{"iograph": [{"items": [308.000000]}]}},
+ {"jsonrpc":"2.0","id":3,"result":{"iograph": [{"items": [4.000000]}, {"items": [1312.000000]}]}},
+ {"jsonrpc":"2.0","id":4,"error":{"code":-6001,"message":"Filter \"garbage filter\" is invalid - \"filter\" was unexpected in this context."}},
+ {"jsonrpc":"2.0","id":5,"result":{"iograph": [
+ {"items": [1.0, '127', 1.0, '1118f', 1.0, '112c9', 1.0]},
+ {"items": [314.0, '127', 342.0, '1118f', 314.0, '112c9', 342.0]},
+ ]}},
+ {"jsonrpc":"2.0","id":6,"result":{"iograph": [
+ {"items": [2.0, '46', 2.0]},
+ {"items": [656.0, '46', 656.0]},
+ ]}},
+ {"jsonrpc":"2.0","id":7,"result":{"iograph": [
+ {"items": [4.0]},
+ {"items": [1312.0]},
+ ]}},
))
def test_sharkd_req_intervals_bad(self, check_sharkd_session, capture_file):
@@ -1230,7 +1308,30 @@ class TestSharkd:
},
), (
{"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
- {"jsonrpc":"2.0","id":2,"result":{"fol": [["UDP", "udp.stream eq 1"]]}},
+ {"jsonrpc":"2.0","id":2,"result":{
+ "fol": [["UDP", "udp.stream eq 1"]],
+ "followers": [{"protocol": "UDP","filter": "udp.stream eq 1","stream": 1}]
+ }},
+ ))
+
+ def test_sharkd_req_frame_http2(self, check_sharkd_session, capture_file):
+ check_sharkd_session((
+ {"jsonrpc":"2.0", "id":1, "method":"load",
+ "params":{"file": capture_file('quic-with-secrets.pcapng')}
+ },
+ {"jsonrpc":"2.0", "id":2, "method":"frame",
+ "params":{"frame": 12}
+ },
+ ), (
+ {"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
+ {"jsonrpc":"2.0","id":2,"result":{
+ "fol": [["HTTP2", "tcp.stream eq 0 and http2.streamid eq 1"],["TCP","tcp.stream eq 0"],["TLS","tcp.stream eq 0"]],
+ "followers": [
+ {"protocol": "HTTP2","filter": "tcp.stream eq 0 and http2.streamid eq 1","stream": 0, "sub_stream": 1},
+ {"protocol": "TCP","filter": "tcp.stream eq 0","stream": 0},
+ {"protocol": "TLS","filter": "tcp.stream eq 0","stream": 0},
+ ]
+ }},
))
def test_sharkd_req_frame_proto(self, check_sharkd_session, capture_file):
@@ -1283,7 +1384,7 @@ class TestSharkd:
{"jsonrpc":"2.0","id":1,"result":{"status":"OK"}},
{"jsonrpc":"2.0","id":2,"error":{"code":-3002,"message":"Frame number is out of range"}},
{"jsonrpc":"2.0","id":3,"result":{"status":"OK"}},
- {"jsonrpc":"2.0","id":4,"result":{"comment":["foo\nbar"],"fol": MatchAny(list)}},
+ {"jsonrpc":"2.0","id":4,"result":{"comment":["foo\nbar"],"fol": MatchAny(list), "followers": MatchAny(list)}},
))
def test_sharkd_req_setconf_bad(self, check_sharkd_session):