(t *testing.T)
| 44 | } |
| 45 | |
| 46 | func TestRuleSet_MatchRequest2(t *testing.T) { |
| 47 | var a = assert.NewAssertion(t) |
| 48 | |
| 49 | var set = waf.NewRuleSet() |
| 50 | set.Connector = waf.RuleConnectorOr |
| 51 | |
| 52 | set.Rules = []*waf.Rule{ |
| 53 | { |
| 54 | Param: "${arg.name}", |
| 55 | Operator: waf.RuleOperatorEqString, |
| 56 | Value: "lu", |
| 57 | }, |
| 58 | { |
| 59 | Param: "${arg.age}", |
| 60 | Operator: waf.RuleOperatorEq, |
| 61 | Value: "21", |
| 62 | }, |
| 63 | } |
| 64 | |
| 65 | err := set.Init(nil) |
| 66 | if err != nil { |
| 67 | t.Fatal(err) |
| 68 | } |
| 69 | |
| 70 | rawReq, err := http.NewRequest(http.MethodGet, "http://teaos.cn/hello?name=lu&age=20", nil) |
| 71 | if err != nil { |
| 72 | t.Fatal(err) |
| 73 | } |
| 74 | req := requests.NewTestRequest(rawReq) |
| 75 | a.IsTrue(set.MatchRequest(req)) |
| 76 | } |
| 77 | |
| 78 | func TestRuleSet_MatchRequest_Allow(t *testing.T) { |
| 79 | var a = assert.NewAssertion(t) |
nothing calls this directly
no test coverage detected