2019-03-14 14:56:06 +00:00
|
|
|
package crd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"testing"
|
|
|
|
|
2019-08-03 01:58:23 +00:00
|
|
|
"github.com/containous/traefik/v2/pkg/config/dynamic"
|
|
|
|
"github.com/containous/traefik/v2/pkg/provider"
|
|
|
|
"github.com/containous/traefik/v2/pkg/tls"
|
2019-03-14 14:56:06 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ provider.Provider = (*Provider)(nil)
|
|
|
|
|
2019-09-30 16:12:04 +00:00
|
|
|
func Int(v int) *int { return &v }
|
|
|
|
func Bool(v bool) *bool { return &v }
|
2019-08-26 08:30:05 +00:00
|
|
|
|
2019-06-11 13:12:04 +00:00
|
|
|
func TestLoadIngressRouteTCPs(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
2019-07-10 07:26:04 +00:00
|
|
|
expected *dynamic.Configuration
|
2019-06-11 13:12:04 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with foo entrypoint",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/simple.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different rules",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_two_rules.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-f44ce589164e656d231c": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-f44ce589164e656d231c",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`bar.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-f44ce589164e656d231c": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-09-13 18:00:06 +00:00
|
|
|
desc: "One ingress Route with two different services",
|
2019-06-11 13:12:04 +00:00
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_two_services.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
Weighted: &dynamic.TCPWeightedRoundRobin{
|
|
|
|
Services: []dynamic.TCPWRRService{
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000",
|
2019-09-13 18:00:06 +00:00
|
|
|
Weight: func(i int) *int { return &i }(2),
|
|
|
|
},
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080",
|
2019-09-13 18:00:06 +00:00
|
|
|
Weight: func(i int) *int { return &i }(3),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp-8000": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
},
|
2019-09-13 18:00:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc-whoamitcp2-8080": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:00:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress class does not match",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/simple.yml"},
|
|
|
|
ingressClass: "tchouk",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Route with empty rule value is ignored",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_no_rule_value.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "check rule quoting validity",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_bad_host_rule.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
|
|
|
CertFile: tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: tls.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with passthrough",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_passthrough.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-06-11 13:12:04 +00:00
|
|
|
Passthrough: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with tls options",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
|
|
|
CAFiles: []tls.FileOrContent{
|
2019-06-27 21:58:03 +00:00
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
SniStrict: true,
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with tls options and specific namespace",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_options_and_specific_namespace.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"myns-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
|
|
|
CAFiles: []tls.FileOrContent{
|
2019-06-27 21:58:03 +00:00
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
SniStrict: true,
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "myns-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with bad tls options",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_bad_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
|
|
|
CAFiles: []tls.FileOrContent{
|
2019-06-27 21:58:03 +00:00
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
|
|
|
SniStrict: true,
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with unknown tls options",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_unknown_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-unknown",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with unknown tls options namespace",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_unknown_tls_options_namespace.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "unknown-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with ACME",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_tls_acme.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-06-11 13:12:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-06-11 13:12:04 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTCPTLSConfig{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.TCPServer{
|
2019-06-11 13:12:04 +00:00
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:00:06 +00:00
|
|
|
{
|
|
|
|
desc: "TCP with terminationDelay",
|
|
|
|
paths: []string{"tcp/services.yml", "tcp/with_termination_delay.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-fdd3e9338e47a45efefc",
|
2019-09-13 18:00:06 +00:00
|
|
|
Rule: "HostSNI(`foo.com`)",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.TCPService{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-fdd3e9338e47a45efefc": {
|
2019-09-13 18:00:06 +00:00
|
|
|
LoadBalancer: &dynamic.TCPServersLoadBalancer{
|
|
|
|
Servers: []dynamic.TCPServer{
|
|
|
|
{
|
|
|
|
Address: "10.10.0.1:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Address: "10.10.0.2:8000",
|
|
|
|
Port: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TerminationDelay: Int(500),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-11 13:12:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
2019-06-21 15:18:05 +00:00
|
|
|
|
2019-06-11 13:12:04 +00:00
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
p := Provider{IngressClass: test.ingressClass}
|
2019-06-21 15:18:05 +00:00
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), newClientMock(test.paths...))
|
2019-06-11 13:12:04 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-14 14:56:06 +00:00
|
|
|
func TestLoadIngressRoutes(t *testing.T) {
|
|
|
|
testCases := []struct {
|
|
|
|
desc string
|
|
|
|
ingressClass string
|
|
|
|
paths []string
|
2019-07-10 07:26:04 +00:00
|
|
|
expected *dynamic.Configuration
|
2019-03-14 14:56:06 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
desc: "Empty",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with foo entrypoint",
|
|
|
|
paths: []string{"services.yml", "simple.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route with middleware",
|
|
|
|
paths: []string{"services.yml", "with_middleware.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test2.route-23c7f4c450289ee29016": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test2.route-23c7f4c450289ee29016",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/tobestripped`)",
|
|
|
|
Priority: 12,
|
2019-09-13 18:44:04 +00:00
|
|
|
Middlewares: []string{"default-stripprefix", "foo-addprefix"},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-stripprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
2019-03-14 14:56:06 +00:00
|
|
|
Prefixes: []string{"/tobestripped"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"foo-addprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
AddPrefix: &dynamic.AddPrefix{
|
2019-03-14 14:56:06 +00:00
|
|
|
Prefix: "/tobeadded",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test2.route-23c7f4c450289ee29016": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-26 12:14:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route with middleware crossprovider",
|
|
|
|
paths: []string{"services.yml", "with_middleware_crossprovider.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test2.route-23c7f4c450289ee29016": {
|
2019-06-26 12:14:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test2.route-23c7f4c450289ee29016",
|
2019-06-26 12:14:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/tobestripped`)",
|
|
|
|
Priority: 12,
|
2019-09-13 18:44:04 +00:00
|
|
|
Middlewares: []string{"default-stripprefix", "foo-addprefix", "basicauth@file", "redirect@file"},
|
2019-06-26 12:14:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-stripprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
StripPrefix: &dynamic.StripPrefix{
|
2019-06-26 12:14:05 +00:00
|
|
|
Prefixes: []string{"/tobestripped"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"foo-addprefix": {
|
2019-07-10 07:26:04 +00:00
|
|
|
AddPrefix: &dynamic.AddPrefix{
|
2019-06-26 12:14:05 +00:00
|
|
|
Prefix: "/tobeadded",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test2.route-23c7f4c450289ee29016": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different rules",
|
|
|
|
paths: []string{"services.yml", "with_two_rules.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Priority: 14,
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-77c62dfe9517144aeeaa",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2019-08-26 08:30:05 +00:00
|
|
|
desc: "One ingress Route with two different services",
|
2019-03-14 14:56:06 +00:00
|
|
|
paths: []string{"services.yml", "with_two_services.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-77c62dfe9517144aeeaa",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-77c62dfe9517144aeeaa-whoami-80",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-77c62dfe9517144aeeaa-whoami2-8080",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: func(i int) *int { return &i }(1),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa-whoami-80": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa-whoami2-8080": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.3:8080",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.4:8080",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "One ingress Route with two different services, with weights",
|
|
|
|
paths: []string{"services.yml", "with_two_services_weight.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-77c62dfe9517144aeeaa",
|
2019-08-26 08:30:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/foo`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa": {
|
2019-08-26 08:30:05 +00:00
|
|
|
Weighted: &dynamic.WeightedRoundRobin{
|
|
|
|
Services: []dynamic.WRRService{
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-77c62dfe9517144aeeaa-whoami-80",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: Int(10),
|
|
|
|
},
|
|
|
|
{
|
2019-09-13 18:44:04 +00:00
|
|
|
Name: "default-test.route-77c62dfe9517144aeeaa-whoami2-8080",
|
2019-08-26 08:30:05 +00:00
|
|
|
Weight: Int(0),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa-whoami-80": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-08-26 08:30:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-77c62dfe9517144aeeaa-whoami2-8080": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.3:8080",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.4:8080",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Ingress class",
|
|
|
|
paths: []string{"services.yml", "simple.yml"},
|
|
|
|
ingressClass: "tchouk",
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Route with empty rule value is ignored",
|
|
|
|
paths: []string{"services.yml", "with_no_rule_value.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Route with kind not of a rule type (empty kind) is ignored",
|
|
|
|
paths: []string{"services.yml", "with_wrong_rule_kind.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "check rule quoting validity",
|
|
|
|
paths: []string{"services.yml", "with_bad_host_rule.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS",
|
|
|
|
paths: []string{"services.yml", "with_tls.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Certificates: []*tls.CertAndStores{
|
|
|
|
{
|
|
|
|
Certificate: tls.Certificate{
|
|
|
|
CertFile: tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
KeyFile: tls.FileOrContent("-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----"),
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-11 13:12:04 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-26 10:12:04 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-26 10:12:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with tls options",
|
|
|
|
paths: []string{"services.yml", "with_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
|
|
|
CAFiles: []tls.FileOrContent{
|
2019-06-27 21:58:03 +00:00
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
SniStrict: true,
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with tls options and specific namespace",
|
|
|
|
paths: []string{"services.yml", "with_tls_options_and_specific_namespace.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"myns-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
|
|
|
CAFiles: []tls.FileOrContent{
|
2019-06-27 21:58:03 +00:00
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-06-27 21:58:03 +00:00
|
|
|
SniStrict: true,
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "myns-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with bad tls options",
|
|
|
|
paths: []string{"services.yml", "with_bad_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
CipherSuites: []string{
|
|
|
|
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
|
|
|
|
"TLS_RSA_WITH_AES_256_GCM_SHA384",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuth: tls.ClientAuth{
|
|
|
|
CAFiles: []tls.FileOrContent{
|
2019-06-27 21:58:03 +00:00
|
|
|
tls.FileOrContent("-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----"),
|
|
|
|
},
|
2019-07-12 15:50:04 +00:00
|
|
|
ClientAuthType: "VerifyClientCertIfGiven",
|
2019-06-27 21:58:03 +00:00
|
|
|
},
|
|
|
|
SniStrict: true,
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with unknown tls options",
|
|
|
|
paths: []string{"services.yml", "with_unknown_tls_options.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "default-unknown",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "TLS with unknown tls options namespace",
|
|
|
|
paths: []string{"services.yml", "with_unknown_tls_options_namespace.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{
|
2019-06-27 21:58:03 +00:00
|
|
|
Options: map[string]tls.Options{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-foo": {
|
2019-06-27 21:58:03 +00:00
|
|
|
MinVersion: "VersionTLS12",
|
|
|
|
},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-06-21 15:18:05 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-06-21 15:18:05 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{
|
2019-09-13 18:44:04 +00:00
|
|
|
Options: "unknown-foo",
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-06-21 15:18:05 +00:00
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-06-21 15:18:05 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-03-26 10:12:04 +00:00
|
|
|
{
|
|
|
|
desc: "TLS with ACME",
|
|
|
|
paths: []string{"services.yml", "with_tls_acme.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-03-26 10:12:04 +00:00
|
|
|
EntryPoints: []string{"web"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-03-26 10:12:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
2019-07-10 07:26:04 +00:00
|
|
|
TLS: &dynamic.RouterTLSConfig{},
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.1:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-06-05 20:18:06 +00:00
|
|
|
URL: "http://10.10.0.2:80",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, defaulting to https for servers",
|
|
|
|
paths: []string{"services.yml", "with_https_default.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-03-14 14:56:06 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-03-14 14:56:06 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
2019-08-14 16:58:04 +00:00
|
|
|
URL: "https://10.10.0.5:8443",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
{
|
2019-08-14 16:58:04 +00:00
|
|
|
URL: "https://10.10.0.6:8443",
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-03-14 14:56:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-07-05 15:24:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, explicit https scheme",
|
|
|
|
paths: []string{"services.yml", "with_https_scheme.yml"},
|
2019-07-10 07:26:04 +00:00
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-07-05 15:24:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-07-05 15:24:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
2019-07-10 07:26:04 +00:00
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-08-26 08:30:05 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
2019-07-10 07:26:04 +00:00
|
|
|
Servers: []dynamic.Server{
|
2019-07-05 15:24:04 +00:00
|
|
|
{
|
|
|
|
URL: "https://10.10.0.7:8443",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "https://10.10.0.8:8443",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-07-05 15:24:04 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-05 11:42:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with basic auth middleware",
|
|
|
|
paths: []string{"services.yml", "with_auth.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-basicauth": {
|
2019-09-05 11:42:04 +00:00
|
|
|
BasicAuth: &dynamic.BasicAuth{
|
|
|
|
Users: dynamic.Users{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-digestauth": {
|
2019-09-05 11:42:04 +00:00
|
|
|
DigestAuth: &dynamic.DigestAuth{
|
|
|
|
Users: dynamic.Users{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-forwardauth": {
|
2019-09-05 11:42:04 +00:00
|
|
|
ForwardAuth: &dynamic.ForwardAuth{
|
|
|
|
Address: "test.com",
|
|
|
|
TLS: &dynamic.ClientTLS{
|
|
|
|
CA: "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----",
|
|
|
|
Cert: "-----BEGIN CERTIFICATE-----\n-----END CERTIFICATE-----",
|
|
|
|
Key: "-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-10 15:24:03 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with error page middleware",
|
|
|
|
paths: []string{"services.yml", "with_error_page.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-errorpage": {
|
2019-09-10 15:24:03 +00:00
|
|
|
Errors: &dynamic.ErrorPage{
|
|
|
|
Status: []string{"404", "500"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-errorpage-errorpage-service",
|
2019-09-10 15:24:03 +00:00
|
|
|
Query: "query",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-errorpage-errorpage-service": {
|
2019-09-10 15:24:03 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(true),
|
2019-09-10 15:24:03 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-09-13 14:46:04 +00:00
|
|
|
{
|
|
|
|
desc: "Simple Ingress Route, with options",
|
|
|
|
paths: []string{"services.yml", "with_options.yml"},
|
|
|
|
expected: &dynamic.Configuration{
|
|
|
|
TCP: &dynamic.TCPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.TCPRouter{},
|
|
|
|
Services: map[string]*dynamic.TCPService{},
|
|
|
|
},
|
|
|
|
HTTP: &dynamic.HTTPConfiguration{
|
|
|
|
Routers: map[string]*dynamic.Router{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-09-13 14:46:04 +00:00
|
|
|
EntryPoints: []string{"foo"},
|
2019-09-13 18:44:04 +00:00
|
|
|
Service: "default-test.route-6b204d94623b3df4370c",
|
2019-09-13 14:46:04 +00:00
|
|
|
Rule: "Host(`foo.com`) && PathPrefix(`/bar`)",
|
|
|
|
Priority: 12,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Middlewares: map[string]*dynamic.Middleware{},
|
|
|
|
Services: map[string]*dynamic.Service{
|
2019-09-13 18:44:04 +00:00
|
|
|
"default-test.route-6b204d94623b3df4370c": {
|
2019-09-13 14:46:04 +00:00
|
|
|
LoadBalancer: &dynamic.ServersLoadBalancer{
|
|
|
|
Servers: []dynamic.Server{
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.1:80",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
URL: "http://10.10.0.2:80",
|
|
|
|
},
|
|
|
|
},
|
2019-09-30 16:12:04 +00:00
|
|
|
PassHostHeader: Bool(false),
|
2019-09-13 14:46:04 +00:00
|
|
|
ResponseForwarding: &dynamic.ResponseForwarding{FlushInterval: "10s"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
TLS: &dynamic.TLSConfiguration{},
|
|
|
|
},
|
|
|
|
},
|
2019-03-14 14:56:06 +00:00
|
|
|
{
|
|
|
|
desc: "port selected by name (TODO)",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range testCases {
|
|
|
|
test := test
|
2019-09-13 14:46:04 +00:00
|
|
|
|
2019-03-14 14:56:06 +00:00
|
|
|
t.Run(test.desc, func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
if test.expected == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
p := Provider{IngressClass: test.ingressClass}
|
2019-06-21 15:18:05 +00:00
|
|
|
conf := p.loadConfigurationFromCRD(context.Background(), newClientMock(test.paths...))
|
2019-03-14 14:56:06 +00:00
|
|
|
assert.Equal(t, test.expected, conf)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|