diff --git a/test/ingress/conformance/tests/httproute-request-header-control.go b/test/ingress/conformance/tests/httproute-request-header-control.go index 0c0f3c14a..42cb90688 100644 --- a/test/ingress/conformance/tests/httproute-request-header-control.go +++ b/test/ingress/conformance/tests/httproute-request-header-control.go @@ -32,6 +32,12 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{ Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { testcases := []http.Assertion{ { + Meta: http.AssertionMeta{ + TestCaseName: "case 1: add one", + TargetBackend: "infra-backend-v1", + TargetNamespace: "higress-conformance-infra", + }, + Request: http.AssertionRequest{ ActualRequest: http.Request{ Path: "/foo1", @@ -39,6 +45,8 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{ }, ExpectedRequest: &http.ExpectedRequest{ Request: http.Request{ + Path: "/foo1", + Host: "foo.com", Headers: map[string]string{ "stage": "test", }, @@ -53,6 +61,12 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{ }, }, { + Meta: http.AssertionMeta{ + TestCaseName: "case 2: add more", + TargetBackend: "infra-backend-v1", + TargetNamespace: "higress-conformance-infra", + }, + Request: http.AssertionRequest{ ActualRequest: http.Request{ Path: "/foo2", @@ -60,6 +74,8 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{ }, ExpectedRequest: &http.ExpectedRequest{ Request: http.Request{ + Path: "/foo2", + Host: "foo.com", Headers: map[string]string{ "stage": "test", "canary": "true", @@ -75,6 +91,12 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{ }, }, { + Meta: http.AssertionMeta{ + TestCaseName: "case 3: update one", + TargetBackend: "infra-backend-v1", + TargetNamespace: "higress-conformance-infra", + }, + Request: http.AssertionRequest{ ActualRequest: http.Request{ Path: "/foo3", @@ -85,9 +107,10 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{ }, ExpectedRequest: &http.ExpectedRequest{ Request: http.Request{ + Path: "/foo3", + Host: "foo.com", Headers: map[string]string{ - "stage": "pro", - "canary": "true", + "stage": "pro", }, }, }, @@ -100,19 +123,94 @@ var HTTPRouteRequestHeaderControl = suite.ConformanceTest{ }, }, { + Meta: http.AssertionMeta{ + TestCaseName: "case 4: update more", + TargetBackend: "infra-backend-v1", + TargetNamespace: "higress-conformance-infra", + }, + Request: http.AssertionRequest{ ActualRequest: http.Request{ Path: "/foo4", Host: "foo.com", + Headers: map[string]string{ + "stage": "test", + "canary": "true", + }, + }, + ExpectedRequest: &http.ExpectedRequest{ + Request: http.Request{ + Path: "/foo4", + Host: "foo.com", + Headers: map[string]string{ + "stage": "pro", + "canary": "false", + }, + }, + }, + }, + + Response: http.AssertionResponse{ + ExpectedResponse: http.Response{ + StatusCode: 200, + }, + }, + }, + { + Meta: http.AssertionMeta{ + TestCaseName: "case 5: remove one", + TargetBackend: "infra-backend-v1", + TargetNamespace: "higress-conformance-infra", + }, + + Request: http.AssertionRequest{ + ActualRequest: http.Request{ + Path: "/foo5", + Host: "foo.com", Headers: map[string]string{ "stage": "test", }, }, ExpectedRequest: &http.ExpectedRequest{ + Request: http.Request{ + Path: "/foo5", + Host: "foo.com", + }, AbsentHeaders: []string{"stage"}, }, }, + Response: http.AssertionResponse{ + ExpectedResponse: http.Response{ + StatusCode: 200, + }, + }, + }, + { + Meta: http.AssertionMeta{ + TestCaseName: "case 6: remove more", + TargetBackend: "infra-backend-v1", + TargetNamespace: "higress-conformance-infra", + }, + + Request: http.AssertionRequest{ + ActualRequest: http.Request{ + Path: "/foo6", + Host: "foo.com", + Headers: map[string]string{ + "stage": "test", + "canary": "true", + }, + }, + ExpectedRequest: &http.ExpectedRequest{ + Request: http.Request{ + Path: "/foo6", + Host: "foo.com", + }, + AbsentHeaders: []string{"stage", "canary"}, + }, + }, + Response: http.AssertionResponse{ ExpectedResponse: http.Response{ StatusCode: 200, diff --git a/test/ingress/conformance/tests/httproute-request-header-control.yaml b/test/ingress/conformance/tests/httproute-request-header-control.yaml index 3b0cf83a9..8126b0f2c 100644 --- a/test/ingress/conformance/tests/httproute-request-header-control.yaml +++ b/test/ingress/conformance/tests/httproute-request-header-control.yaml @@ -61,7 +61,7 @@ kind: Ingress metadata: annotations: higress.io/request-header-control-update: stage pro - name: httproute-request-header-control-update + name: httproute-request-header-control-update-one namespace: higress-conformance-infra spec: ingressClassName: higress @@ -81,8 +81,10 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: annotations: - higress.io/request-header-control-remove: stage - name: httproute-request-header-control-remove + higress.io/request-header-control-update: | + stage pro + canary false + name: httproute-request-header-control-update-more namespace: higress-conformance-infra spec: ingressClassName: higress @@ -97,3 +99,45 @@ spec: name: infra-backend-v1 port: number: 8080 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + higress.io/request-header-control-remove: stage + name: httproute-request-header-control-remove-one + namespace: higress-conformance-infra +spec: + ingressClassName: higress + rules: + - host: "foo.com" + http: + paths: + - pathType: Exact + path: "/foo5" + backend: + service: + name: infra-backend-v1 + port: + number: 8080 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + higress.io/request-header-control-remove: stage,canary + name: httproute-request-header-control-remove-more + namespace: higress-conformance-infra +spec: + ingressClassName: higress + rules: + - host: "foo.com" + http: + paths: + - pathType: Exact + path: "/foo6" + backend: + service: + name: infra-backend-v1 + port: + number: 8080 diff --git a/test/ingress/e2e_test.go b/test/ingress/e2e_test.go index 443e7ba6f..f4b332cf3 100644 --- a/test/ingress/e2e_test.go +++ b/test/ingress/e2e_test.go @@ -72,6 +72,7 @@ func TestHigressConformanceTests(t *testing.T) { tests.HTTPRouteMatchPath, tests.HttpForceRedirectHttps, tests.HttpRedirectAsHttps, + tests.HTTPRouteRequestHeaderControl, } cSuite.Run(t, higressTests)