From 714ab40357c7cbd038ef127bf33ef367c5514274 Mon Sep 17 00:00:00 2001 From: Mattia Lavacca Date: Thu, 2 Feb 2023 11:04:33 +0100 Subject: [PATCH 1/3] parentRefNotPermitted used in conformance test The reason ParentRefNotPermitted has been used and checked in the HTTPRouteInvalidCrossNamespaceParentRef conformance test. Signed-off-by: Mattia Lavacca --- .../httproute-invalid-cross-namespace-parent-ref.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go b/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go index 3fcd6433eb..29c8ba44be 100644 --- a/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go +++ b/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go @@ -19,8 +19,10 @@ package tests import ( "testing" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/gateway-api/apis/v1beta1" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" ) @@ -37,6 +39,17 @@ var HTTPRouteInvalidCrossNamespaceParentRef = suite.ConformanceTest{ gwNN := types.NamespacedName{Name: "same-namespace", Namespace: "gateway-conformance-infra"} routeNN := types.NamespacedName{Name: "invalid-cross-namespace-parent-ref", Namespace: "gateway-conformance-web-backend"} + // The Route must have an Accepted Condition with a ParentRefNotPermitted Reason. + t.Run("HTTPRoute with a cross-namespace ParentRef and no ReferenceGrants allows such a reference, has an Accepted Condition with status False and Reason ParentRefNotPermitted", func(t *testing.T) { + acceptedCond := metav1.Condition{ + Type: string(v1beta1.RouteConditionAccepted), + Status: metav1.ConditionFalse, + Reason: string(v1beta1.RouteReasonParentRefNotPermitted), + } + + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, acceptedCond) + }) + t.Run("Route should not have Parents set in status", func(t *testing.T) { kubernetes.HTTPRouteMustHaveNoAcceptedParents(t, suite.Client, suite.TimeoutConfig, routeNN) }) From 8fec2a6ce5e2c262d5ff3e6441046994451b887d Mon Sep 17 00:00:00 2001 From: Mattia Lavacca Date: Thu, 2 Feb 2023 11:05:47 +0100 Subject: [PATCH 2/3] fixed accepted condition var name Signed-off-by: Mattia Lavacca --- .../httproute-invalid-parentref-not-matching-listener-port.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conformance/tests/httproute-invalid-parentref-not-matching-listener-port.go b/conformance/tests/httproute-invalid-parentref-not-matching-listener-port.go index 9b9ddb95cb..dda394d110 100644 --- a/conformance/tests/httproute-invalid-parentref-not-matching-listener-port.go +++ b/conformance/tests/httproute-invalid-parentref-not-matching-listener-port.go @@ -42,13 +42,13 @@ var HTTPRouteInvalidParentRefNotMatchingListenerPort = suite.ConformanceTest{ // The Route must have an Accepted Condition with a NoMatchingParent Reason. t.Run("HTTPRoute with no matching port in ParentRef has an Accepted Condition with status False and Reason NoMatchingParent", func(t *testing.T) { - resolvedRefsCond := metav1.Condition{ + acceptedCond := metav1.Condition{ Type: string(v1beta1.RouteConditionAccepted), Status: metav1.ConditionFalse, Reason: string(v1beta1.RouteReasonNoMatchingParent), } - kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, resolvedRefsCond) + kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, acceptedCond) }) t.Run("Route should not have Parents accepted in status", func(t *testing.T) { From d0915648419227f3903d4dedf052efbd723c1dc0 Mon Sep 17 00:00:00 2001 From: Mattia Lavacca Date: Fri, 3 Feb 2023 16:33:27 +0100 Subject: [PATCH 3/3] Update conformance/tests/httproute-invalid-cross-namespace-parent-ref.go Co-authored-by: Shane Utt --- .../tests/httproute-invalid-cross-namespace-parent-ref.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go b/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go index 29c8ba44be..77f90302ad 100644 --- a/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go +++ b/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go @@ -40,7 +40,7 @@ var HTTPRouteInvalidCrossNamespaceParentRef = suite.ConformanceTest{ routeNN := types.NamespacedName{Name: "invalid-cross-namespace-parent-ref", Namespace: "gateway-conformance-web-backend"} // The Route must have an Accepted Condition with a ParentRefNotPermitted Reason. - t.Run("HTTPRoute with a cross-namespace ParentRef and no ReferenceGrants allows such a reference, has an Accepted Condition with status False and Reason ParentRefNotPermitted", func(t *testing.T) { + t.Run("HTTPRoute with a cross-namespace ParentRef where no ReferenceGrants allows such a reference, has an Accepted Condition with status False and Reason ParentRefNotPermitted", func(t *testing.T) { acceptedCond := metav1.Condition{ Type: string(v1beta1.RouteConditionAccepted), Status: metav1.ConditionFalse,