...

Source file src/sigs.k8s.io/gateway-api/conformance/tests/gateway-secret-reference-grant-all-in-namespace.go

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

     1  /*
     2  Copyright 2022 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  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    23  	"k8s.io/apimachinery/pkg/types"
    24  
    25  	v1 "sigs.k8s.io/gateway-api/apis/v1"
    26  	"sigs.k8s.io/gateway-api/conformance/utils/kubernetes"
    27  	"sigs.k8s.io/gateway-api/conformance/utils/suite"
    28  )
    29  
    30  func init() {
    31  	ConformanceTests = append(ConformanceTests, GatewaySecretReferenceGrantAllInNamespace)
    32  }
    33  
    34  var GatewaySecretReferenceGrantAllInNamespace = suite.ConformanceTest{
    35  	ShortName:   "GatewaySecretReferenceGrantAllInNamespace",
    36  	Description: "A Gateway in the gateway-conformance-infra namespace should become programmed if the Gateway has a certificateRef for a Secret in the gateway-conformance-web-backend namespace and a ReferenceGrant granting permission to all Secrets in the namespace exists",
    37  	Features: []suite.SupportedFeature{
    38  		suite.SupportGateway,
    39  		suite.SupportReferenceGrant,
    40  	},
    41  	Manifests: []string{"tests/gateway-secret-reference-grant-all-in-namespace.yaml"},
    42  	Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
    43  		gwNN := types.NamespacedName{Name: "gateway-secret-reference-grant-all-in-namespace", Namespace: "gateway-conformance-infra"}
    44  
    45  		t.Run("Gateway listener should have a true ResolvedRefs condition and a true Programmed condition", func(t *testing.T) {
    46  			listeners := []v1.ListenerStatus{{
    47  				Name: v1.SectionName("https"),
    48  				SupportedKinds: []v1.RouteGroupKind{{
    49  					Group: (*v1.Group)(&v1.GroupVersion.Group),
    50  					Kind:  v1.Kind("HTTPRoute"),
    51  				}},
    52  				Conditions: []metav1.Condition{
    53  					{
    54  						Type:   string(v1.ListenerConditionProgrammed),
    55  						Status: metav1.ConditionTrue,
    56  						Reason: string(v1.ListenerReasonProgrammed),
    57  					},
    58  					{
    59  						Type:   string(v1.ListenerConditionResolvedRefs),
    60  						Status: metav1.ConditionTrue,
    61  						Reason: "", // any reason
    62  					},
    63  				},
    64  				AttachedRoutes: 0,
    65  			}}
    66  
    67  			kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners)
    68  		})
    69  	},
    70  }
    71  

View as plain text