MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestRuleSet_MatchRequest

Function TestRuleSet_MatchRequest

internal/waf/rule_set_test.go:16–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func 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
46func TestRuleSet_MatchRequest2(t *testing.T) {
47 var a = assert.NewAssertion(t)

Callers

nothing calls this directly

Calls 5

NewRuleSetFunction · 0.92
NewTestRequestFunction · 0.92
LogMethod · 0.80
InitMethod · 0.65
MatchRequestMethod · 0.45

Tested by

no test coverage detected