(t *testing.T)
| 14 | ) |
| 15 | |
| 16 | func TestRuleSet_MatchRequest(t *testing.T) { |
| 17 | var set = waf.NewRuleSet() |
| 18 | set.Connector = waf.RuleConnectorAnd |
| 19 | |
| 20 | set.Rules = []*waf.Rule{ |
| 21 | { |
| 22 | Param: "${arg.name}", |
| 23 | Operator: waf.RuleOperatorEqString, |
| 24 | Value: "lu", |
| 25 | }, |
| 26 | { |
| 27 | Param: "${arg.age}", |
| 28 | Operator: waf.RuleOperatorEq, |
| 29 | Value: "20", |
| 30 | }, |
| 31 | } |
| 32 | |
| 33 | err := set.Init(nil) |
| 34 | if err != nil { |
| 35 | t.Fatal(err) |
| 36 | } |
| 37 | |
| 38 | rawReq, err := http.NewRequest(http.MethodGet, "http://teaos.cn/hello?name=lu&age=20", nil) |
| 39 | if err != nil { |
| 40 | t.Fatal(err) |
| 41 | } |
| 42 | req := requests.NewTestRequest(rawReq) |
| 43 | t.Log(set.MatchRequest(req)) |
| 44 | } |
| 45 | |
| 46 | func TestRuleSet_MatchRequest2(t *testing.T) { |
| 47 | var a = assert.NewAssertion(t) |
nothing calls this directly
no test coverage detected