github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/checkpoints/request_referer_origin_test.go (about) 1 package checkpoints_test 2 3 import ( 4 "github.com/TeaOSLab/EdgeNode/internal/waf/checkpoints" 5 "github.com/TeaOSLab/EdgeNode/internal/waf/requests" 6 "net/http" 7 "testing" 8 ) 9 10 func TestRequestRefererOriginCheckpoint_RequestValue(t *testing.T) { 11 rawReq, err := http.NewRequest(http.MethodGet, "https://example.com", nil) 12 if err != nil { 13 t.Fatal(err) 14 } 15 var req = requests.NewTestRequest(rawReq) 16 17 var checkpoint = &checkpoints.RequestRefererOriginCheckpoint{} 18 19 { 20 t.Log(checkpoint.RequestValue(req, "", nil, 0)) 21 } 22 23 { 24 rawReq.Header.Set("Referer", "https://example.com/hello.yaml") 25 t.Log(checkpoint.RequestValue(req, "", nil, 0)) 26 } 27 28 { 29 rawReq.Header.Set("Origin", "https://example.com/world.yaml") 30 t.Log(checkpoint.RequestValue(req, "", nil, 0)) 31 } 32 33 { 34 rawReq.Header.Del("Referer") 35 rawReq.Header.Set("Origin", "https://example.com/world.yaml") 36 t.Log(checkpoint.RequestValue(req, "", nil, 0)) 37 } 38 }