(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func 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 |
nothing calls this directly
no test coverage detected