sigs.k8s.io/gateway-api@v1.0.0/conformance/tests/mesh-consumer-route.go (about) 1 /* 2 Copyright 2023 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package tests 18 19 import ( 20 "testing" 21 22 "sigs.k8s.io/gateway-api/conformance/utils/echo" 23 "sigs.k8s.io/gateway-api/conformance/utils/http" 24 "sigs.k8s.io/gateway-api/conformance/utils/suite" 25 ) 26 27 func init() { 28 ConformanceTests = append(ConformanceTests, MeshConsumerRoute) 29 } 30 31 var MeshConsumerRoute = suite.ConformanceTest{ 32 ShortName: "MeshConsumerRoute", 33 Description: "An HTTPRoute in a namespace other than its parentRef's namespace only affects requests from the route's namespace", 34 Features: []suite.SupportedFeature{ 35 suite.SupportMesh, 36 suite.SupportHTTPRoute, 37 suite.SupportHTTPRouteResponseHeaderModification, 38 }, 39 Manifests: []string{"tests/mesh-consumer-route.yaml"}, 40 Test: func(t *testing.T, s *suite.ConformanceTestSuite) { 41 consumerClient := echo.ConnectToAppInNamespace(t, s, echo.MeshAppEchoV1, "gateway-conformance-mesh-consumer") 42 consumerCases := []http.ExpectedResponse{ 43 { 44 TestCaseName: "request from consumer route's namespace modified by HTTPRoute", 45 Request: http.Request{ 46 Host: "echo-v1.gateway-conformance-mesh", 47 Method: "GET", 48 Path: "/", 49 }, 50 Response: http.Response{ 51 StatusCode: 200, 52 Headers: map[string]string{ 53 "X-Header-Set": "set", 54 }, 55 }, 56 Backend: "echo-v1", 57 }, 58 } 59 producerClient := echo.ConnectToAppInNamespace(t, s, echo.MeshAppEchoV1, "gateway-conformance-mesh") 60 producerCases := []http.ExpectedResponse{ 61 { 62 TestCaseName: "request not from consumer route's namespace not modified by HTTPRoute", 63 Request: http.Request{ 64 Host: "echo-v1.gateway-conformance-mesh", 65 Method: "GET", 66 Path: "/", 67 }, 68 Response: http.Response{ 69 StatusCode: 200, 70 AbsentHeaders: []string{"X-Header-Set"}, 71 }, 72 Backend: "echo-v1", 73 }, 74 } 75 for i, tc := range consumerCases { 76 t.Run(tc.GetTestCaseName(i), func(t *testing.T) { 77 consumerClient.MakeRequestAndExpectEventuallyConsistentResponse(t, tc, s.TimeoutConfig) 78 }) 79 } 80 for i, tc := range producerCases { 81 t.Run(tc.GetTestCaseName(i), func(t *testing.T) { 82 producerClient.MakeRequestAndExpectEventuallyConsistentResponse(t, tc, s.TimeoutConfig) 83 }) 84 } 85 }, 86 }