...

Source file src/sigs.k8s.io/gateway-api/conformance/tests/httproute-backend-protocol-h2c.go

Documentation: sigs.k8s.io/gateway-api/conformance/tests

     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  	"k8s.io/apimachinery/pkg/types"
    23  
    24  	"sigs.k8s.io/gateway-api/conformance/utils/http"
    25  	"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
    26  	"sigs.k8s.io/gateway-api/conformance/utils/roundtripper"
    27  	"sigs.k8s.io/gateway-api/conformance/utils/suite"
    28  )
    29  
    30  func init() {
    31  	ConformanceTests = append(ConformanceTests, HTTPRouteBackendProtocolH2C)
    32  }
    33  
    34  var HTTPRouteBackendProtocolH2C = suite.ConformanceTest{
    35  	ShortName:   "HTTPRouteBackendProtocolH2C",
    36  	Description: "A HTTPRoute with a BackendRef that has an appProtocol kubernetes.io/h2c should be functional",
    37  	Features: []suite.SupportedFeature{
    38  		suite.SupportGateway,
    39  		suite.SupportHTTPRoute,
    40  		suite.SupportHTTPRouteBackendProtocolH2C,
    41  	},
    42  	Manifests: []string{
    43  		"tests/httproute-backend-protocol-h2c.yaml",
    44  	},
    45  	Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
    46  		ns := "gateway-conformance-infra"
    47  		routeNN := types.NamespacedName{Name: "backend-protocol-h2c", Namespace: ns}
    48  		gwNN := types.NamespacedName{Name: "same-namespace", Namespace: ns}
    49  		gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN), routeNN)
    50  
    51  		// We are not testing the h2c HTTP upgrade mechanism as it is deprecated
    52  		// See: https://datatracker.ietf.org/doc/html/rfc9113#versioning
    53  
    54  		t.Run("http2 prior knowledge request should reach backend", func(t *testing.T) {
    55  			http.MakeRequestAndExpectEventuallyConsistentResponse(t, suite.RoundTripper, suite.TimeoutConfig, gwAddr, http.ExpectedResponse{
    56  				Request: http.Request{
    57  					Path:     "/",
    58  					Protocol: roundtripper.H2CPriorKnowledgeProtocol,
    59  				},
    60  				Response:  http.Response{StatusCode: 200},
    61  				Backend:   "infra-backend-v1",
    62  				Namespace: "gateway-conformance-infra",
    63  			})
    64  		})
    65  	},
    66  }
    67  

View as plain text