2020-12-15 15:40:05 +00:00
|
|
|
package gateway
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-03-25 13:38:04 +00:00
|
|
|
"errors"
|
2024-06-13 09:16:04 +00:00
|
|
|
"net/http"
|
2024-05-01 04:38:03 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2020-12-15 15:40:05 +00:00
|
|
|
"testing"
|
2022-11-16 10:38:07 +00:00
|
|
|
"time"
|
2020-12-15 15:40:05 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2022-11-16 10:38:07 +00:00
|
|
|
ptypes "github.com/traefik/paerser/types"
|
2023-02-03 14:24:05 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/config/dynamic"
|
|
|
|
"github.com/traefik/traefik/v3/pkg/provider"
|
2024-03-25 13:38:04 +00:00
|
|
|
traefikv1alpha1 "github.com/traefik/traefik/v3/pkg/provider/kubernetes/crd/traefikio/v1alpha1"
|
2024-05-01 04:38:03 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/provider/kubernetes/k8s"
|
2023-02-03 14:24:05 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/tls"
|
2024-01-11 16:06:06 +00:00
|
|
|
"github.com/traefik/traefik/v3/pkg/types"
|
2024-05-28 12:30:04 +00:00
|
|
|
corev1 "k8s.io/api/core/v1"
|
2021-11-09 10:34:06 +00:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
2024-05-01 04:38:03 +00:00
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
|
|
kubefake "k8s.io/client-go/kubernetes/fake"
|
|
|
|
kscheme "k8s.io/client-go/kubernetes/scheme"
|
2024-01-09 09:28:05 +00:00
|
|
|
"k8s.io/utils/ptr"
|
|
|
|
gatev1 "sigs.k8s.io/gateway-api/apis/v1"
|
2024-05-01 04:38:03 +00:00
|
|
|
gatev1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
|
2024-09-17 08:50:04 +00:00
|
|
|
gatev1alpha3 "sigs.k8s.io/gateway-api/apis/v1alpha3"
|
2024-01-30 15:44:05 +00:00
|
|
|
gatev1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
|
2024-05-01 04:38:03 +00:00
|
|
|
gatefake "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned/fake"
|
2020-12-15 15:40:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ provider.Provider = (*Provider)(nil)
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
func init() {
|
|
|
|
// required by k8s.MustParseYaml
|
|
|
|
if err := gatev1.AddToScheme(kscheme.Scheme); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := gatev1beta1.AddToScheme(kscheme.Scheme); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if err := gatev1alpha2.AddToScheme(kscheme.Scheme); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2024-09-17 08:50:04 +00:00
|
|
|
if err := gatev1alpha3.AddToScheme(kscheme.Scheme); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2024-05-01 04:38:03 +00:00
|
|
|
}
|
|
|
|
|
2020-12-15 15:40:05 +00:00
|
|
|
func TestLoadHTTPRoutes(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2024-04-02 15:32:04 +00:00
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
entryPoints map[string]Entrypoint
|
|
|
|
experimentalChannel bool
|
2020-12-15 15:40:05 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because missing entry point",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/simple.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":443",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because no http route defined",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/without_httproute.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by missing GatewayClass",
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/without_gatewayclass.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Empty caused by unknown GatewayClass controller desc",
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/gatewayclass_with_unknown_controller.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-09-03 10:10:04 +00:00
|
|
|
desc: "Router with service in error caused by wrong TargetPort",
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_wrong_service_port.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2024-05-22 15:20:04 +00:00
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-05-22 15:20:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-05-22 15:20:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-05-22 15:20:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-9000",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
Status: ptr.To(500),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by HTTPS without TLS",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
}},
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_protocol_https_without_tls.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
{
|
|
|
|
desc: "Empty caused by HTTPS with TLS passthrough",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "httproute/with_protocol_https_with_tls_passthrough.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by HTTPRoute with protocol TLS",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "httproute/with_protocol_tls.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by HTTPRoute with protocol TCP",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "httproute/with_protocol_tcp.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by TCPRoute with protocol HTTP",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":9000",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tcproute/with_protocol_http.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by TCPRoute with protocol HTTPS",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":9000",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tcproute/with_protocol_https.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by TLSRoute with protocol TCP",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":9001",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_protocol_tcp.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by TLSRoute with protocol HTTP",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":9001",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_protocol_http.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by TLSRoute with protocol HTTPS",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":9001",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_protocol_https.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused use http entrypoint with tls activated with HTTPRoute",
|
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
HasHTTPTLSConf: true,
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "httproute/simple_with_tls_entrypoint.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because no tcp route defined tls protocol",
|
|
|
|
paths: []string{"services.yml", "tcproute/without_tcproute_tls_protocol.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
2024-04-02 15:32:04 +00:00
|
|
|
experimentalChannel: true,
|
2021-05-20 09:50:12 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Empty caused by HTTPRoute with TLS configuration",
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "httproute/with_tls_configuration.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/simple.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
2021-02-02 18:36:04 +00:00
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-02-02 18:36:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-02-02 18:36:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-02-02 18:36:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with api@internal service",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/simple_to_api_internal.yml"},
|
2021-02-02 18:36:04 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-02-02 18:36:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2021-02-02 18:36:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "api@internal",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-02-02 18:36:04 +00:00
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-02-02 18:36:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute with protocol HTTPS",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_protocol_https.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-websecure-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-websecure-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2020-12-15 15:40:05 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-websecure-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with multiple hosts",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_multiple_host.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-66e726cd8903b49727ae": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-66e726cd8903b49727ae-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "(Host(`foo.com`) || Host(`bar.com`)) && PathPrefix(`/`)",
|
|
|
|
Priority: 9,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-66e726cd8903b49727ae-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-04-29 15:18:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with two hosts one wildcard",
|
|
|
|
paths: []string{"services.yml", "with_two_hosts_one_wildcard.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-baa117c0219e3878749f": {
|
2021-04-29 15:18:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-baa117c0219e3878749f-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "(Host(`foo.com`) || HostRegexp(`^[a-z0-9-\\.]+\\.bar\\.com$`)) && PathPrefix(`/`)",
|
|
|
|
Priority: 11,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-baa117c0219e3878749f-wrr": {
|
2021-04-29 15:18:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with one host and a wildcard",
|
|
|
|
paths: []string{"services.yml", "with_two_hosts_wildcard.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-45eba2eaf40ac792e036": {
|
2021-04-29 15:18:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-45eba2eaf40ac792e036-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "(Host(`foo.com`) || HostRegexp(`^[a-z0-9-\\.]+\\.foo\\.com$`)) && PathPrefix(`/`)",
|
|
|
|
Priority: 11,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-45eba2eaf40ac792e036-wrr": {
|
2021-04-29 15:18:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
{
|
|
|
|
desc: "One HTTPRoute with two different rules",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/two_rules.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100009,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-1-d737b4933fa88e68ab8a": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bir`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-1-d737b4933fa88e68ab8a-wrr",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-1-d737b4933fa88e68ab8a-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami2-8080",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami2-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One HTTPRoute with one rule two targets",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/one_rule_two_targets.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami2-8080",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami2-8080": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Two Gateways and one HTTPRoute",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_two_gateways_one_httproute.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {
|
|
|
|
Address: ":80",
|
|
|
|
},
|
|
|
|
"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-http-web-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-http-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-https-websecure-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-https-websecure-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2020-12-15 15:40:05 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-http-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-https-websecure-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Gateway with two listeners and one HTTPRoute",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_two_listeners_one_httproute.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {
|
|
|
|
Address: ":80",
|
|
|
|
},
|
|
|
|
"websecure": {
|
|
|
|
Address: ":443",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-websecure-0-1c0cf64bde37d9d0df06": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-websecure-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2020-12-15 15:40:05 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-websecure-0-1c0cf64bde37d9d0df06-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with several rules",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_several_rules.yml"},
|
2020-12-15 15:40:05 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-6cf37fa71907768d925c": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && (Path(`/bar`) || PathPrefix(`/bar/`)) && Header(`my-header`,`foo`) && Header(`my-header2`,`bar`)",
|
|
|
|
Priority: 10610,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-6cf37fa71907768d925c-wrr",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-2-d23f7039bc8036fb918c": {
|
2020-12-15 15:40:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathRegexp(`^/buzz/[0-9]+$`)",
|
2024-06-18 07:48:04 +00:00
|
|
|
Priority: 11408,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-2-d23f7039bc8036fb918c-wrr",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-1-aaba0f24fd26e1ca2276": {
|
2024-05-23 18:08:03 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`) && Header(`my-header`,`bar`)",
|
|
|
|
Priority: 100109,
|
2024-05-23 18:08:03 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-1-aaba0f24fd26e1ca2276-wrr",
|
2024-05-23 18:08:03 +00:00
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-6cf37fa71907768d925c-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-2-d23f7039bc8036fb918c-wrr": {
|
2020-12-15 15:40:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-1-aaba0f24fd26e1ca2276-wrr": {
|
2024-05-23 18:08:03 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2024-06-18 07:48:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with method matching",
|
|
|
|
paths: []string{"services.yml", "httproute/with_method_matching.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-74ad70a7cf090becdd3c": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Rule: "Host(`foo.com`) && (Path(`/foo`) || PathPrefix(`/foo/`)) && Method(`GET`)",
|
|
|
|
Priority: 11408,
|
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-74ad70a7cf090becdd3c-wrr",
|
2024-06-18 07:48:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-74ad70a7cf090becdd3c-wrr": {
|
2024-06-18 07:48:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with query param matching",
|
|
|
|
paths: []string{"services.yml", "httproute/with_query_param_matching.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-bb7b03c9610e982fd627": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Rule: "Host(`foo.com`) && (Path(`/foo`) || PathPrefix(`/foo/`)) && Query(`foo`,`bar`) && QueryRegexp(`baz`,`buz`)",
|
|
|
|
Priority: 10428,
|
|
|
|
RuleSyntax: "v3",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-bb7b03c9610e982fd627-wrr",
|
2024-06-18 07:48:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-bb7b03c9610e982fd627-wrr": {
|
2024-06-18 07:48:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
{
|
|
|
|
desc: "HTTPRoute with Same namespace selector",
|
|
|
|
paths: []string{"services.yml", "httproute/with_namespace_same.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":80"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-efde1997778109a1f6eb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-web-0-efde1997778109a1f6eb-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/foo`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-efde1997778109a1f6eb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTPRoute with All namespace selector",
|
|
|
|
paths: []string{"services.yml", "httproute/with_namespace_all.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":80"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-efde1997778109a1f6eb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-web-0-efde1997778109a1f6eb-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/foo`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-66f5c78d03d948e36597": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-http-app-bar-my-gateway-web-0-66f5c78d03d948e36597-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`bar.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-efde1997778109a1f6eb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-66f5c78d03d948e36597-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoami-bar-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoami-bar-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.11:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.12:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "HTTPRoute with namespace selector",
|
2021-10-04 13:46:08 +00:00
|
|
|
paths: []string{"services.yml", "httproute/with_namespace_selector.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":80"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-66f5c78d03d948e36597": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-http-app-bar-my-gateway-web-0-66f5c78d03d948e36597-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`bar.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-66f5c78d03d948e36597-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoami-bar-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoami-bar-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.11:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.12:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-12-22 14:02:05 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2024-04-05 15:18:03 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, request header modifier",
|
|
|
|
paths: []string{"services.yml", "httproute/filter_request_header_modifier.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4": {
|
2024-04-05 15:18:03 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`example.org`) && PathPrefix(`/`)",
|
|
|
|
Priority: 13,
|
2024-04-05 15:18:03 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-06-13 09:16:04 +00:00
|
|
|
Middlewares: []string{"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-requestheadermodifier-0"},
|
2024-04-05 15:18:03 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-requestheadermodifier-0": {
|
2024-08-12 09:34:04 +00:00
|
|
|
RequestHeaderModifier: &dynamic.HeaderModifier{
|
|
|
|
Set: map[string]string{"X-Foo": "Bar"},
|
|
|
|
Add: map[string]string{"X-Bar": "Foo"},
|
|
|
|
Remove: []string{"X-Baz"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr": {
|
2024-08-12 09:34:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, response header modifier",
|
|
|
|
paths: []string{"services.yml", "httproute/filter_response_header_modifier.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4": {
|
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr",
|
2024-08-12 09:34:04 +00:00
|
|
|
Rule: "Host(`example.org`) && PathPrefix(`/`)",
|
|
|
|
Priority: 13,
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
Middlewares: []string{"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-responseheadermodifier-0"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-responseheadermodifier-0": {
|
|
|
|
ResponseHeaderModifier: &dynamic.HeaderModifier{
|
2024-04-05 15:18:03 +00:00
|
|
|
Set: map[string]string{"X-Foo": "Bar"},
|
|
|
|
Add: map[string]string{"X-Bar": "Foo"},
|
|
|
|
Remove: []string{"X-Baz"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr": {
|
2024-04-05 15:18:03 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-04-05 15:18:03 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2022-12-22 14:02:05 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, redirect HTTP to HTTPS",
|
|
|
|
paths: []string{"services.yml", "httproute/filter_http_to_https.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4": {
|
2022-12-22 14:02:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`example.org`) && PathPrefix(`/`)",
|
|
|
|
Priority: 13,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-06-13 09:16:04 +00:00
|
|
|
Middlewares: []string{"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-requestredirect-0"},
|
2022-12-22 14:02:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-requestredirect-0": {
|
2024-06-06 08:56:03 +00:00
|
|
|
RequestRedirect: &dynamic.RequestRedirect{
|
2024-06-13 09:16:04 +00:00
|
|
|
Scheme: ptr.To("https"),
|
|
|
|
Port: ptr.To(""),
|
|
|
|
StatusCode: http.StatusMovedPermanently,
|
2022-12-22 14:02:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr": {
|
2024-06-06 08:56:03 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{},
|
2022-12-22 14:02:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, redirect HTTP to HTTPS with hostname",
|
|
|
|
paths: []string{"services.yml", "httproute/filter_http_to_https_with_hostname_and_port.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4": {
|
2022-12-22 14:02:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`example.org`) && PathPrefix(`/`)",
|
|
|
|
Priority: 13,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-06-13 09:16:04 +00:00
|
|
|
Middlewares: []string{"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-requestredirect-0"},
|
2022-12-22 14:02:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-requestredirect-0": {
|
2024-06-06 08:56:03 +00:00
|
|
|
RequestRedirect: &dynamic.RequestRedirect{
|
2024-06-13 09:16:04 +00:00
|
|
|
Hostname: ptr.To("example.com"),
|
|
|
|
Port: ptr.To("443"),
|
|
|
|
StatusCode: http.StatusFound,
|
2022-12-22 14:02:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-364ce6ec04c3d49b19c4-wrr": {
|
2024-06-06 08:56:03 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2024-06-13 15:06:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute URL rewrite FullPath",
|
|
|
|
paths: []string{"services.yml", "httproute/filter_url_rewrite_fullpath.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8": {
|
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-wrr",
|
2024-06-13 15:06:04 +00:00
|
|
|
Rule: "Host(`example.com`) && (Path(`/foo`) || PathPrefix(`/foo/`))",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
Priority: 10412,
|
|
|
|
Middlewares: []string{"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-urlrewrite-0"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-urlrewrite-0": {
|
|
|
|
URLRewrite: &dynamic.URLRewrite{
|
|
|
|
Path: ptr.To("/bar"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-wrr": {
|
2024-06-13 15:06:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute URL rewrite Hostname",
|
|
|
|
paths: []string{"services.yml", "httproute/filter_url_rewrite_hostname.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8": {
|
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-wrr",
|
2024-06-13 15:06:04 +00:00
|
|
|
Rule: "Host(`example.com`) && (Path(`/foo`) || PathPrefix(`/foo/`))",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
Priority: 10412,
|
|
|
|
Middlewares: []string{"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-urlrewrite-0"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-urlrewrite-0": {
|
|
|
|
URLRewrite: &dynamic.URLRewrite{
|
|
|
|
Hostname: ptr.To("www.foo.bar"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-wrr": {
|
2024-06-13 15:06:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute URL rewrite Combined",
|
|
|
|
paths: []string{"services.yml", "httproute/filter_url_rewrite_combined.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8": {
|
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-wrr",
|
2024-06-13 15:06:04 +00:00
|
|
|
Rule: "Host(`example.com`) && (Path(`/foo`) || PathPrefix(`/foo/`))",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
Priority: 10412,
|
|
|
|
Middlewares: []string{"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-urlrewrite-0"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-urlrewrite-0": {
|
|
|
|
URLRewrite: &dynamic.URLRewrite{
|
|
|
|
Hostname: ptr.To("www.foo.bar"),
|
|
|
|
Path: ptr.To("/xyz"),
|
|
|
|
PathPrefix: ptr.To("/foo"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-7f90cf546b15efadf2f8-wrr": {
|
2024-06-13 15:06:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2024-09-17 08:50:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute and BackendTLSPolicy, experimental channel disabled",
|
|
|
|
paths: []string{"services.yml", "httproute/with_backend_tls_policy.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute and BackendTLSPolicy with CA certificate, experimental channel enabled",
|
|
|
|
paths: []string{"services.yml", "httproute/with_backend_tls_policy.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
experimentalChannel: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
ServersTransport: "default-whoami-80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{
|
|
|
|
"default-whoami-80": {
|
|
|
|
ServerName: "whoami",
|
|
|
|
RootCAs: []types.FileOrContent{
|
|
|
|
"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute and BackendTLSPolicy with System CA, experimental channel enabled",
|
|
|
|
paths: []string{"services.yml", "httproute/with_backend_tls_policy_system.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
experimentalChannel: true,
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
ServersTransport: "default-whoami-80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{
|
|
|
|
"default-whoami-80": {
|
|
|
|
ServerName: "whoami",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, test.paths)
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
2024-09-17 08:50:04 +00:00
|
|
|
client.experimentalChannel = test.experimentalChannel
|
2024-05-01 04:38:03 +00:00
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
2024-03-25 13:38:04 +00:00
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
EntryPoints: test.entryPoints,
|
|
|
|
ExperimentalChannel: test.experimentalChannel,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
|
|
|
conf := p.loadConfigurationFromGateways(context.Background())
|
2020-12-15 15:40:05 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-25 13:38:04 +00:00
|
|
|
func TestLoadHTTPRoutes_backendExtensionRef(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
paths []string
|
|
|
|
groupKindBackendFuncs map[string]map[string]BuildBackendFunc
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
entryPoints map[string]Entrypoint
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute with TraefikService",
|
|
|
|
paths: []string{"services.yml", "httproute/simple_with_TraefikService.yml"},
|
|
|
|
groupKindBackendFuncs: map[string]map[string]BuildBackendFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"TraefikService": func(name, namespace string) (string, *dynamic.Service, error) {
|
|
|
|
return name, nil, nil
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-03-25 13:38:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-03-25 13:38:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-03-25 13:38:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "whoami",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-03-25 13:38:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute with TraefikService with service configuration",
|
|
|
|
paths: []string{"services.yml", "httproute/simple_with_TraefikService.yml"},
|
|
|
|
groupKindBackendFuncs: map[string]map[string]BuildBackendFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"TraefikService": func(name, namespace string) (string, *dynamic.Service, error) {
|
|
|
|
return name, &dynamic.Service{LoadBalancer: &dynamic.ServersLoadBalancer{Servers: []dynamic.Server{{URL: "foobar"}}}}, nil
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-03-25 13:38:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-03-25 13:38:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-03-25 13:38:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "whoami",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-03-25 13:38:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"whoami": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{URL: "foobar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute with invalid TraefikService kind",
|
|
|
|
paths: []string{"services.yml", "httproute/simple_with_TraefikService.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2024-05-22 15:20:04 +00:00
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-05-22 15:20:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-05-22 15:20:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-05-22 15:20:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
Status: ptr.To(500),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-03-25 13:38:04 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute with backendFunc error",
|
|
|
|
paths: []string{"services.yml", "httproute/simple_with_TraefikService.yml"},
|
|
|
|
groupKindBackendFuncs: map[string]map[string]BuildBackendFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"TraefikService": func(name, namespace string) (string, *dynamic.Service, error) {
|
|
|
|
return "", nil, errors.New("BOOM")
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2024-05-22 15:20:04 +00:00
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-05-22 15:20:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-05-22 15:20:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-05-22 15:20:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
Status: ptr.To(500),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-03-25 13:38:04 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with myservice@file service",
|
|
|
|
paths: []string{"services.yml", "httproute/simple_cross_provider.yml"},
|
|
|
|
groupKindBackendFuncs: map[string]map[string]BuildBackendFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"TraefikService": func(name, namespace string) (string, *dynamic.Service, error) {
|
|
|
|
// func should never be executed in case of cross-provider reference.
|
|
|
|
return "", nil, errors.New("BOOM")
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-03-25 13:38:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-03-25 13:38:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-03-25 13:38:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "service@file",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-03-25 13:38:04 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-03-25 13:38:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2024-09-09 08:08:08 +00:00
|
|
|
{
|
|
|
|
desc: "Simple HTTPRoute, with appProtocol service",
|
|
|
|
paths: []string{"services.yml", "httproute/with_app_protocol_service.yml"},
|
|
|
|
groupKindBackendFuncs: map[string]map[string]BuildBackendFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"TraefikService": func(name, namespace string) (string, *dynamic.Service, error) {
|
|
|
|
// func should never be executed in case of cross-provider reference.
|
|
|
|
return "", nil, errors.New("BOOM")
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
|
|
|
"default-http-multi-protocols-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Service: "default-http-multi-protocols-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"default-http-multi-protocols-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-h2c-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami-ws-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoami-wss-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-h2c-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "h2c://10.10.0.13:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-ws-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.14:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-wss-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "https://10.10.0.15:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2024-03-25 13:38:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, test.paths)
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
EntryPoints: test.entryPoints,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
2024-03-25 13:38:04 +00:00
|
|
|
for group, kindFuncs := range test.groupKindBackendFuncs {
|
|
|
|
for kind, backendFunc := range kindFuncs {
|
|
|
|
p.RegisterBackendFuncs(group, kind, backendFunc)
|
|
|
|
}
|
|
|
|
}
|
2024-06-13 09:16:04 +00:00
|
|
|
conf := p.loadConfigurationFromGateways(context.Background())
|
2024-03-25 13:38:04 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoadHTTPRoutes_filterExtensionRef(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
groupKindFilterFuncs map[string]map[string]BuildFilterFunc
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
entryPoints map[string]Entrypoint
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "HTTPRoute with ExtensionRef filter",
|
|
|
|
groupKindFilterFuncs: map[string]map[string]BuildFilterFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"Middleware": func(name, namespace string) (string, *dynamic.Middleware, error) {
|
|
|
|
return namespace + "-" + name, nil, nil
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-03-25 13:38:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-03-25 13:38:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
Middlewares: []string{"default-my-middleware"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-03-25 13:38:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-03-25 13:38:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "HTTPRoute with ExtensionRef filter and create middleware",
|
|
|
|
groupKindFilterFuncs: map[string]map[string]BuildFilterFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"Middleware": func(name, namespace string) (string, *dynamic.Middleware, error) {
|
|
|
|
return namespace + "-" + name, &dynamic.Middleware{Headers: &dynamic.Headers{CustomRequestHeaders: map[string]string{"Test-Header": "Test"}}}, nil
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-03-25 13:38:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr",
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-03-25 13:38:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
Middlewares: []string{"default-my-middleware"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
|
|
|
"default-my-middleware": {Headers: &dynamic.Headers{CustomRequestHeaders: map[string]string{"Test-Header": "Test"}}},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-wrr": {
|
2024-03-25 13:38:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-03-25 13:38:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PassHostHeader: ptr.To(true),
|
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "ExtensionRef filter: Unknown",
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2024-05-28 12:30:04 +00:00
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-05-28 12:30:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-err-wrr",
|
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-05-28 12:30:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-err-wrr": {
|
2024-05-28 12:30:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "invalid-httproute-filter",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
Status: ptr.To(500),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-03-25 13:38:04 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "ExtensionRef filter with filterFunc error",
|
|
|
|
groupKindFilterFuncs: map[string]map[string]BuildFilterFunc{
|
|
|
|
traefikv1alpha1.GroupName: {"Middleware": func(name, namespace string) (string, *dynamic.Middleware, error) {
|
|
|
|
return "", nil, errors.New("BOOM")
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":80",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2024-05-28 12:30:04 +00:00
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06": {
|
2024-05-28 12:30:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-err-wrr",
|
|
|
|
Rule: "Host(`foo.com`) && Path(`/bar`)",
|
|
|
|
Priority: 100008,
|
2024-05-28 12:30:04 +00:00
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-1c0cf64bde37d9d0df06-err-wrr": {
|
2024-05-28 12:30:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "invalid-httproute-filter",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
Status: ptr.To(500),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-03-25 13:38:04 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, []string{"services.yml", "httproute/filter_extension_ref.yml"})
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
EntryPoints: test.entryPoints,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
2024-03-25 13:38:04 +00:00
|
|
|
for group, kindFuncs := range test.groupKindFilterFuncs {
|
|
|
|
for kind, filterFunc := range kindFuncs {
|
|
|
|
p.RegisterFilterFuncs(group, kind, filterFunc)
|
|
|
|
}
|
|
|
|
}
|
2024-06-13 09:16:04 +00:00
|
|
|
conf := p.loadConfigurationFromGateways(context.Background())
|
2024-03-25 13:38:04 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 09:50:12 +00:00
|
|
|
func TestLoadTCPRoutes(t *testing.T) {
|
2020-12-15 15:40:05 +00:00
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
2021-05-20 09:50:12 +00:00
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
entryPoints map[string]Entrypoint
|
2020-12-15 15:40:05 +00:00
|
|
|
}{
|
|
|
|
{
|
2021-05-20 09:50:12 +00:00
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because missing entry point",
|
|
|
|
paths: []string{"services.yml", "tcproute/simple.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8000",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because no tcp route defined",
|
|
|
|
paths: []string{"services.yml", "tcproute/without_tcproute.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by missing GatewayClass",
|
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tcproute/without_gatewayclass.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Empty caused by unknown GatewayClass controller desc",
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tcproute/gatewayclass_with_unknown_controller.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Empty caused by HTTPRoute with TLS configuration",
|
|
|
|
entryPoints: map[string]Entrypoint{"web": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tcproute/with_tls_configuration.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-09-03 10:10:04 +00:00
|
|
|
desc: "Router with service in error caused by wrong TargetPort",
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tcproute/with_wrong_service_port.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2024-09-03 10:10:04 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-TCP-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb": {
|
|
|
|
EntryPoints: []string{"TCP"},
|
|
|
|
Rule: "HostSNI(`*`)",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
Service: "default-TCP-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-wrr",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-TCP-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-wrr": {
|
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{{
|
|
|
|
Name: "default-TCP-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-err-lb",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-TCP-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-err-lb": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Simple TCPRoute",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "tcproute/simple.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Multiple TCPRoute",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "tcproute/with_multiple_routes.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp-1": {Address: ":9000"},
|
|
|
|
"tcp-2": {Address: ":10000"},
|
|
|
|
"not-tcp": {Address: ":11000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tcp-gateway-tcp-1-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-tcp-gateway-tcp-1-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-2-my-tcp-gateway-tcp-2-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp-2"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-2-my-tcp-gateway-tcp-2-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tcp-gateway-tcp-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-2-my-tcp-gateway-tcp-2-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-10000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-10000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:10000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:10000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "TCPRoute with multiple rules",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "tcproute/with_multiple_rules.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp-1": {Address: ":9000"},
|
|
|
|
"tcp-2": {Address: ":10000"},
|
|
|
|
"not-tcp": {Address: ":11000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-11-09 10:34:06 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-my-tcp-gateway-tcp-1-0-e3b0c44298fc1c149afb": {
|
|
|
|
EntryPoints: []string{"tcp-1"},
|
|
|
|
Service: "default-tcp-app-my-tcp-gateway-tcp-1-0-e3b0c44298fc1c149afb-wrr",
|
|
|
|
Rule: "HostSNI(`*`)",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
},
|
|
|
|
"default-tcp-app-my-tcp-gateway-tcp-1-1-e3b0c44298fc1c149afb": {
|
2021-11-09 10:34:06 +00:00
|
|
|
EntryPoints: []string{"tcp-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-my-tcp-gateway-tcp-1-1-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-11-09 10:34:06 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-my-tcp-gateway-tcp-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-my-tcp-gateway-tcp-1-1-e3b0c44298fc1c149afb-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-10000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-10000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:10000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:10000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TCPRoute, with backendRef",
|
|
|
|
paths: []string{"services.yml", "tcproute/simple_cross_provider.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "service@file",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TCPRoute, with TLS",
|
|
|
|
paths: []string{"services.yml", "tcproute/with_protocol_tls.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-10-04 13:46:08 +00:00
|
|
|
desc: "TCPRoute with Same namespace selector",
|
|
|
|
paths: []string{"services.yml", "tcproute/with_namespace_same.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {Address: ":9000"},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-10-04 13:46:08 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-10-04 13:46:08 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-10-04 13:46:08 +00:00
|
|
|
desc: "TCPRoute with All namespace selector",
|
|
|
|
paths: []string{"services.yml", "tcproute/with_namespace_all.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-10-04 13:46:08 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tcp-app-bar-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoamitcp-bar-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.13:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.14:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "TCPRoute with namespace selector",
|
2021-10-04 13:46:08 +00:00
|
|
|
paths: []string{"services.yml", "tcproute/with_namespace_selector.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tcp-app-bar-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-tcp-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoamitcp-bar-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.13:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.14:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, test.paths)
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
|
|
|
client.experimentalChannel = true
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
EntryPoints: test.entryPoints,
|
|
|
|
ExperimentalChannel: true,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
|
|
|
conf := p.loadConfigurationFromGateways(context.Background())
|
2021-10-04 13:46:08 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoadTLSRoutes(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
entryPoints map[string]Entrypoint
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because no matching entry point",
|
|
|
|
paths: []string{"services.yml", "tlsroute/simple_TLS_to_TCPRoute.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8000",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because no tls route defined",
|
|
|
|
paths: []string{"services.yml", "tlsroute/without_tlsroute.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by missing GatewayClass",
|
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tlsroute/without_gatewayclass.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Empty caused by unknown GatewayClass controller desc",
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tlsroute/gatewayclass_with_unknown_controller.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-09-03 10:10:04 +00:00
|
|
|
desc: "Router with service in error caused by wrong TargetPort",
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{"TCP": {
|
|
|
|
Address: ":8080",
|
|
|
|
}},
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_wrong_service_port.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2024-09-03 10:10:04 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
|
|
|
"default-tls-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb": {
|
|
|
|
EntryPoints: []string{"TCP"},
|
|
|
|
Rule: "HostSNI(`*`)",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
Service: "default-tls-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-wrr",
|
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"default-tls-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-wrr": {
|
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{{
|
|
|
|
Name: "default-tls-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-err-lb",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-tls-app-1-my-gateway-TCP-0-e3b0c44298fc1c149afb-err-lb": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Empty caused by mixed routes with wrong parent ref",
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {
|
|
|
|
Address: ":9000",
|
|
|
|
},
|
|
|
|
"tcp-tls": {
|
|
|
|
Address: ":9443",
|
|
|
|
},
|
|
|
|
"http": {
|
|
|
|
Address: ":80",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
paths: []string{"services.yml", "mixed/with_wrong_routes_selector.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Simple TLS listener to TCPRoute in Terminate mode",
|
|
|
|
paths: []string{"services.yml", "tlsroute/simple_TLS_to_TCPRoute.yml"},
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{
|
2021-11-09 10:34:06 +00:00
|
|
|
"tcp": {Address: ":9000"},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-11-09 10:34:06 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-11-09 10:34:06 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-11-09 10:34:06 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
2021-11-09 10:34:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Simple TLS listener to TCPRoute in Passthrough mode",
|
|
|
|
paths: []string{"services.yml", "tlsroute/simple_TLS_to_TCPRoute_passthrough.yml"},
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
2021-11-09 10:34:06 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TLS listener to TLSRoute",
|
|
|
|
paths: []string{"services.yml", "tlsroute/simple_TLS_to_TLSRoute.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "Multiple TLSRoute",
|
2021-05-20 09:50:12 +00:00
|
|
|
paths: []string{"services.yml", "tlsroute/with_multiple_routes_kind.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
"tcp": {Address: ":10000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tls-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-tls-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-tls-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-tls-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-10000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-10000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:10000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:10000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TLSRoute, with backendRef",
|
|
|
|
paths: []string{"services.yml", "tlsroute/simple_cross_provider.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "service@file",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TLSRoute, with Passthrough and TLS configuration should raise a warn",
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_passthrough_tls.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TLSRoute, with Passthrough",
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_passthrough.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TLSRoute, with single SNI matching",
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_SNI_matching.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple TLSRoute, with multiple SNI matching",
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_multiple_SNI_matching.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2022-12-12 15:30:05 +00:00
|
|
|
Rule: "HostSNI(`foo.example.com`) || HostSNI(`bar.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-10-04 13:46:08 +00:00
|
|
|
desc: "TLSRoute with Same namespace selector",
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_namespace_same.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-10-04 13:46:08 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`foo.default`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-10-04 13:46:08 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLSRoute with All namespace selector",
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_namespace_all.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`foo.default`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tls-app-bar-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tls-app-bar-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tls-app-bar-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoamitcp-bar-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.13:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.14:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "TLSRoute with namespace selector",
|
2021-10-04 13:46:08 +00:00
|
|
|
paths: []string{"services.yml", "tlsroute/with_namespace_selector.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tls-app-bar-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tls-app-bar-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`foo.bar`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tls-app-bar-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoamitcp-bar-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.13:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.14:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
{
|
2021-11-09 10:34:06 +00:00
|
|
|
desc: "TLSRoute with multiple rules",
|
|
|
|
paths: []string{"services.yml", "tlsroute/with_multiple_rules.yml"},
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{
|
2021-11-09 10:34:06 +00:00
|
|
|
"tcp-1": {Address: ":9000"},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2021-11-09 10:34:06 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-my-gateway-tcp-1-0-e3b0c44298fc1c149afb": {
|
2021-11-09 10:34:06 +00:00
|
|
|
EntryPoints: []string{"tcp-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-my-gateway-tcp-1-0-e3b0c44298fc1c149afb-wrr",
|
|
|
|
Rule: "HostSNI(`*`)",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-tls-app-my-gateway-tcp-1-1-e3b0c44298fc1c149afb": {
|
|
|
|
EntryPoints: []string{"tcp-1"},
|
|
|
|
Service: "default-tls-app-my-gateway-tcp-1-1-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-11-09 10:34:06 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-my-gateway-tcp-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-my-gateway-tcp-1-1-e3b0c44298fc1c149afb-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-10000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-10000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:10000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:10000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, test.paths)
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
|
|
|
client.experimentalChannel = true
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
EntryPoints: test.entryPoints,
|
|
|
|
ExperimentalChannel: true,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
|
|
|
conf := p.loadConfigurationFromGateways(context.Background())
|
2021-11-09 10:34:06 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLoadMixedRoutes(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2024-04-02 15:32:04 +00:00
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
entryPoints map[string]Entrypoint
|
|
|
|
experimentalChannel bool
|
2021-11-09 10:34:06 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by unsupported listener.Protocol",
|
|
|
|
paths: []string{"services.yml", "mixed/with_bad_listener_protocol.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by unsupported listener.Route.Kind",
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
},
|
|
|
|
paths: []string{"services.yml", "mixed/with_bad_listener_route_kind.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty caused by listener.Protocol does not support listener.Route.Kind",
|
|
|
|
paths: []string{"services.yml", "mixed/with_incompatible_protocol_and_route_kind.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Mixed routes",
|
|
|
|
paths: []string{"services.yml", "mixed/simple.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
"websecure": {Address: ":9443"},
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
"tls-1": {Address: ":10000"},
|
|
|
|
"tls-2": {Address: ":11000"},
|
|
|
|
},
|
2024-04-02 15:32:04 +00:00
|
|
|
experimentalChannel: true,
|
2021-05-20 09:50:12 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-1-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-2-0-e3b0c44298fc1c149afb": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"tls-2"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-1-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`pass.tls.foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-06-11 13:30:05 +00:00
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
2021-05-20 09:50:12 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-1-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-a431b128267aabc954fd": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-web-0-a431b128267aabc954fd-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-websecure-0-a431b128267aabc954fd": {
|
2021-05-20 09:50:12 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-websecure-0-a431b128267aabc954fd-wrr",
|
2021-05-20 09:50:12 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-05-20 09:50:12 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-web-0-a431b128267aabc954fd-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-websecure-0-a431b128267aabc954fd-wrr": {
|
2021-05-20 09:50:12 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-15 12:02:11 +00:00
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2022-06-23 09:58:09 +00:00
|
|
|
desc: "Empty caused by mixed routes with multiple listeners using same hostname, port and protocol",
|
|
|
|
paths: []string{"services.yml", "mixed/with_multiple_listeners_using_same_hostname_port_protocol.yml"},
|
2021-05-20 09:50:12 +00:00
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
"tls": {Address: ":9001"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
2022-12-09 08:58:05 +00:00
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
2021-07-15 12:02:11 +00:00
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
{
|
|
|
|
desc: "Mixed routes with Same namespace selector",
|
|
|
|
paths: []string{"services.yml", "mixed/with_namespace_same.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
"websecure": {Address: ":9443"},
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
"tls-1": {Address: ":10000"},
|
|
|
|
"tls-2": {Address: ":11000"},
|
|
|
|
},
|
2024-04-02 15:32:04 +00:00
|
|
|
experimentalChannel: true,
|
2021-10-04 13:46:08 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tls-1-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-2-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls-2"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-default-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`pass.tls.foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-web-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Mixed routes with All namespace selector",
|
|
|
|
paths: []string{"services.yml", "mixed/with_namespace_all.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
"websecure": {Address: ":9443"},
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
"tls-1": {Address: ":10000"},
|
|
|
|
"tls-2": {Address: ":11000"},
|
|
|
|
},
|
2024-04-02 15:32:04 +00:00
|
|
|
experimentalChannel: true,
|
2021-10-04 13:46:08 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tls-1-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-2-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls-2"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tls-app-default-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`pass.tls.foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tcp-app-bar-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tls-1-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tcp-app-bar-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tls-app-default-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoamitcp-bar-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.13:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.14:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-web-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-http-app-bar-my-gateway-web-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-websecure-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-http-app-bar-my-gateway-websecure-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"bar-whoami-bar-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.11:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.12:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoami-bar-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-websecure-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoami-bar-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Mixed routes with Selector Route Binding",
|
|
|
|
paths: []string{"services.yml", "mixed/with_namespace_selector.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
"websecure": {Address: ":9443"},
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
"tls-1": {Address: ":10000"},
|
|
|
|
"tls-2": {Address: ":11000"},
|
|
|
|
},
|
2024-04-02 15:32:04 +00:00
|
|
|
experimentalChannel: true,
|
2021-10-04 13:46:08 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tcp-app-bar-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tls-1-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls-1"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tcp-app-bar-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tls-app-bar-my-gateway-tls-2-0-e3b0c44298fc1c149afb": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"tls-2"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-tls-app-bar-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`pass.tls.foo.example.com`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
|
|
|
"bar-whoamitcp-bar-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.13:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.14:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tcp-app-bar-my-gateway-tls-1-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-tls-app-bar-my-gateway-tls-2-0-e3b0c44298fc1c149afb-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoamitcp-bar-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-http-app-bar-my-gateway-web-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-websecure-0-a431b128267aabc954fd": {
|
2021-10-04 13:46:08 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "bar-http-app-bar-my-gateway-websecure-0-a431b128267aabc954fd-wrr",
|
2021-10-04 13:46:08 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-10-04 13:46:08 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
|
|
|
"bar-whoami-bar-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.11:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.12:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-web-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoami-bar-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"bar-http-app-bar-my-gateway-websecure-0-a431b128267aabc954fd-wrr": {
|
2021-10-04 13:46:08 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "bar-whoami-bar-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-10-04 13:46:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-11-09 10:34:06 +00:00
|
|
|
{
|
|
|
|
desc: "Mixed routes with core group",
|
|
|
|
paths: []string{"services.yml", "mixed/with_core_group.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"web": {Address: ":9080"},
|
|
|
|
"websecure": {Address: ":9443"},
|
|
|
|
"tcp": {Address: ":9000"},
|
|
|
|
"tls": {Address: ":10000"},
|
|
|
|
},
|
2024-04-02 15:32:04 +00:00
|
|
|
experimentalChannel: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb": {
|
2021-11-09 10:34:06 +00:00
|
|
|
EntryPoints: []string{"tcp"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2021-11-09 10:34:06 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tcp-0-e3b0c44298fc1c149afb-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-default-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-12-09 08:58:05 +00:00
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-a431b128267aabc954fd": {
|
2021-11-09 10:34:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-web-0-a431b128267aabc954fd-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd": {
|
2021-11-09 10:34:06 +00:00
|
|
|
EntryPoints: []string{"websecure"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd-wrr",
|
2021-11-09 10:34:06 +00:00
|
|
|
Rule: "PathPrefix(`/`)",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 2,
|
2024-01-23 10:34:05 +00:00
|
|
|
RuleSyntax: "v3",
|
2021-11-09 10:34:06 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-web-0-a431b128267aabc954fd-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-default-my-gateway-websecure-0-a431b128267aabc954fd-wrr": {
|
2021-11-09 10:34:06 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-80",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoami-80": {
|
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
PassHostHeader: ptr.To(true),
|
2022-11-16 10:38:07 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{
|
|
|
|
FlushInterval: ptypes.Duration(100 * time.Millisecond),
|
|
|
|
},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
2024-01-11 16:06:06 +00:00
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-05-20 09:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, test.paths)
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
|
|
|
client.experimentalChannel = test.experimentalChannel
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
EntryPoints: test.entryPoints,
|
|
|
|
ExperimentalChannel: test.experimentalChannel,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
|
|
|
conf := p.loadConfigurationFromGateways(context.Background())
|
2021-05-20 09:50:12 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-30 15:44:05 +00:00
|
|
|
func TestLoadRoutesWithReferenceGrants(t *testing.T) {
|
|
|
|
testCases := []struct {
|
2024-04-02 15:32:04 +00:00
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
|
|
|
expected *dynamic.Configuration
|
|
|
|
entryPoints map[string]Entrypoint
|
|
|
|
experimentalChannel bool
|
2024-01-30 15:44:05 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because ReferenceGrant for Secret is missing",
|
|
|
|
paths: []string{"services.yml", "referencegrant/for_secret_missing.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-06-04 12:16:04 +00:00
|
|
|
desc: "Empty because ReferenceGrant spec.from does not match secret",
|
2024-01-30 15:44:05 +00:00
|
|
|
paths: []string{"services.yml", "referencegrant/for_secret_not_matching_from.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2024-06-04 12:16:04 +00:00
|
|
|
desc: "Empty because ReferenceGrant spec.to does not match secret",
|
2024-01-30 15:44:05 +00:00
|
|
|
paths: []string{"services.yml", "referencegrant/for_secret_not_matching_to.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "For Secret",
|
|
|
|
paths: []string{"services.yml", "referencegrant/for_secret.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
2024-04-02 15:32:04 +00:00
|
|
|
experimentalChannel: true,
|
2024-01-30 15:44:05 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb": {
|
2024-01-30 15:44:05 +00:00
|
|
|
EntryPoints: []string{"tls"},
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr",
|
2024-01-30 15:44:05 +00:00
|
|
|
Rule: "HostSNI(`*`)",
|
|
|
|
RuleSyntax: "v3",
|
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-tcp-app-1-my-gateway-tls-0-e3b0c44298fc1c149afb-wrr": {
|
2024-01-30 15:44:05 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{{
|
|
|
|
Name: "default-whoamitcp-9000",
|
2024-05-22 15:20:04 +00:00
|
|
|
Weight: ptr.To(1),
|
2024-01-30 15:44:05 +00:00
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"default-whoamitcp-9000": {
|
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.9:9000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.10:9000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
|
|
|
CertFile: types.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: types.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-06-04 12:16:04 +00:00
|
|
|
{
|
|
|
|
desc: "Empty because ReferenceGrant for Service is missing",
|
|
|
|
paths: []string{"services.yml", "referencegrant/for_secret_missing.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because ReferenceGrant spec.from does not match service",
|
|
|
|
paths: []string{"services.yml", "referencegrant/for_service_not_matching_from.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty because ReferenceGrant spec.to does not match service",
|
|
|
|
paths: []string{"services.yml", "referencegrant/for_service_not_matching_to.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"tls": {Address: ":9000"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "For Service",
|
|
|
|
paths: []string{"services.yml", "referencegrant/for_service.yml"},
|
|
|
|
entryPoints: map[string]Entrypoint{
|
|
|
|
"http": {Address: ":80"},
|
|
|
|
},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
UDP: &dynamic.UDPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.UDPRouter{},
|
|
|
|
Services: map[string]*dynamic.UDPService{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Middlewares: map[string]*dynamic.TCPMiddleware{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
ServersTransports: map[string]*dynamic.TCPServersTransport{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2024-06-13 09:16:04 +00:00
|
|
|
"default-http-app-1-my-gateway-http-0-d40286ed9f4652ca2108": {
|
2024-06-04 12:16:04 +00:00
|
|
|
EntryPoints: []string{"http"},
|
2024-06-13 09:16:04 +00:00
|
|
|
Rule: "Host(`foo.example.com`) && PathPrefix(`/`)",
|
2024-09-03 10:10:04 +00:00
|
|
|
Service: "default-http-app-1-my-gateway-http-0-d40286ed9f4652ca2108-wrr",
|
2024-06-04 12:16:04 +00:00
|
|
|
RuleSyntax: "v3",
|
2024-06-13 09:16:04 +00:00
|
|
|
Priority: 17,
|
2024-06-04 12:16:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2024-09-03 10:10:04 +00:00
|
|
|
"default-http-app-1-my-gateway-http-0-d40286ed9f4652ca2108-wrr": {
|
2024-06-04 12:16:04 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
|
|
|
Name: "default-whoami-bar-80",
|
|
|
|
Weight: ptr.To(1),
|
|
|
|
Status: ptr.To(500),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServersTransports: map[string]*dynamic.ServersTransport{},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2024-01-30 15:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, test.paths)
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
|
|
|
client.experimentalChannel = test.experimentalChannel
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
EntryPoints: test.entryPoints,
|
|
|
|
ExperimentalChannel: test.experimentalChannel,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
|
|
|
conf := p.loadConfigurationFromGateways(context.Background())
|
2024-01-30 15:44:05 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
func Test_matchListener(t *testing.T) {
|
2021-05-20 09:50:12 +00:00
|
|
|
testCases := []struct {
|
2024-05-28 12:30:04 +00:00
|
|
|
desc string
|
|
|
|
gwListener gatewayListener
|
|
|
|
parentRef gatev1.ParentReference
|
|
|
|
routeNamespace string
|
|
|
|
wantMatch bool
|
2021-05-20 09:50:12 +00:00
|
|
|
}{
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Unsupported group",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
Group: ptr.To(gatev1.Group("foo")),
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: false,
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Unsupported kind",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
|
|
|
Kind: ptr.To(gatev1.Kind("foo")),
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: false,
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Namespace does not match the listener",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2021-04-29 15:18:04 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
Namespace: ptr.To(gatev1.Namespace("foo")),
|
|
|
|
Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
|
|
|
Kind: ptr.To(gatev1.Kind("Gateway")),
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: false,
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Route namespace defaulting does not match the listener",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
routeNamespace: "foo",
|
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
|
|
|
Kind: ptr.To(gatev1.Kind("Gateway")),
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: false,
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Name does not match the listener",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
Namespace: ptr.To(gatev1.Namespace("default")),
|
|
|
|
Name: "foo",
|
|
|
|
Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
|
|
|
Kind: ptr.To(gatev1.Kind("Gateway")),
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: false,
|
2021-07-15 15:20:08 +00:00
|
|
|
},
|
2020-12-15 15:40:05 +00:00
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "SectionName does not match a listener",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
SectionName: ptr.To(gatev1.SectionName("bar")),
|
|
|
|
Name: "gateway",
|
|
|
|
Namespace: ptr.To(gatev1.Namespace("default")),
|
|
|
|
Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
|
|
|
Kind: ptr.To(gatev1.Kind("Gateway")),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: false,
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Match",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
SectionName: ptr.To(gatev1.SectionName("foo")),
|
|
|
|
Name: "gateway",
|
|
|
|
Namespace: ptr.To(gatev1.Namespace("default")),
|
|
|
|
Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
|
|
|
Kind: ptr.To(gatev1.Kind("Gateway")),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: true,
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Match with route namespace defaulting",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
routeNamespace: "default",
|
|
|
|
parentRef: gatev1.ParentReference{
|
|
|
|
SectionName: ptr.To(gatev1.SectionName("foo")),
|
|
|
|
Name: "gateway",
|
|
|
|
Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
|
|
|
Kind: ptr.To(gatev1.Kind("Gateway")),
|
2020-12-15 15:40:05 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
wantMatch: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
gotMatch := matchListener(test.gwListener, test.routeNamespace, test.parentRef)
|
|
|
|
assert.Equal(t, test.wantMatch, gotMatch)
|
2021-11-09 10:34:06 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
func Test_allowRoute(t *testing.T) {
|
2021-11-09 10:34:06 +00:00
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
2024-05-28 12:30:04 +00:00
|
|
|
gwListener gatewayListener
|
2021-11-09 10:34:06 +00:00
|
|
|
routeNamespace string
|
2024-05-28 12:30:04 +00:00
|
|
|
routeKind string
|
|
|
|
wantAllow bool
|
2021-11-09 10:34:06 +00:00
|
|
|
}{
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Not allowed Kind",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
|
|
|
AllowedRouteKinds: []string{
|
|
|
|
"foo",
|
|
|
|
"bar",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
routeKind: "baz",
|
|
|
|
wantAllow: false,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Allowed Kind",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
|
|
|
AllowedRouteKinds: []string{
|
|
|
|
"foo",
|
|
|
|
"bar",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
AllowedNamespaces: []string{
|
|
|
|
corev1.NamespaceAll,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
routeKind: "bar",
|
|
|
|
wantAllow: true,
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Not allowed namespace",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
|
|
|
AllowedRouteKinds: []string{
|
|
|
|
"foo",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
AllowedNamespaces: []string{
|
|
|
|
"foo",
|
|
|
|
"bar",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
routeKind: "foo",
|
|
|
|
routeNamespace: "baz",
|
|
|
|
wantAllow: false,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Allowed namespace",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
|
|
|
AllowedRouteKinds: []string{
|
|
|
|
"foo",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
AllowedNamespaces: []string{
|
|
|
|
"foo",
|
|
|
|
"bar",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
routeKind: "foo",
|
|
|
|
routeNamespace: "foo",
|
|
|
|
wantAllow: true,
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Allowed namespace",
|
|
|
|
gwListener: gatewayListener{
|
|
|
|
Name: "foo",
|
|
|
|
GWName: "gateway",
|
|
|
|
GWNamespace: "default",
|
|
|
|
AllowedRouteKinds: []string{
|
|
|
|
"foo",
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
AllowedNamespaces: []string{
|
|
|
|
corev1.NamespaceAll,
|
|
|
|
"bar",
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
},
|
2024-05-28 12:30:04 +00:00
|
|
|
routeKind: "foo",
|
|
|
|
routeNamespace: "foo",
|
|
|
|
wantAllow: true,
|
2021-05-20 09:50:12 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
gotAllow := allowRoute(test.gwListener, test.routeNamespace, test.routeKind)
|
|
|
|
assert.Equal(t, test.wantAllow, gotAllow)
|
2021-11-09 10:34:06 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
func Test_findMatchingHostnames(t *testing.T) {
|
2022-06-23 09:58:09 +00:00
|
|
|
testCases := []struct {
|
2024-05-28 12:30:04 +00:00
|
|
|
desc string
|
|
|
|
listenerHostname *gatev1.Hostname
|
|
|
|
routeHostnames []gatev1.Hostname
|
|
|
|
want []gatev1.Hostname
|
|
|
|
wantOk bool
|
2021-11-09 10:34:06 +00:00
|
|
|
}{
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Empty",
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Only listener hostname",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("foo.com")),
|
|
|
|
want: []gatev1.Hostname{"foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Only Route hostname",
|
|
|
|
routeHostnames: []gatev1.Hostname{"foo.com"},
|
|
|
|
want: []gatev1.Hostname{"foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Matching hostname",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"foo.com"},
|
|
|
|
want: []gatev1.Hostname{"foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Matching hostname with wildcard",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("*.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"*.foo.com"},
|
|
|
|
want: []gatev1.Hostname{"*.foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Matching subdomain with listener wildcard",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("*.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"bar.foo.com"},
|
|
|
|
want: []gatev1.Hostname{"bar.foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Matching subsubdomain with listener wildcard",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("*.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"baz.bar.foo.com"},
|
|
|
|
want: []gatev1.Hostname{"baz.bar.foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Matching subdomain with route hostname wildcard",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("bar.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"*.foo.com"},
|
|
|
|
want: []gatev1.Hostname{"bar.foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Matching subsubdomain with route hostname wildcard",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("baz.bar.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"*.foo.com"},
|
|
|
|
want: []gatev1.Hostname{"baz.bar.foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Non matching root domain with listener wildcard",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("*.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"foo.com"},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Non matching root domain with route hostname wildcard",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"*.foo.com"},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
{
|
2024-05-28 12:30:04 +00:00
|
|
|
desc: "Multiple route hostnames with one matching route hostname",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("*.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"bar.com", "test.foo.com", "test.buz.com"},
|
|
|
|
want: []gatev1.Hostname{"test.foo.com"},
|
|
|
|
wantOk: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Multiple route hostnames with non matching route hostname",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("*.fuz.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"bar.com", "test.foo.com", "test.buz.com"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Multiple route hostnames with multiple matching route hostnames",
|
|
|
|
listenerHostname: ptr.To(gatev1.Hostname("*.foo.com")),
|
|
|
|
routeHostnames: []gatev1.Hostname{"toto.foo.com", "test.foo.com", "test.buz.com"},
|
|
|
|
want: []gatev1.Hostname{"toto.foo.com", "test.foo.com"},
|
|
|
|
wantOk: true,
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-06-23 09:58:09 +00:00
|
|
|
for _, test := range testCases {
|
2021-11-09 10:34:06 +00:00
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
got, ok := findMatchingHostnames(test.listenerHostname, test.routeHostnames)
|
|
|
|
assert.Equal(t, test.wantOk, ok)
|
2021-11-09 10:34:06 +00:00
|
|
|
assert.Equal(t, test.want, got)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
func Test_allowedRouteKinds(t *testing.T) {
|
2022-06-23 09:58:09 +00:00
|
|
|
testCases := []struct {
|
2021-11-09 10:34:06 +00:00
|
|
|
desc string
|
2024-01-09 09:28:05 +00:00
|
|
|
listener gatev1.Listener
|
|
|
|
supportedRouteKinds []gatev1.RouteGroupKind
|
|
|
|
wantKinds []gatev1.RouteGroupKind
|
2021-11-09 10:34:06 +00:00
|
|
|
wantErr bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Empty AllowedRoutes",
|
2024-01-09 09:28:05 +00:00
|
|
|
supportedRouteKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
wantKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "AllowedRoutes with unsupported Group",
|
2024-01-09 09:28:05 +00:00
|
|
|
listener: gatev1.Listener{
|
|
|
|
AllowedRoutes: &gatev1.AllowedRoutes{
|
|
|
|
Kinds: []gatev1.RouteGroupKind{{
|
2024-05-28 12:30:04 +00:00
|
|
|
Kind: kindTLSRoute, Group: ptr.To(gatev1.Group("foo")),
|
2021-11-09 10:34:06 +00:00
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
supportedRouteKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "AllowedRoutes with nil Group",
|
2024-01-09 09:28:05 +00:00
|
|
|
listener: gatev1.Listener{
|
|
|
|
AllowedRoutes: &gatev1.AllowedRoutes{
|
|
|
|
Kinds: []gatev1.RouteGroupKind{{
|
2021-11-09 10:34:06 +00:00
|
|
|
Kind: kindTLSRoute, Group: nil,
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
supportedRouteKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "AllowedRoutes with unsupported Kind",
|
2024-01-09 09:28:05 +00:00
|
|
|
listener: gatev1.Listener{
|
|
|
|
AllowedRoutes: &gatev1.AllowedRoutes{
|
|
|
|
Kinds: []gatev1.RouteGroupKind{{
|
2024-05-28 12:30:04 +00:00
|
|
|
Kind: "foo", Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
2021-11-09 10:34:06 +00:00
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
supportedRouteKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
wantErr: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Supported AllowedRoutes",
|
2024-01-09 09:28:05 +00:00
|
|
|
listener: gatev1.Listener{
|
|
|
|
AllowedRoutes: &gatev1.AllowedRoutes{
|
|
|
|
Kinds: []gatev1.RouteGroupKind{{
|
2024-05-28 12:30:04 +00:00
|
|
|
Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName)),
|
2021-11-09 10:34:06 +00:00
|
|
|
}},
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
supportedRouteKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
wantKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Supported AllowedRoutes with duplicates",
|
2024-01-09 09:28:05 +00:00
|
|
|
listener: gatev1.Listener{
|
|
|
|
AllowedRoutes: &gatev1.AllowedRoutes{
|
|
|
|
Kinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
|
|
|
{Kind: kindTCPRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
|
|
|
{Kind: kindTCPRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
supportedRouteKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
|
|
|
{Kind: kindTCPRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
2024-01-09 09:28:05 +00:00
|
|
|
wantKinds: []gatev1.RouteGroupKind{
|
2024-05-28 12:30:04 +00:00
|
|
|
{Kind: kindTLSRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
|
|
|
{Kind: kindTCPRoute, Group: ptr.To(gatev1.Group(gatev1.GroupName))},
|
2021-11-09 10:34:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-06-23 09:58:09 +00:00
|
|
|
for _, test := range testCases {
|
2021-11-09 10:34:06 +00:00
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-28 12:30:04 +00:00
|
|
|
got, conditions := allowedRouteKinds(&gatev1.Gateway{}, test.listener, test.supportedRouteKinds)
|
2021-11-09 10:34:06 +00:00
|
|
|
if test.wantErr {
|
|
|
|
require.NotEmpty(t, conditions, "no conditions")
|
2021-05-20 09:50:12 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-11-17 00:50:06 +00:00
|
|
|
require.Empty(t, conditions)
|
2021-11-09 10:34:06 +00:00
|
|
|
assert.Equal(t, test.wantKinds, got)
|
2021-05-20 09:50:12 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2021-11-09 10:34:06 +00:00
|
|
|
|
2022-06-23 09:58:09 +00:00
|
|
|
func Test_makeListenerKey(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
2024-01-09 09:28:05 +00:00
|
|
|
listener gatev1.Listener
|
2022-06-23 09:58:09 +00:00
|
|
|
expectedKey string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "empty",
|
|
|
|
expectedKey: "||0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "listener with port, protocol and hostname",
|
2024-01-09 09:28:05 +00:00
|
|
|
listener: gatev1.Listener{
|
2022-06-23 09:58:09 +00:00
|
|
|
Port: 443,
|
2024-01-09 09:28:05 +00:00
|
|
|
Protocol: gatev1.HTTPSProtocolType,
|
2024-05-28 12:30:04 +00:00
|
|
|
Hostname: ptr.To(gatev1.Hostname("www.example.com")),
|
2022-06-23 09:58:09 +00:00
|
|
|
},
|
|
|
|
expectedKey: "HTTPS|www.example.com|443",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "listener with port, protocol and nil hostname",
|
2024-01-09 09:28:05 +00:00
|
|
|
listener: gatev1.Listener{
|
2022-06-23 09:58:09 +00:00
|
|
|
Port: 443,
|
2024-01-09 09:28:05 +00:00
|
|
|
Protocol: gatev1.HTTPSProtocolType,
|
2022-06-23 09:58:09 +00:00
|
|
|
},
|
|
|
|
expectedKey: "HTTPS||443",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
assert.Equal(t, test.expectedKey, makeListenerKey(test.listener))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-30 15:44:05 +00:00
|
|
|
func Test_referenceGrantMatchesFrom(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
referenceGrant gatev1beta1.ReferenceGrant
|
|
|
|
group string
|
|
|
|
kind string
|
|
|
|
namespace string
|
|
|
|
expectedResult bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "matches",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
From: []gatev1beta1.ReferenceGrantFrom{
|
|
|
|
{
|
|
|
|
Group: "correct-group",
|
|
|
|
Kind: "correct-kind",
|
|
|
|
Namespace: "correct-namespace",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
namespace: "correct-namespace",
|
|
|
|
expectedResult: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "empty group matches core",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
From: []gatev1beta1.ReferenceGrantFrom{
|
|
|
|
{
|
|
|
|
Group: "",
|
|
|
|
Kind: "correct-kind",
|
|
|
|
Namespace: "correct-namespace",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "core",
|
|
|
|
kind: "correct-kind",
|
|
|
|
namespace: "correct-namespace",
|
|
|
|
expectedResult: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "wrong group",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
From: []gatev1beta1.ReferenceGrantFrom{
|
|
|
|
{
|
|
|
|
Group: "wrong-group",
|
|
|
|
Kind: "correct-kind",
|
|
|
|
Namespace: "correct-namespace",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
namespace: "correct-namespace",
|
|
|
|
expectedResult: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "wrong kind",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
From: []gatev1beta1.ReferenceGrantFrom{
|
|
|
|
{
|
|
|
|
Group: "correct-group",
|
|
|
|
Kind: "wrong-kind",
|
|
|
|
Namespace: "correct-namespace",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
namespace: "correct-namespace",
|
|
|
|
expectedResult: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "wrong namespace",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
From: []gatev1beta1.ReferenceGrantFrom{
|
|
|
|
{
|
|
|
|
Group: "correct-group",
|
|
|
|
Kind: "correct-kind",
|
|
|
|
Namespace: "wrong-namespace",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
namespace: "correct-namespace",
|
|
|
|
expectedResult: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
assert.Equal(t, test.expectedResult, referenceGrantMatchesFrom(&test.referenceGrant, test.group, test.kind, test.namespace))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_referenceGrantMatchesTo(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
referenceGrant gatev1beta1.ReferenceGrant
|
|
|
|
group string
|
|
|
|
kind string
|
|
|
|
name string
|
|
|
|
expectedResult bool
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "matches",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
To: []gatev1beta1.ReferenceGrantTo{
|
|
|
|
{
|
|
|
|
Group: "correct-group",
|
|
|
|
Kind: "correct-kind",
|
2024-05-28 12:30:04 +00:00
|
|
|
Name: ptr.To(gatev1.ObjectName("correct-name")),
|
2024-01-30 15:44:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
name: "correct-name",
|
|
|
|
expectedResult: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "matches without name",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
To: []gatev1beta1.ReferenceGrantTo{
|
|
|
|
{
|
|
|
|
Group: "correct-group",
|
|
|
|
Kind: "correct-kind",
|
|
|
|
Name: nil,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
name: "some-name",
|
|
|
|
expectedResult: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "empty group matches core",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
To: []gatev1beta1.ReferenceGrantTo{
|
|
|
|
{
|
|
|
|
Group: "",
|
|
|
|
Kind: "correct-kind",
|
2024-05-28 12:30:04 +00:00
|
|
|
Name: ptr.To(gatev1.ObjectName("correct-name")),
|
2024-01-30 15:44:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "core",
|
|
|
|
kind: "correct-kind",
|
|
|
|
name: "correct-name",
|
|
|
|
expectedResult: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "wrong group",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
To: []gatev1beta1.ReferenceGrantTo{
|
|
|
|
{
|
|
|
|
Group: "wrong-group",
|
|
|
|
Kind: "correct-kind",
|
2024-05-28 12:30:04 +00:00
|
|
|
Name: ptr.To(gatev1.ObjectName("correct-name")),
|
2024-01-30 15:44:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
name: "correct-namespace",
|
|
|
|
expectedResult: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "wrong kind",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
To: []gatev1beta1.ReferenceGrantTo{
|
|
|
|
{
|
|
|
|
Group: "correct-group",
|
|
|
|
Kind: "wrong-kind",
|
2024-05-28 12:30:04 +00:00
|
|
|
Name: ptr.To(gatev1.ObjectName("correct-name")),
|
2024-01-30 15:44:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
name: "correct-name",
|
|
|
|
expectedResult: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "wrong name",
|
|
|
|
referenceGrant: gatev1beta1.ReferenceGrant{
|
|
|
|
Spec: gatev1beta1.ReferenceGrantSpec{
|
|
|
|
To: []gatev1beta1.ReferenceGrantTo{
|
|
|
|
{
|
|
|
|
Group: "correct-group",
|
|
|
|
Kind: "correct-kind",
|
2024-05-28 12:30:04 +00:00
|
|
|
Name: ptr.To(gatev1.ObjectName("wrong-name")),
|
2024-01-30 15:44:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
group: "correct-group",
|
|
|
|
kind: "correct-kind",
|
|
|
|
name: "correct-name",
|
|
|
|
expectedResult: false,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
assert.Equal(t, test.expectedResult, referenceGrantMatchesTo(&test.referenceGrant, test.group, test.kind, test.name))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-10 07:34:07 +00:00
|
|
|
func Test_gatewayAddresses(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
statusAddress *StatusAddress
|
|
|
|
paths []string
|
|
|
|
wantErr require.ErrorAssertionFunc
|
|
|
|
want []gatev1.GatewayStatusAddress
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "nothing",
|
|
|
|
wantErr: require.NoError,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "empty configuration",
|
|
|
|
statusAddress: &StatusAddress{},
|
|
|
|
wantErr: require.Error,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "IP address",
|
|
|
|
statusAddress: &StatusAddress{
|
|
|
|
IP: "1.2.3.4",
|
|
|
|
},
|
|
|
|
wantErr: require.NoError,
|
|
|
|
want: []gatev1.GatewayStatusAddress{
|
|
|
|
{
|
|
|
|
Type: ptr.To(gatev1.IPAddressType),
|
|
|
|
Value: "1.2.3.4",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "hostname address",
|
|
|
|
statusAddress: &StatusAddress{
|
|
|
|
Hostname: "foo.bar",
|
|
|
|
},
|
|
|
|
wantErr: require.NoError,
|
|
|
|
want: []gatev1.GatewayStatusAddress{
|
|
|
|
{
|
|
|
|
Type: ptr.To(gatev1.HostnameAddressType),
|
|
|
|
Value: "foo.bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "service",
|
|
|
|
statusAddress: &StatusAddress{
|
|
|
|
Service: ServiceRef{
|
|
|
|
Name: "status-address",
|
|
|
|
Namespace: "default",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
paths: []string{"services.yml"},
|
|
|
|
wantErr: require.NoError,
|
|
|
|
want: []gatev1.GatewayStatusAddress{
|
|
|
|
{
|
|
|
|
Type: ptr.To(gatev1.HostnameAddressType),
|
|
|
|
Value: "foo.bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: ptr.To(gatev1.IPAddressType),
|
|
|
|
Value: "1.2.3.4",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "missing service",
|
|
|
|
statusAddress: &StatusAddress{
|
|
|
|
Service: ServiceRef{
|
|
|
|
Name: "status-address2",
|
|
|
|
Namespace: "default",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
wantErr: require.Error,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "service without load-balancer status",
|
|
|
|
statusAddress: &StatusAddress{
|
|
|
|
Service: ServiceRef{
|
|
|
|
Name: "whoamitcp-bar",
|
|
|
|
Namespace: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
paths: []string{"services.yml"},
|
|
|
|
wantErr: require.NoError,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
k8sObjects, gwObjects := readResources(t, test.paths)
|
|
|
|
|
|
|
|
kubeClient := kubefake.NewSimpleClientset(k8sObjects...)
|
|
|
|
gwClient := newGatewaySimpleClientSet(t, gwObjects...)
|
|
|
|
|
|
|
|
client := newClientImpl(kubeClient, gwClient)
|
|
|
|
|
|
|
|
eventCh, err := client.WatchAll(nil, make(chan struct{}))
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
if len(k8sObjects) > 0 || len(gwObjects) > 0 {
|
|
|
|
// just wait for the first event
|
|
|
|
<-eventCh
|
|
|
|
}
|
|
|
|
|
2024-06-13 09:16:04 +00:00
|
|
|
p := Provider{
|
|
|
|
StatusAddress: test.statusAddress,
|
|
|
|
client: client,
|
|
|
|
}
|
|
|
|
|
|
|
|
got, err := p.gatewayAddresses()
|
2024-04-10 07:34:07 +00:00
|
|
|
test.wantErr(t, err)
|
|
|
|
|
|
|
|
assert.Equal(t, test.want, got)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-04 12:16:04 +00:00
|
|
|
func Test_upsertRouteConditionResolvedRefs(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
conditions []metav1.Condition
|
|
|
|
condition metav1.Condition
|
|
|
|
wantConditions []metav1.Condition
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "True to False",
|
|
|
|
conditions: []metav1.Condition{
|
|
|
|
{
|
|
|
|
Type: "foo",
|
|
|
|
Status: "bar",
|
|
|
|
Reason: "baz",
|
|
|
|
Message: "foobarbaz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionTrue,
|
|
|
|
Reason: "foo",
|
|
|
|
Message: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
condition: metav1.Condition{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionFalse,
|
|
|
|
Reason: "bar",
|
|
|
|
Message: "bar",
|
|
|
|
},
|
|
|
|
wantConditions: []metav1.Condition{
|
|
|
|
{
|
|
|
|
Type: "foo",
|
|
|
|
Status: "bar",
|
|
|
|
Reason: "baz",
|
|
|
|
Message: "foobarbaz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionFalse,
|
|
|
|
Reason: "bar",
|
|
|
|
Message: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "False to False",
|
|
|
|
conditions: []metav1.Condition{
|
|
|
|
{
|
|
|
|
Type: "foo",
|
|
|
|
Status: "bar",
|
|
|
|
Reason: "baz",
|
|
|
|
Message: "foobarbaz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionFalse,
|
|
|
|
Reason: "foo",
|
|
|
|
Message: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
condition: metav1.Condition{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionFalse,
|
|
|
|
Reason: "bar",
|
|
|
|
Message: "bar",
|
|
|
|
},
|
|
|
|
wantConditions: []metav1.Condition{
|
|
|
|
{
|
|
|
|
Type: "foo",
|
|
|
|
Status: "bar",
|
|
|
|
Reason: "baz",
|
|
|
|
Message: "foobarbaz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionFalse,
|
|
|
|
Reason: "bar",
|
|
|
|
Message: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "False to True: no upsert",
|
|
|
|
conditions: []metav1.Condition{
|
|
|
|
{
|
|
|
|
Type: "foo",
|
|
|
|
Status: "bar",
|
|
|
|
Reason: "baz",
|
|
|
|
Message: "foobarbaz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionFalse,
|
|
|
|
Reason: "foo",
|
|
|
|
Message: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
condition: metav1.Condition{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionTrue,
|
|
|
|
Reason: "bar",
|
|
|
|
Message: "bar",
|
|
|
|
},
|
|
|
|
wantConditions: []metav1.Condition{
|
|
|
|
{
|
|
|
|
Type: "foo",
|
|
|
|
Status: "bar",
|
|
|
|
Reason: "baz",
|
|
|
|
Message: "foobarbaz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: string(gatev1.RouteConditionResolvedRefs),
|
|
|
|
Status: metav1.ConditionFalse,
|
|
|
|
Reason: "foo",
|
|
|
|
Message: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
got := upsertRouteConditionResolvedRefs(test.conditions, test.condition)
|
|
|
|
assert.Equal(t, test.wantConditions, got)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-01 04:38:03 +00:00
|
|
|
// We cannot use the gateway-api fake.NewSimpleClientset due to Gateway being pluralized as "gatewaies" instead of "gateways".
|
|
|
|
func newGatewaySimpleClientSet(t *testing.T, objects ...runtime.Object) *gatefake.Clientset {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
client := gatefake.NewSimpleClientset(objects...)
|
|
|
|
for _, object := range objects {
|
|
|
|
gateway, ok := object.(*gatev1.Gateway)
|
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err := client.GatewayV1().Gateways(gateway.Namespace).Create(context.Background(), gateway, metav1.CreateOptions{})
|
|
|
|
require.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return client
|
|
|
|
}
|
|
|
|
|
|
|
|
func readResources(t *testing.T, paths []string) ([]runtime.Object, []runtime.Object) {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
var k8sObjects []runtime.Object
|
|
|
|
var gwObjects []runtime.Object
|
|
|
|
for _, path := range paths {
|
|
|
|
yamlContent, err := os.ReadFile(filepath.FromSlash("./fixtures/" + path))
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
objects := k8s.MustParseYaml(yamlContent)
|
|
|
|
for _, obj := range objects {
|
|
|
|
switch obj.GetObjectKind().GroupVersionKind().Group {
|
|
|
|
case "gateway.networking.k8s.io":
|
|
|
|
gwObjects = append(gwObjects, obj)
|
|
|
|
default:
|
|
|
|
k8sObjects = append(k8sObjects, obj)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return k8sObjects, gwObjects
|
|
|
|
}
|