-
Notifications
You must be signed in to change notification settings - Fork 10
/
test_chain_basic.py
54 lines (42 loc) · 1.41 KB
/
test_chain_basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from pathspider.tests.chains import ChainTestCase
from pathspider.chains.basic import BasicChain
class TestBasicChain(ChainTestCase):
# TODO: Add tests for UDP/SCTP/UDP-lite/DCCP
def test_chain_basic_ipv4_tcp(self):
test_trace = "basic_ipv4_tcp.pcap"
self.create_observer(test_trace, [BasicChain])
expected_basic = {
'oct_fwd': 1747,
'dp': 80,
'pkt_rev': 32,
'pkt_fwd': 32,
'proto': 6,
'oct_rev': 41030,
'sip': '139.133.208.62',
'sp': 38878,
'dip': '139.133.1.4'
}
flows = self.run_observer()
print(flows)
assert len(flows) == 1
for key in expected_basic:
assert flows[0][key] == expected_basic[key]
def test_chain_basic_ipv6_tcp(self):
test_trace = "basic_ipv6_tcp.pcap"
self.create_observer(test_trace, [BasicChain])
expected_basic = {
'oct_fwd': 514,
'dp': 80,
'pkt_rev': 4,
'pkt_fwd': 6,
'proto': 6,
'oct_rev': 799,
'sip': '2001:630:241:20f:c2ea:e939:f310:9c32',
'sp': 39956,
'dip': '2a00:1450:4009:810::200e',
}
flows = self.run_observer()
print(flows)
assert len(flows) == 1
for key in expected_basic:
assert flows[0][key] == expected_basic[key]