|
| 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 | + "sigs.k8s.io/gateway-api/apis/v1alpha2" |
| 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, GatewaySecretMissingReferencedSecret) |
| 32 | +} |
| 33 | + |
| 34 | +var GatewaySecretMissingReferencedSecret = suite.ConformanceTest{ |
| 35 | + ShortName: "GatewaySecretMissingReferencedSecret", |
| 36 | + Description: "A Gateway should fail to become ready if the Gateway has a certificateRef for a nonexistent Secret", |
| 37 | + Manifests: []string{"tests/gateway-secret-missing-referenced-secret.yaml"}, |
| 38 | + Test: func(t *testing.T, s *suite.ConformanceTestSuite) { |
| 39 | + gwNN := types.NamespacedName{Name: "gateway-secret-missing-referenced-secret", Namespace: "gateway-conformance-infra"} |
| 40 | + |
| 41 | + t.Run("Gateway listener should have a false ResolvedRefs condition with reason InvalidCertificateRef", func(t *testing.T) { |
| 42 | + listeners := []v1alpha2.ListenerStatus{{ |
| 43 | + Name: v1alpha2.SectionName("https"), |
| 44 | + SupportedKinds: []v1alpha2.RouteGroupKind{{ |
| 45 | + Group: (*v1alpha2.Group)(&v1alpha2.GroupVersion.Group), |
| 46 | + Kind: v1alpha2.Kind("HTTPRoute"), |
| 47 | + }}, |
| 48 | + Conditions: []metav1.Condition{{ |
| 49 | + Type: string(v1alpha2.ListenerConditionResolvedRefs), |
| 50 | + Status: metav1.ConditionFalse, |
| 51 | + Reason: string(v1alpha2.ListenerReasonInvalidCertificateRef), |
| 52 | + }}, |
| 53 | + }} |
| 54 | + |
| 55 | + kubernetes.GatewayStatusMustHaveListeners(t, s.Client, gwNN, listeners, 60) |
| 56 | + }) |
| 57 | + }, |
| 58 | +} |
0 commit comments