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

Function Test_Template2

internal/waf/template_test.go:42–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func Test_Template2(t *testing.T) {
43 reader := bytes.NewReader([]byte(strings.Repeat("HELLO", 1024)))
44 req, err := http.NewRequest(http.MethodPost, "https://example.com/index.php?id=123", reader)
45 if err != nil {
46 t.Fatal(err)
47 }
48
49 wafInstance, err := waf.Template()
50 if err != nil {
51 t.Fatal(err)
52 }
53
54 now := time.Now()
55 result, err := wafInstance.MatchRequest(requests.NewTestRequest(req), nil, firewallconfigs.ServerCaptchaTypeNone)
56 if err != nil {
57 t.Fatal(err)
58 }
59 t.Log(time.Since(now).Seconds()*1000, "ms")
60
61 if result.GoNext {
62 t.Log("ok")
63 return
64 }
65
66 logs.PrintAsJSON(result.Set, t)
67}
68
69func BenchmarkTemplate(b *testing.B) {
70 runtime.GOMAXPROCS(4)

Callers

nothing calls this directly

Calls 4

TemplateFunction · 0.92
NewTestRequestFunction · 0.92
LogMethod · 0.80
MatchRequestMethod · 0.45

Tested by

no test coverage detected