|
| 1 | +// Copyright Envoy Gateway Authors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +// The full text of the Apache license is available in the LICENSE file at |
| 4 | +// the root of the repo. |
| 5 | + |
| 6 | +//go:build e2e |
| 7 | +// +build e2e |
| 8 | + |
| 9 | +package tests |
| 10 | + |
| 11 | +import ( |
| 12 | + "testing" |
| 13 | + |
| 14 | + "k8s.io/apimachinery/pkg/types" |
| 15 | + "sigs.k8s.io/gateway-api/conformance/utils/http" |
| 16 | + "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" |
| 17 | + "sigs.k8s.io/gateway-api/conformance/utils/suite" |
| 18 | +) |
| 19 | + |
| 20 | +func init() { |
| 21 | + ConformanceTests = append(ConformanceTests, EnvoyPatchPolicyTest) |
| 22 | +} |
| 23 | + |
| 24 | +var EnvoyPatchPolicyTest = suite.ConformanceTest{ |
| 25 | + ShortName: "EnvoyPatchPolicy", |
| 26 | + Description: "update xds using EnvoyPatchPolicy", |
| 27 | + Manifests: []string{"testdata/envoy-patch-policy.yaml"}, |
| 28 | + Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { |
| 29 | + t.Run("envoy patch policy", func(t *testing.T) { |
| 30 | + ns := "gateway-conformance-infra" |
| 31 | + routeNN := types.NamespacedName{Name: "http-envoy-patch-policy", Namespace: ns} |
| 32 | + gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns} |
| 33 | + gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN) |
| 34 | + OkResp := http.ExpectedResponse{ |
| 35 | + Request: http.Request{ |
| 36 | + Path: "/foo", |
| 37 | + }, |
| 38 | + Response: http.Response{ |
| 39 | + StatusCode: 200, |
| 40 | + }, |
| 41 | + Namespace: ns, |
| 42 | + } |
| 43 | + |
| 44 | + // Send a request to an valid path and expect a successful response |
| 45 | + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, OkResp) |
| 46 | + |
| 47 | + customResp := http.ExpectedResponse{ |
| 48 | + Request: http.Request{ |
| 49 | + Path: "/bar", |
| 50 | + }, |
| 51 | + Response: http.Response{ |
| 52 | + StatusCode: 406, |
| 53 | + }, |
| 54 | + Namespace: ns, |
| 55 | + } |
| 56 | + |
| 57 | + // Send a request to an invalid path and expect a custom response |
| 58 | + http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, customResp) |
| 59 | + }) |
| 60 | + }, |
| 61 | +} |
0 commit comments