Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conformance: HTTPRoute and not allowing listener #1669

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions conformance/tests/httproute-disallowed-kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -31,22 +33,29 @@ func init() {

var HTTPRouteDisallowedKind = suite.ConformanceTest{
ShortName: "HTTPRouteDisallowedKind",
Description: "A single HTTPRoute in the gateway-conformance-infra namespace should fail to attach to a Listener that does not allow the HTTPRoute kind",
Description: "A single HTTPRoute in the gateway-conformance-infra namespace should fail to attach to a Gateway with no listeners that allow the HTTPRoute kind",
Features: []suite.SupportedFeature{suite.SupportTLSRoute},
Manifests: []string{"tests/httproute-disallowed-kind.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
// This test creates an additional Gateway in the gateway-conformance-infra
// namespace so we have to wait for it to be ready.
kubernetes.NamespacesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, []string{"gateway-conformance-infra"})

routeName := types.NamespacedName{Name: "disallowed-kind", Namespace: "gateway-conformance-infra"}
gwName := types.NamespacedName{Name: "tlsroutes-only", Namespace: "gateway-conformance-infra"}
routeNN := types.NamespacedName{Name: "disallowed-kind", Namespace: "gateway-conformance-infra"}
gwNN := types.NamespacedName{Name: "tlsroutes-only", Namespace: "gateway-conformance-infra"}
mlavacca marked this conversation as resolved.
Show resolved Hide resolved

t.Run("Route should not have been accepted with reason NotAllowedByListeners", func(t *testing.T) {
mlavacca marked this conversation as resolved.
Show resolved Hide resolved
kubernetes.HTTPRouteMustHaveCondition(t, suite.Client, suite.TimeoutConfig, routeNN, gwNN, metav1.Condition{
Type: string(v1beta1.RouteConditionAccepted),
Status: metav1.ConditionFalse,
Reason: string(v1beta1.RouteReasonNotAllowedByListeners),
})
})
t.Run("Route should not have Parents set in status", func(t *testing.T) {
kubernetes.HTTPRouteMustHaveNoAcceptedParents(t, suite.Client, suite.TimeoutConfig, routeName)
kubernetes.HTTPRouteMustHaveNoAcceptedParents(t, suite.Client, suite.TimeoutConfig, routeNN)
})
t.Run("Gateway should have 0 Routes attached", func(t *testing.T) {
kubernetes.GatewayMustHaveZeroRoutes(t, suite.Client, suite.TimeoutConfig, gwName)
kubernetes.GatewayMustHaveZeroRoutes(t, suite.Client, suite.TimeoutConfig, gwNN)
})
},
}
4 changes: 2 additions & 2 deletions conformance/tests/httproute-hostname-intersection.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ var HTTPRouteHostnameIntersection = suite.ConformanceTest{

t.Run("HTTPRoutes that do not intersect with listener hostnames", func(t *testing.T) {
gwAddr := kubernetes.GatewayAndHTTPRoutesMustBeAccepted(t, suite.Client, suite.TimeoutConfig, suite.ControllerName, kubernetes.NewGatewayRef(gwNN))
routeNN := types.NamespacedName{Namespace: ns, Name: "no-intersecting-hosts"}

routeName := types.NamespacedName{Namespace: ns, Name: "no-intersecting-hosts"}
parents := []v1beta1.RouteParentStatus{{
ParentRef: parentRefTo(gwNN),
ControllerName: v1beta1.GatewayController(suite.ControllerName),
Expand All @@ -204,7 +204,7 @@ var HTTPRouteHostnameIntersection = suite.ConformanceTest{
},
}}

kubernetes.HTTPRouteMustHaveParents(t, suite.Client, suite.TimeoutConfig, routeName, parents, true)
kubernetes.HTTPRouteMustHaveParents(t, suite.Client, suite.TimeoutConfig, routeNN, parents, true)

testCases := []http.ExpectedResponse{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ var HTTPRouteInvalidCrossNamespaceParentRef = suite.ConformanceTest{
Description: "A single HTTPRoute in the gateway-conformance-web-backend namespace should fail to attach to a Gateway in another namespace that it is not allowed to",
Manifests: []string{"tests/httproute-invalid-cross-namespace-parent-ref.yaml"},
Test: func(t *testing.T, suite *suite.ConformanceTestSuite) {
routeName := types.NamespacedName{Name: "invalid-cross-namespace-parent-ref", Namespace: "gateway-conformance-web-backend"}
gwName := types.NamespacedName{Name: "same-namespace", Namespace: "gateway-conformance-infra"}
gwNN := types.NamespacedName{Name: "same-namespace", Namespace: "gateway-conformance-infra"}
routeNN := types.NamespacedName{Name: "invalid-cross-namespace-parent-ref", Namespace: "gateway-conformance-web-backend"}

t.Run("Route should not have Parents set in status", func(t *testing.T) {
kubernetes.HTTPRouteMustHaveNoAcceptedParents(t, suite.Client, suite.TimeoutConfig, routeName)
kubernetes.HTTPRouteMustHaveNoAcceptedParents(t, suite.Client, suite.TimeoutConfig, routeNN)
})

t.Run("Gateway should have 0 Routes attached", func(t *testing.T) {
kubernetes.GatewayMustHaveZeroRoutes(t, suite.Client, suite.TimeoutConfig, gwName)
kubernetes.GatewayMustHaveZeroRoutes(t, suite.Client, suite.TimeoutConfig, gwNN)
})
},
}