-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenricher_test.go
43 lines (37 loc) · 1.06 KB
/
enricher_test.go
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
package main
import (
"bytes"
"encoding/json"
"os"
"testing"
"github.com/stretchr/testify/require"
)
func TestEnricher(t *testing.T) {
table := []struct {
file string
}{
{file: "testdata/record.txt"},
{file: "testdata/record1.txt"},
{file: "testdata/record2.txt"},
{file: "testdata/record3.txt"},
{file: "testdata/record4.txt"},
}
for _, tt := range table {
sc, err := newEnricher(
enricherWithCRS("crs/coraza.conf", "crs/crs-setup.conf", "crs/rules/*.conf"),
enricherWithOptionalGeoIP("testdata/GeoLite2-City-Test.mmdb"),
)
require.Nil(t, err, "unexpected error in instantiating scorer")
f, err := os.ReadFile(tt.file)
require.Nil(t, err, "unexpected error in reading test data")
s, err := sc.EnrichRecord(bytes.NewReader(f))
require.NoError(t, err, "should not return error")
require.NotNil(t, s, "should produce non nil score")
defer s.Close()
ecs, err := s.toECS()
require.NoError(t, err, "should not return error")
require.NotNil(t, ecs, "should produce non nil score")
b, _ := json.Marshal(ecs)
t.Log(string(b))
}
}