Documentation
¶
Overview ¶
testhelpers contains functions and fixtures that are helpful for testing multiple parts of the Gateway API code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ControllerTestFixture = []client.Object{ &gatewayv1.GatewayClass{ ObjectMeta: metav1.ObjectMeta{ Name: "cilium", }, Spec: gatewayv1.GatewayClassSpec{ ControllerName: "io.cilium/gateway-controller", }, }, &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "tls-secret", Namespace: "default", }, StringData: map[string]string{ "tls.crt": "cert", "tls.key": "key", }, Type: corev1.SecretTypeTLS, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "valid-gateway", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "https", Hostname: ptr.To[gatewayv1.Hostname]("example.com"), Port: 443, TLS: &gatewayv1.ListenerTLSConfig{ CertificateRefs: []gatewayv1.SecretObjectReference{ { Name: "tls-secret", }, }, }, }, }, }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "valid-gateway-2", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "https", Hostname: ptr.To[gatewayv1.Hostname]("example2.com"), Port: 443, TLS: &gatewayv1.ListenerTLSConfig{ CertificateRefs: []gatewayv1.SecretObjectReference{}, }, }, }, }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gateway-with-no-tls", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "https", Port: 80, }, }, }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gateway-tlsroute", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "tls", Protocol: gatewayv1.TLSProtocolType, Port: 443, }, }, }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gateway-from-same-namespace", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "https", Port: 80, AllowedRoutes: &gatewayv1.AllowedRoutes{ Namespaces: &gatewayv1.RouteNamespaces{ From: ptr.To(gatewayv1.NamespacesFromSame), }, }, }, }, }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gateway-from-all-namespaces", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "https", Port: 80, AllowedRoutes: &gatewayv1.AllowedRoutes{ Namespaces: &gatewayv1.RouteNamespaces{ From: ptr.To(gatewayv1.NamespacesFromAll), }, }, }, }, }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gateway-with-namespaces-selector", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "https", Port: 80, AllowedRoutes: &gatewayv1.AllowedRoutes{ Namespaces: &gatewayv1.RouteNamespaces{ From: ptr.To(gatewayv1.NamespacesFromSelector), Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "gateway": "allowed", }, }, }, }, }, }, }, }, &gatewayv1.Gateway{ ObjectMeta: metav1.ObjectMeta{ Name: "gateway-with-invalid-namespaces-selector", Namespace: "default", }, Spec: gatewayv1.GatewaySpec{ GatewayClassName: "cilium", Listeners: []gatewayv1.Listener{ { Name: "https", Port: 80, AllowedRoutes: &gatewayv1.AllowedRoutes{ Namespaces: &gatewayv1.RouteNamespaces{ From: ptr.To(gatewayv1.NamespacesFromSelector), }, }, }, }, }, }, }
View Source
var NamespaceFixtures = []client.Object{ &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "default", }, }, &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "another-namespace", }, }, &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "namespace-with-allowed-gateway-selector", Labels: map[string]string{ "gateway": "allowed", }, }, }, &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name: "namespace-with-disallowed-gateway-selector", Labels: map[string]string{ "gateway": "disallowed", }, }, }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.