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

Function TestWAF_MatchRequest_Allow

internal/waf/waf_test.go:60–135  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestWAF_MatchRequest_Allow(t *testing.T) {
61 var a = assert.NewAssertion(t)
62
63 var wafInstance = waf.NewWAF()
64
65 {
66 var set = waf.NewRuleSet()
67 set.Id = 1
68 set.Name = "set1"
69 set.Connector = waf.RuleConnectorAnd
70 set.Rules = []*waf.Rule{
71 {
72 Param: "${requestPath}",
73 Operator: waf.RuleOperatorMatch,
74 Value: "hello",
75 },
76 }
77 set.AddAction(waf.ActionAllow, maps.Map{
78 "scope": "global",
79 })
80
81 var group = waf.NewRuleGroup()
82 group.Id = 1
83 group.AddRuleSet(set)
84 group.IsInbound = true
85
86 wafInstance.AddRuleGroup(group)
87 }
88
89 {
90 var set = waf.NewRuleSet()
91 set.Id = 2
92 set.Name = "set2"
93 set.Connector = waf.RuleConnectorAnd
94 set.Rules = []*waf.Rule{
95 {
96 Param: "${requestPath}",
97 Operator: waf.RuleOperatorMatch,
98 Value: "he",
99 },
100 }
101 set.AddAction(waf.ActionAllow, maps.Map{
102 "scope": "global",
103 })
104
105 var group = waf.NewRuleGroup()
106 group.Id = 2
107 group.AddRuleSet(set)
108 group.IsInbound = true
109
110 wafInstance.AddRuleGroup(group)
111 }
112
113 errs := wafInstance.Init()
114 if len(errs) > 0 {
115 t.Fatal(errs[0])
116 }
117

Callers

nothing calls this directly

Calls 10

NewWAFFunction · 0.92
NewRuleSetFunction · 0.92
NewRuleGroupFunction · 0.92
NewTestRequestFunction · 0.92
AddRuleSetMethod · 0.80
AddRuleGroupMethod · 0.80
LogMethod · 0.80
InitMethod · 0.65
AddActionMethod · 0.45
MatchRequestMethod · 0.45

Tested by

no test coverage detected