...
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, MeshFrontendHostname)
29 }
30
31 var MeshFrontendHostname = suite.ConformanceTest{
32 ShortName: "MeshFrontendHostname",
33 Description: "Mesh parentRef matches Service IP (not Host)",
34 Features: []suite.SupportedFeature{
35 suite.SupportMesh,
36 suite.SupportHTTPRouteResponseHeaderModification,
37 },
38 Manifests: []string{"tests/mesh-frontend.yaml"},
39 Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
40 client := echo.ConnectToApp(t, s, echo.MeshAppEchoV1)
41 cases := []http.ExpectedResponse{
42 {
43 TestCaseName: "Send to service with wrong hostname",
44 Request: http.Request{
45 Host: "echo-v2",
46 Headers: map[string]string{
47 "Host": "echo-v1",
48 },
49 Method: "GET",
50 },
51 Response: http.Response{
52 StatusCode: 200,
53
54 Headers: map[string]string{
55 "X-Header-Set": "set",
56 },
57 },
58 Backend: "echo-v2",
59 },
60 {
61 TestCaseName: "Send to other service with matching hostname",
62 Request: http.Request{
63 Host: "echo-v1",
64 Headers: map[string]string{
65 "Host": "echo-v2",
66 },
67 Method: "GET",
68 },
69 Response: http.Response{
70 StatusCode: 200,
71 AbsentHeaders: []string{"X-Header-Set"},
72 },
73 Backend: "echo-v1",
74 },
75 }
76 for i := range cases {
77
78
79 tc := cases[i]
80 t.Run(tc.GetTestCaseName(i), func(t *testing.T) {
81 client.MakeRequestAndExpectEventuallyConsistentResponse(t, tc, s.TimeoutConfig)
82 })
83 }
84 },
85 }
86
View as plain text