summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/captures/quic-with-secrets.pcapngbin0 -> 44236 bytes
-rw-r--r--test/lua/protofield.lua8
-rw-r--r--test/suite_sharkd.py55
3 files changed, 60 insertions, 3 deletions
diff --git a/test/captures/quic-with-secrets.pcapng b/test/captures/quic-with-secrets.pcapng
new file mode 100644
index 00000000..4968365a
--- /dev/null
+++ b/test/captures/quic-with-secrets.pcapng
Binary files differ
diff --git a/test/lua/protofield.lua b/test/lua/protofield.lua
index 9d2223f6..f9ce2dc0 100644
--- a/test/lua/protofield.lua
+++ b/test/lua/protofield.lua
@@ -14,7 +14,7 @@ local n_frames = 4
local taptests = {
[FRAME]=n_frames,
[PER_FRAME]=n_frames*8,
- [OTHER]=50,
+ [OTHER]=52,
}
testlib.init(taptests)
@@ -67,6 +67,9 @@ testlib.test(OTHER,"ProtoField-new-bool-mask-none", success)
success = pcall(ProtoField.new, "boolean", "test.boolean6", ftypes.BOOLEAN, nil, base.NONE, nil)
testlib.test(OTHER,"ProtoField-new-bool-mask-nil", success)
+success = pcall(ProtoField.new, "boolean", "test.boolean7", ftypes.BOOLEAN, nil, base.HEX, "0x00FFFFFF00000000")
+testlib.test(OTHER,"ProtoField-new-bool-mask-hex", success)
+
success = pcall(ProtoField.bool, "test.boolean10", nil, 64, nil, 0x1)
testlib.test(OTHER,"ProtoField-bool-mask-trivial", success)
@@ -109,6 +112,9 @@ testlib.test(OTHER,"ProtoField-new-uint64-mask-none", success)
success = pcall(ProtoField.new, "uint64", "test.uint64_6", ftypes.UINT64, nil, base.NONE, nil)
testlib.test(OTHER,"ProtoField-new-uint64-mask-nil", success)
+success = pcall(ProtoField.new, "uint64", "test.uint64_7", ftypes.UINT64, nil, base.HEX, "0x00FFFFFF00000000")
+testlib.test(OTHER,"ProtoField-new-uint64-mask-hex", success)
+
success = pcall(ProtoField.uint64, "test.uint64_10", nil, base.HEX, nil, 0x1)
testlib.test(OTHER,"ProtoField-uint64-mask-trivial", success)
diff --git a/test/suite_sharkd.py b/test/suite_sharkd.py
index d8c1ef2f..9d883647 100644
--- a/test/suite_sharkd.py
+++ b/test/suite_sharkd.py
@@ -1107,6 +1107,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 +1117,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 +1157,28 @@ class TestSharkd:
},
))
+ def test_sharkd_req_follow_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":"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",
@@ -1230,7 +1258,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 +1334,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):