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

Function TestRuleSet_MatchRequest2

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

Source from the content-addressed store, hash-verified

44}
45
46func 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
78func TestRuleSet_MatchRequest_Allow(t *testing.T) {
79 var a = assert.NewAssertion(t)

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected