Skip to content

Commit

Permalink
add test re: issue 97
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadrad committed May 22, 2020
1 parent f0e98c4 commit ea1297e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ipfix/decoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,22 @@ func TestUnknownDatasetsMessage(t *testing.T) {
t.Error("Received unexpected erorr:", err)
}
}

func TestDecodeDataTpl(t *testing.T) {
var payload = []byte{0, 10, 1, 32, 92, 88, 61, 168, 0, 1, 117, 38, 0, 0, 0, 0, 4, 0, 0, 120, 0, 0, 1, 104, 184, 176, 218, 137, 0, 0, 1, 104, 184, 176, 211, 113, 0, 0, 0, 0, 0, 0, 3, 72, 0, 0, 0, 0, 0, 0, 0, 10, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 2, 15, 216, 58, 215, 99, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 104, 184, 176, 218, 137, 0, 0, 1, 104, 184, 176, 211, 113, 0, 0, 0, 0, 0, 0, 3, 72, 0, 0, 0, 0, 0, 0, 0, 10, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216, 58, 215, 99, 10, 0, 2, 15, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 0, 0, 88, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 0, 0, 0, 0, 0, 189, 0, 0, 0, 0, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 128, 0, 0, 0, 0, 0, 0, 31, 12, 114, 32, 178, 94, 204, 189, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251, 0, 20, 233, 20, 233, 0, 17, 0, 0, 0, 4, 0, 0, 64, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 0, 0, 0, 0, 0, 169, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 2, 15, 224, 0, 0, 251, 20, 233, 20, 233, 0, 0, 17, 0, 0, 0}
var tpl = []byte{0, 10, 1, 32, 92, 88, 61, 152, 0, 1, 117, 22, 0, 0, 0, 0, 0, 2, 0, 68, 4, 0, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 8, 0, 4, 0, 12, 0, 4, 0, 7, 0, 2, 0, 11, 0, 2, 0, 5, 0, 1, 0, 6, 0, 1, 0, 4, 0, 1, 0, 2, 0, 68, 4, 1, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 8, 0, 4, 0, 12, 0, 4, 0, 7, 0, 2, 0, 11, 0, 2, 0, 5, 0, 1, 0, 6, 0, 1, 0, 4, 0, 1, 0, 2, 0, 68, 8, 0, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 27, 0, 16, 0, 28, 0, 16, 0, 5, 0, 1, 0, 7, 0, 2, 0, 11, 0, 2, 0, 6, 0, 1, 0, 4, 0, 1, 0, 2, 0, 68, 8, 1, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 27, 0, 16, 0, 28, 0, 16, 0, 5, 0, 1, 0, 7, 0, 2, 0, 11, 0, 2, 0, 6, 0, 1, 0, 4, 0, 1}

ip := net.ParseIP("127.0.0.1")
templates := GetCache("")
d := NewDecoder(ip, tpl)
_, err := d.Decode(templates)
if err != nil {
t.Error(err)
}

d = NewDecoder(ip, payload)
_, err = d.Decode(templates)
if err != nil {
t.Error(err)
}
}

0 comments on commit ea1297e

Please sign in to comment.