Beispiel #1
0
def test_sort_pcap():
    f = lambda x: os.path.join("tests", "files", "pcap", x)
    h = lambda x: hashlib.sha1(open(x, "rb").read()).hexdigest()

    filepath = tempfile.mktemp()
    sort_pcap(f("smtp.pcap"), filepath)
    assert h(filepath) == "c99b74eaca15d792049e8f75a4bfe6c1c416c26b"

    filepath = tempfile.mktemp()
    sort_pcap(f("duplicate-dns-requests.pcap"), filepath)
    assert h(filepath) == "4859334accbee12858621cca39564fdbce9ae605"

    filepath = tempfile.mktemp()
    sort_pcap(f("mixed-traffic.pcap"), filepath)
    assert h(filepath) == "8d92880f9f356d5bdfd04e24541f614f275b02e0"

    filepath = tempfile.mktemp()
    sort_pcap(f("not-http.pcap"), filepath)
    assert h(filepath) == "340e6c442619de912253d956b499e428164e8cdd"

    filepath = tempfile.mktemp()
    sort_pcap(f("status-code.pcap"), filepath)
    assert h(filepath) == "106dc235ef82ff844b7025339c2713aad752037e"

    filepath = tempfile.mktemp()
    sort_pcap(f("used_dns_server.pcap"), filepath)
    assert h(filepath) == "782b766b99998fd8cbbe400b7c419abfe645b50d"
Beispiel #2
0
def test_sort_pcap_rm_temp(p):
    filepath = tempfile.mktemp()
    sort_pcap("tests/files/pcap/smtp.pcap", filepath)
    p.assert_called_once()
    assert p.call_args[0][0].startswith(tempfile.gettempdir())