Skip to content

Commit

Permalink
Add tests for basic chain
Browse files Browse the repository at this point in the history
  • Loading branch information
irl committed Apr 18, 2017
1 parent de482ae commit 42d0131
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 10 deletions.
Binary file added pathspider/tests/data/basic_ipv4_tcp.pcap
Binary file not shown.
Binary file added pathspider/tests/data/basic_ipv6_tcp.pcap
Binary file not shown.
62 changes: 52 additions & 10 deletions pathspider/tests/test_chain_basic.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@

# TODO: Need some basic chain tests
# 1. Packet counts
# 2. Octet counts
# 3. Port numbers and addresses for IPv4/TCP
# 4. Port numbers and addresses for IPv4/UDP
# 5. Port numbers and addresses for IPv6/TCP
# 6. Port numbers and addresses for IPv6/UDP
# 7. Port numbers and addresses for IPv4/SCTP
# 8. Port numbers and addresses for IPv4/UDP-Lite
# 9. Port numbers and addresses for IPv4/DCCP
from pathspider.tests.chains import ChainTestCase

from pathspider.chains.basic import BasicChain

class TestBasicChain(ChainTestCase):



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]

0 comments on commit 42d0131

Please sign in to comment.