mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-19 20:40:26 +08:00
WAF参数中增加“请求来源”
This commit is contained in:
38
internal/waf/checkpoints/request_referer_origin_test.go
Normal file
38
internal/waf/checkpoints/request_referer_origin_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package checkpoints_test
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints"
|
||||
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||||
"net/http"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRequestRefererOriginCheckpoint_RequestValue(t *testing.T) {
|
||||
rawReq, err := http.NewRequest(http.MethodGet, "https://example.com", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var req = requests.NewTestRequest(rawReq)
|
||||
|
||||
var checkpoint = &checkpoints.RequestRefererOriginCheckpoint{}
|
||||
|
||||
{
|
||||
t.Log(checkpoint.RequestValue(req, "", nil, 0))
|
||||
}
|
||||
|
||||
{
|
||||
rawReq.Header.Set("Referer", "https://example.com/hello.yaml")
|
||||
t.Log(checkpoint.RequestValue(req, "", nil, 0))
|
||||
}
|
||||
|
||||
{
|
||||
rawReq.Header.Set("Origin", "https://example.com/world.yaml")
|
||||
t.Log(checkpoint.RequestValue(req, "", nil, 0))
|
||||
}
|
||||
|
||||
{
|
||||
rawReq.Header.Del("Referer")
|
||||
rawReq.Header.Set("Origin", "https://example.com/world.yaml")
|
||||
t.Log(checkpoint.RequestValue(req, "", nil, 0))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user