Skip to content

Commit 4fa06d7

Browse files
committed
skip some test on windows since coraza crs not support windows for now
1 parent acdda75 commit 4fa06d7

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

pkg/filters/waf/waf_test.go

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package waf
2020
import (
2121
"net/http"
2222
"os"
23+
"runtime"
2324
"testing"
2425

2526
"github.com/stretchr/testify/assert"
@@ -82,7 +83,8 @@ ruleGroupName: test-waf-group
8283

8384
// test with WAF rule group
8485
{
85-
controllerConfig := `
86+
if runtime.GOOS != "windows" {
87+
controllerConfig := `
8688
kind: WAFController
8789
name: waf-controller
8890
ruleGroups:
@@ -93,26 +95,28 @@ ruleGroups:
9395
- REQUEST-942-APPLICATION-ATTACK-SQLI.conf
9496
- REQUEST-949-BLOCKING-EVALUATION.conf
9597
`
96-
super := supervisor.NewMock(option.New(), nil, nil, nil, false, nil, nil)
97-
spec, err := super.NewSpec(controllerConfig)
98-
assert.Nil(err, "Failed to create WAFController spec")
99-
controller := wafcontroller.WAFController{}
100-
controller.Init(spec)
101-
102-
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/test?id=1' OR '1'='1", nil)
103-
assert.Nil(err, "Failed to create HTTP request")
104-
setRequest(t, ctx, "controller", req)
105-
result := p.Handle(ctx)
106-
assert.Equal(string(protocol.ResultBlocked), result)
107-
108-
resp := ctx.GetResponse("controller").(*httpprot.Response)
109-
assert.Equal(http.StatusInternalServerError, resp.StatusCode(), "Expected status code to be 500 Internal Server Error")
110-
111-
controller.Close()
98+
super := supervisor.NewMock(option.New(), nil, nil, nil, false, nil, nil)
99+
spec, err := super.NewSpec(controllerConfig)
100+
assert.Nil(err, "Failed to create WAFController spec")
101+
controller := wafcontroller.WAFController{}
102+
controller.Init(spec)
103+
104+
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:8080/test?id=1' OR '1'='1", nil)
105+
assert.Nil(err, "Failed to create HTTP request")
106+
setRequest(t, ctx, "controller", req)
107+
result := p.Handle(ctx)
108+
assert.Equal(string(protocol.ResultBlocked), result)
109+
110+
resp := ctx.GetResponse("controller").(*httpprot.Response)
111+
assert.Equal(http.StatusInternalServerError, resp.StatusCode(), "Expected status code to be 500 Internal Server Error")
112+
113+
controller.Close()
114+
}
112115
}
113116

114117
{
115-
controllerConfig := `
118+
if runtime.GOOS != "windows" {
119+
controllerConfig := `
116120
kind: WAFController
117121
name: waf-controller
118122
ruleGroups:
@@ -136,17 +140,18 @@ ruleGroups:
136140
setvar:tx.crs_setup_version=4160"
137141
`
138142

139-
super := supervisor.NewMock(option.New(), nil, nil, nil, false, nil, nil)
140-
spec, err := super.NewSpec(controllerConfig)
141-
assert.Nil(err, "Failed to create WAFController spec")
142-
controller := wafcontroller.WAFController{}
143-
controller.Init(spec)
144-
145-
req, err := http.NewRequest(http.MethodGet, "http://127.0.1:8080/[email protected]", nil)
146-
assert.Nil(err, "Failed to create HTTP request")
147-
setRequest(t, ctx, "controller", req)
148-
result := p.Handle(ctx)
149-
assert.Equal(string(protocol.ResultOk), result)
143+
super := supervisor.NewMock(option.New(), nil, nil, nil, false, nil, nil)
144+
spec, err := super.NewSpec(controllerConfig)
145+
assert.Nil(err, "Failed to create WAFController spec")
146+
controller := wafcontroller.WAFController{}
147+
controller.Init(spec)
148+
149+
req, err := http.NewRequest(http.MethodGet, "http://127.0.1:8080/[email protected]", nil)
150+
assert.Nil(err, "Failed to create HTTP request")
151+
setRequest(t, ctx, "controller", req)
152+
result := p.Handle(ctx)
153+
assert.Equal(string(protocol.ResultOk), result)
154+
}
150155
}
151156

152157
{

pkg/object/wafcontroller/rulegroup_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !windows
2+
13
/*
24
* Copyright (c) 2017, The Easegress Authors
35
* All rights reserved.

0 commit comments

Comments
 (0)