sigs.k8s.io/gateway-api@v1.0.0/conformance/tests/gateway-invalid-tls-certificateref.go (about) 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, GatewayInvalidTLSConfiguration) 32 } 33 34 var GatewayInvalidTLSConfiguration = suite.ConformanceTest{ 35 ShortName: "GatewayInvalidTLSConfiguration", 36 Description: "A Gateway should fail to become ready if the Gateway has an invalid TLS configuration", 37 Features: []suite.SupportedFeature{ 38 suite.SupportGateway, 39 }, 40 Manifests: []string{"tests/gateway-invalid-tls-certificateref.yaml"}, 41 Test: func(t *testing.T, s *suite.ConformanceTestSuite) { 42 listeners := []v1.ListenerStatus{{ 43 Name: v1.SectionName("https"), 44 SupportedKinds: []v1.RouteGroupKind{{ 45 Group: (*v1.Group)(&v1.GroupVersion.Group), 46 Kind: v1.Kind("HTTPRoute"), 47 }}, 48 Conditions: []metav1.Condition{{ 49 Type: string(v1.ListenerConditionResolvedRefs), 50 Status: metav1.ConditionFalse, 51 Reason: string(v1.ListenerReasonInvalidCertificateRef), 52 }}, 53 AttachedRoutes: 0, 54 }} 55 56 testCases := []struct { 57 name string 58 gatewayNamespacedName types.NamespacedName 59 }{ 60 { 61 name: "Nonexistent secret referenced as CertificateRef in a Gateway listener", 62 gatewayNamespacedName: types.NamespacedName{Name: "gateway-certificate-nonexistent-secret", Namespace: "gateway-conformance-infra"}, 63 }, 64 { 65 name: "Unsupported group resource referenced as CertificateRef in a Gateway listener", 66 gatewayNamespacedName: types.NamespacedName{Name: "gateway-certificate-unsupported-group", Namespace: "gateway-conformance-infra"}, 67 }, 68 { 69 name: "Unsupported kind resource referenced as CertificateRef in a Gateway listener", 70 gatewayNamespacedName: types.NamespacedName{Name: "gateway-certificate-unsupported-kind", Namespace: "gateway-conformance-infra"}, 71 }, 72 { 73 name: "Malformed secret referenced as CertificateRef in a Gateway listener", 74 gatewayNamespacedName: types.NamespacedName{Name: "gateway-certificate-malformed-secret", Namespace: "gateway-conformance-infra"}, 75 }, 76 } 77 78 for _, tc := range testCases { 79 tc := tc 80 t.Run(tc.name, func(t *testing.T) { 81 t.Parallel() 82 kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, tc.gatewayNamespacedName, listeners) 83 }) 84 } 85 }, 86 }