forked from corazawaf/coraza
-
Notifications
You must be signed in to change notification settings - Fork 0
/
waf_test.go
43 lines (37 loc) · 977 Bytes
/
waf_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
// Copyright 2022 Juan Pablo Tosso and the OWASP Coraza contributors
// SPDX-License-Identifier: Apache-2.0
package coraza
import "testing"
func TestNewWAFLimits(t *testing.T) {
testCases := map[string]struct {
expectedErr string
cfg requestBodyConfig
}{
"empty limit": {
cfg: requestBodyConfig{},
expectedErr: "request body limit should be bigger than 0",
},
"memory limit bigger than limit": {
cfg: requestBodyConfig{
limit: 5,
inMemoryLimit: 9,
},
expectedErr: "request body limit should be at least the memory limit",
},
}
for name, tCase := range testCases {
t.Run(name, func(t *testing.T) {
_, err := NewWAF(&wafConfig{
requestBody: &tCase.cfg,
})
if tCase.expectedErr != "" {
if err == nil {
t.Fatal("expected error")
}
if want, have := tCase.expectedErr, err.Error(); want != have {
t.Fatalf("unexpected error: want %q, have %q", want, have)
}
}
})
}
}