inlet/flow: replace raw data test files with PCAP files

Raw data files can be converted with Scapy:

```python
from scapy.all import *
wrpcap("data-1140.pcap",
  Ether(src="00:53:00:11:22:33",dst="00:53:00:44:55:66")/
  IP(src="192.0.2.100", dst="192.0.2.101")/
  UDP(sport=47873,dport=6343)/
  open("data-1140.data", "rb").read())
```
This commit is contained in:
Vincent Bernat
2022-09-09 11:25:39 +02:00
parent 1587c5ff44
commit f8a795282e
15 changed files with 70 additions and 42 deletions

View File

@@ -4,7 +4,6 @@
package netflow
import (
"io/ioutil"
"net"
"path/filepath"
"testing"
@@ -19,10 +18,7 @@ func TestDecode(t *testing.T) {
nfdecoder := New(r)
// Send an option template
template, err := ioutil.ReadFile(filepath.Join("testdata", "options-template-257.data"))
if err != nil {
panic(err)
}
template := helpers.ReadPcapPayload(t, filepath.Join("testdata", "options-template-257.pcap"))
got := nfdecoder.Decode(decoder.RawFlow{Payload: template, Source: net.ParseIP("127.0.0.1")})
if got == nil {
t.Fatalf("Decode() error on options template")
@@ -44,10 +40,7 @@ func TestDecode(t *testing.T) {
}
// Send option data
data, err := ioutil.ReadFile(filepath.Join("testdata", "options-data-257.data"))
if err != nil {
panic(err)
}
data := helpers.ReadPcapPayload(t, filepath.Join("testdata", "options-data-257.pcap"))
got = nfdecoder.Decode(decoder.RawFlow{Payload: data, Source: net.ParseIP("127.0.0.1")})
if got == nil {
t.Fatalf("Decode() error on options data")
@@ -71,10 +64,7 @@ func TestDecode(t *testing.T) {
}
// Send a regular template
template, err = ioutil.ReadFile(filepath.Join("testdata", "template-260.data"))
if err != nil {
panic(err)
}
template = helpers.ReadPcapPayload(t, filepath.Join("testdata", "template-260.pcap"))
got = nfdecoder.Decode(decoder.RawFlow{Payload: template, Source: net.ParseIP("127.0.0.1")})
if got == nil {
t.Fatalf("Decode() error on template")
@@ -101,10 +91,7 @@ func TestDecode(t *testing.T) {
}
// Send data
data, err = ioutil.ReadFile(filepath.Join("testdata", "data-260.data"))
if err != nil {
panic(err)
}
data = helpers.ReadPcapPayload(t, filepath.Join("testdata", "data-260.pcap"))
got = nfdecoder.Decode(decoder.RawFlow{Payload: data, Source: net.ParseIP("127.0.0.1")})
if got == nil {
t.Fatalf("Decode() error on data")