1
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, MeshPorts)
29 }
30
31 var MeshPorts = suite.ConformanceTest{
32 ShortName: "MeshPorts",
33 Description: "A mesh route can optionally configure 'port' in parentRef",
34 Features: []suite.SupportedFeature{
35 suite.SupportMesh,
36 suite.SupportHTTPRoute,
37 suite.SupportHTTPRouteResponseHeaderModification,
38 },
39 Manifests: []string{"tests/mesh-ports.yaml"},
40 Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
41 client := echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
42 cases := []http.ExpectedResponse{
43 {
44 TestCaseName: "Explicit port set, send to that port",
45 Request: http.Request{
46 Host: "echo-v1",
47 Method: "GET",
48 },
49 Response: http.Response{
50 StatusCode: 200,
51
52 Headers: map[string]string{
53 "X-Header-Set": "v1",
54 },
55 },
56 Backend: "echo-v1",
57 },
58 {
59 TestCaseName: "Explicit port, send to an excluded port",
60 Request: http.Request{
61 Host: "echo-v1:8080",
62 Method: "GET",
63 },
64 Response: http.Response{
65 StatusCode: 200,
66
67 AbsentHeaders: []string{"X-Header-Set"},
68 },
69 Backend: "echo-v1",
70 },
71 {
72 TestCaseName: "No port set",
73 Request: http.Request{
74 Host: "echo-v2",
75 Method: "GET",
76 },
77 Response: http.Response{
78 StatusCode: 200,
79 Headers: map[string]string{
80 "X-Header-Set": "v2",
81 },
82 },
83 Backend: "echo-v2",
84 },
85 {
86 TestCaseName: "No port set",
87 Request: http.Request{
88 Host: "echo-v2:8080",
89 Method: "GET",
90 },
91 Response: http.Response{
92 StatusCode: 200,
93 Headers: map[string]string{
94 "X-Header-Set": "v2",
95 },
96 },
97 Backend: "echo-v2",
98 },
99 }
100 for i := range cases {
101
102
103 tc := cases[i]
104 t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
105 client.MakeRequestAndExpectEventuallyConsistentResponse(t, tc, s.TimeoutConfig)
106 })
107 }
108 },
109 }
110
View as plain text