From 56e805f7682674706faf6149676483ab9a798a96 Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Wed, 15 Feb 2023 10:06:27 +0800 Subject: [PATCH] e2e: add cors forbidden origin case (#187) Signed-off-by: bitliu --- .../tests/httproute-enable-cors.go | 22 ++++++++++++++++++- .../tests/httproute-enable-cors.yaml | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/test/ingress/conformance/tests/httproute-enable-cors.go b/test/ingress/conformance/tests/httproute-enable-cors.go index d7256e940..cf9507415 100644 --- a/test/ingress/conformance/tests/httproute-enable-cors.go +++ b/test/ingress/conformance/tests/httproute-enable-cors.go @@ -73,7 +73,7 @@ var HTTPRouteEnableCors = suite.ConformanceTest{ }, }, { Meta: http.AssertionMeta{ - TestCaseName: "case3: enable cors and allow headers", + TestCaseName: "case3: enable cors and allow origin headers", TargetBackend: "infra-backend-v3", TargetNamespace: "higress-conformance-infra", }, @@ -91,6 +91,26 @@ var HTTPRouteEnableCors = suite.ConformanceTest{ Headers: map[string]string{"Access-Control-Allow-Credentials": "true", "Access-Control-Allow-Origin": "http://bar.com", "Access-Control-Expose-Headers": "*"}, }, }, + }, { + Meta: http.AssertionMeta{ + TestCaseName: "case4: enable cors and use forbidden Origin", + TargetBackend: "infra-backend-v3", + TargetNamespace: "higress-conformance-infra", + }, + Request: http.AssertionRequest{ + ActualRequest: http.Request{ + Path: "/foo", + Host: "foo3.com", + Method: "OPTIONS", + Headers: map[string]string{"Origin": "http://foo.com"}, + }, + }, + Response: http.AssertionResponse{ + ExpectedResponse: http.Response{ + StatusCode: 200, + AbsentHeaders: []string{"Access-Control-Allow-Credentials", "Access-Control-Allow-Origin", "Access-Control-Expose-Headers"}, + }, + }, }, } diff --git a/test/ingress/conformance/tests/httproute-enable-cors.yaml b/test/ingress/conformance/tests/httproute-enable-cors.yaml index 8ad192ad8..1eaf2b9a2 100644 --- a/test/ingress/conformance/tests/httproute-enable-cors.yaml +++ b/test/ingress/conformance/tests/httproute-enable-cors.yaml @@ -79,4 +79,4 @@ spec: service: name: infra-backend-v3 port: - number: 8080 \ No newline at end of file + number: 8080