Move dynamic config into a dedicated package.
This commit is contained in:
parent
09cc1161c9
commit
c8bf8e896a
102 changed files with 3170 additions and 3166 deletions
|
@ -11,7 +11,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/containous/mux"
|
||||
"github.com/containous/traefik/pkg/config"
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/static"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -29,13 +29,13 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
path string
|
||||
conf config.RuntimeConfiguration
|
||||
conf dynamic.RuntimeConfiguration
|
||||
expected expected
|
||||
}{
|
||||
{
|
||||
desc: "all TCP routers, but no config",
|
||||
path: "/api/tcp/routers",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusOK,
|
||||
nextPage: "1",
|
||||
|
@ -45,20 +45,20 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all TCP routers",
|
||||
path: "/api/tcp/routers",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*config.TCPRouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*dynamic.TCPRouterInfo{
|
||||
"test@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar.other`)",
|
||||
TLS: &config.RouterTCPTLSConfig{
|
||||
TLS: &dynamic.RouterTCPTLSConfig{
|
||||
Passthrough: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"bar@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -75,24 +75,24 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all TCP routers, pagination, 1 res per page, want page 2",
|
||||
path: "/api/tcp/routers?page=2&per_page=1",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*config.TCPRouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*dynamic.TCPRouterInfo{
|
||||
"bar@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
"baz@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`toto.bar`)",
|
||||
},
|
||||
},
|
||||
"test@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar.other`)",
|
||||
|
@ -109,10 +109,10 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one TCP router by id",
|
||||
path: "/api/tcp/routers/bar@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*config.TCPRouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*dynamic.TCPRouterInfo{
|
||||
"bar@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -128,10 +128,10 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one TCP router by id, that does not exist",
|
||||
path: "/api/tcp/routers/foo@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*config.TCPRouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPRouters: map[string]*dynamic.TCPRouterInfo{
|
||||
"bar@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -146,7 +146,7 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one TCP router by id, but no config",
|
||||
path: "/api/tcp/routers/bar@myprovider",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusNotFound,
|
||||
},
|
||||
|
@ -154,7 +154,7 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all tcp services, but no config",
|
||||
path: "/api/tcp/services",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusOK,
|
||||
nextPage: "1",
|
||||
|
@ -164,12 +164,12 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all tcp services",
|
||||
path: "/api/tcp/services",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPServices: map[string]*config.TCPServiceInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPServices: map[string]*dynamic.TCPServiceInfo{
|
||||
"bar@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1:2345",
|
||||
},
|
||||
|
@ -179,9 +179,9 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
UsedBy: []string{"foo@myprovider", "test@myprovider"},
|
||||
},
|
||||
"baz@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.2:2345",
|
||||
},
|
||||
|
@ -201,12 +201,12 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all tcp services, 1 res per page, want page 2",
|
||||
path: "/api/tcp/services?page=2&per_page=1",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPServices: map[string]*config.TCPServiceInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPServices: map[string]*dynamic.TCPServiceInfo{
|
||||
"bar@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1:2345",
|
||||
},
|
||||
|
@ -216,9 +216,9 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
UsedBy: []string{"foo@myprovider", "test@myprovider"},
|
||||
},
|
||||
"baz@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.2:2345",
|
||||
},
|
||||
|
@ -228,9 +228,9 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
UsedBy: []string{"foo@myprovider"},
|
||||
},
|
||||
"test@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.3:2345",
|
||||
},
|
||||
|
@ -249,12 +249,12 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one tcp service by id",
|
||||
path: "/api/tcp/services/bar@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPServices: map[string]*config.TCPServiceInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPServices: map[string]*dynamic.TCPServiceInfo{
|
||||
"bar@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1:2345",
|
||||
},
|
||||
|
@ -273,12 +273,12 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one tcp service by id, that does not exist",
|
||||
path: "/api/tcp/services/nono@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
TCPServices: map[string]*config.TCPServiceInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
TCPServices: map[string]*dynamic.TCPServiceInfo{
|
||||
"bar@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1:2345",
|
||||
},
|
||||
|
@ -296,7 +296,7 @@ func TestHandlerTCP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one tcp service by id, but no config",
|
||||
path: "/api/tcp/services/foo@myprovider",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusNotFound,
|
||||
},
|
||||
|
@ -363,13 +363,13 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
path string
|
||||
conf config.RuntimeConfiguration
|
||||
conf dynamic.RuntimeConfiguration
|
||||
expected expected
|
||||
}{
|
||||
{
|
||||
desc: "all routers, but no config",
|
||||
path: "/api/http/routers",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusOK,
|
||||
nextPage: "1",
|
||||
|
@ -379,10 +379,10 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all routers",
|
||||
path: "/api/http/routers",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Routers: map[string]*config.RouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Routers: map[string]*dynamic.RouterInfo{
|
||||
"test@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar.other`)",
|
||||
|
@ -390,7 +390,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"bar@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -408,10 +408,10 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all routers, pagination, 1 res per page, want page 2",
|
||||
path: "/api/http/routers?page=2&per_page=1",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Routers: map[string]*config.RouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Routers: map[string]*dynamic.RouterInfo{
|
||||
"bar@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -419,14 +419,14 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"baz@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`toto.bar`)",
|
||||
},
|
||||
},
|
||||
"test@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar.other`)",
|
||||
|
@ -444,7 +444,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all routers, pagination, 19 results overall, 7 res per page, want page 3",
|
||||
path: "/api/http/routers?page=3&per_page=7",
|
||||
conf: config.RuntimeConfiguration{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Routers: generateHTTPRouters(19),
|
||||
},
|
||||
expected: expected{
|
||||
|
@ -456,7 +456,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all routers, pagination, 5 results overall, 10 res per page, want page 2",
|
||||
path: "/api/http/routers?page=2&per_page=10",
|
||||
conf: config.RuntimeConfiguration{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Routers: generateHTTPRouters(5),
|
||||
},
|
||||
expected: expected{
|
||||
|
@ -466,7 +466,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all routers, pagination, 10 results overall, 10 res per page, want page 2",
|
||||
path: "/api/http/routers?page=2&per_page=10",
|
||||
conf: config.RuntimeConfiguration{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Routers: generateHTTPRouters(10),
|
||||
},
|
||||
expected: expected{
|
||||
|
@ -476,10 +476,10 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one router by id",
|
||||
path: "/api/http/routers/bar@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Routers: map[string]*config.RouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Routers: map[string]*dynamic.RouterInfo{
|
||||
"bar@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -496,10 +496,10 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one router by id, that does not exist",
|
||||
path: "/api/http/routers/foo@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Routers: map[string]*config.RouterInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Routers: map[string]*dynamic.RouterInfo{
|
||||
"bar@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -515,7 +515,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one router by id, but no config",
|
||||
path: "/api/http/routers/foo@myprovider",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusNotFound,
|
||||
},
|
||||
|
@ -523,7 +523,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all services, but no config",
|
||||
path: "/api/http/services",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusOK,
|
||||
nextPage: "1",
|
||||
|
@ -533,13 +533,13 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all services",
|
||||
path: "/api/http/services",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Services: map[string]*config.ServiceInfo{
|
||||
"bar@myprovider": func() *config.ServiceInfo {
|
||||
si := &config.ServiceInfo{
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Services: map[string]*dynamic.ServiceInfo{
|
||||
"bar@myprovider": func() *dynamic.ServiceInfo {
|
||||
si := &dynamic.ServiceInfo{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -551,11 +551,11 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
si.UpdateStatus("http://127.0.0.1", "UP")
|
||||
return si
|
||||
}(),
|
||||
"baz@myprovider": func() *config.ServiceInfo {
|
||||
si := &config.ServiceInfo{
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
"baz@myprovider": func() *dynamic.ServiceInfo {
|
||||
si := &dynamic.ServiceInfo{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.2",
|
||||
},
|
||||
|
@ -578,13 +578,13 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all services, 1 res per page, want page 2",
|
||||
path: "/api/http/services?page=2&per_page=1",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Services: map[string]*config.ServiceInfo{
|
||||
"bar@myprovider": func() *config.ServiceInfo {
|
||||
si := &config.ServiceInfo{
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Services: map[string]*dynamic.ServiceInfo{
|
||||
"bar@myprovider": func() *dynamic.ServiceInfo {
|
||||
si := &dynamic.ServiceInfo{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -596,11 +596,11 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
si.UpdateStatus("http://127.0.0.1", "UP")
|
||||
return si
|
||||
}(),
|
||||
"baz@myprovider": func() *config.ServiceInfo {
|
||||
si := &config.ServiceInfo{
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
"baz@myprovider": func() *dynamic.ServiceInfo {
|
||||
si := &dynamic.ServiceInfo{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.2",
|
||||
},
|
||||
|
@ -612,11 +612,11 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
si.UpdateStatus("http://127.0.0.2", "UP")
|
||||
return si
|
||||
}(),
|
||||
"test@myprovider": func() *config.ServiceInfo {
|
||||
si := &config.ServiceInfo{
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
"test@myprovider": func() *dynamic.ServiceInfo {
|
||||
si := &dynamic.ServiceInfo{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.3",
|
||||
},
|
||||
|
@ -639,13 +639,13 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one service by id",
|
||||
path: "/api/http/services/bar@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Services: map[string]*config.ServiceInfo{
|
||||
"bar@myprovider": func() *config.ServiceInfo {
|
||||
si := &config.ServiceInfo{
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Services: map[string]*dynamic.ServiceInfo{
|
||||
"bar@myprovider": func() *dynamic.ServiceInfo {
|
||||
si := &dynamic.ServiceInfo{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -667,13 +667,13 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one service by id, that does not exist",
|
||||
path: "/api/http/services/nono@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Services: map[string]*config.ServiceInfo{
|
||||
"bar@myprovider": func() *config.ServiceInfo {
|
||||
si := &config.ServiceInfo{
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Services: map[string]*dynamic.ServiceInfo{
|
||||
"bar@myprovider": func() *dynamic.ServiceInfo {
|
||||
si := &dynamic.ServiceInfo{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -694,7 +694,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one service by id, but no config",
|
||||
path: "/api/http/services/foo@myprovider",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusNotFound,
|
||||
},
|
||||
|
@ -702,7 +702,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all middlewares, but no config",
|
||||
path: "/api/http/middlewares",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusOK,
|
||||
nextPage: "1",
|
||||
|
@ -712,27 +712,27 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all middlewares",
|
||||
path: "/api/http/middlewares",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Middlewares: map[string]*config.MiddlewareInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Middlewares: map[string]*dynamic.MiddlewareInfo{
|
||||
"auth@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
BasicAuth: &config.BasicAuth{
|
||||
Middleware: &dynamic.Middleware{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"admin:admin"},
|
||||
},
|
||||
},
|
||||
UsedBy: []string{"bar@myprovider", "test@myprovider"},
|
||||
},
|
||||
"addPrefixTest@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/titi",
|
||||
},
|
||||
},
|
||||
UsedBy: []string{"test@myprovider"},
|
||||
},
|
||||
"addPrefixTest@anotherprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/toto",
|
||||
},
|
||||
},
|
||||
|
@ -749,27 +749,27 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "all middlewares, 1 res per page, want page 2",
|
||||
path: "/api/http/middlewares?page=2&per_page=1",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Middlewares: map[string]*config.MiddlewareInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Middlewares: map[string]*dynamic.MiddlewareInfo{
|
||||
"auth@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
BasicAuth: &config.BasicAuth{
|
||||
Middleware: &dynamic.Middleware{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"admin:admin"},
|
||||
},
|
||||
},
|
||||
UsedBy: []string{"bar@myprovider", "test@myprovider"},
|
||||
},
|
||||
"addPrefixTest@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/titi",
|
||||
},
|
||||
},
|
||||
UsedBy: []string{"test@myprovider"},
|
||||
},
|
||||
"addPrefixTest@anotherprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/toto",
|
||||
},
|
||||
},
|
||||
|
@ -786,27 +786,27 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one middleware by id",
|
||||
path: "/api/http/middlewares/auth@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Middlewares: map[string]*config.MiddlewareInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Middlewares: map[string]*dynamic.MiddlewareInfo{
|
||||
"auth@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
BasicAuth: &config.BasicAuth{
|
||||
Middleware: &dynamic.Middleware{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"admin:admin"},
|
||||
},
|
||||
},
|
||||
UsedBy: []string{"bar@myprovider", "test@myprovider"},
|
||||
},
|
||||
"addPrefixTest@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/titi",
|
||||
},
|
||||
},
|
||||
UsedBy: []string{"test@myprovider"},
|
||||
},
|
||||
"addPrefixTest@anotherprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/toto",
|
||||
},
|
||||
},
|
||||
|
@ -822,11 +822,11 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one middleware by id, that does not exist",
|
||||
path: "/api/http/middlewares/foo@myprovider",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Middlewares: map[string]*config.MiddlewareInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Middlewares: map[string]*dynamic.MiddlewareInfo{
|
||||
"auth@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
BasicAuth: &config.BasicAuth{
|
||||
Middleware: &dynamic.Middleware{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"admin:admin"},
|
||||
},
|
||||
},
|
||||
|
@ -841,7 +841,7 @@ func TestHandlerHTTP_API(t *testing.T) {
|
|||
{
|
||||
desc: "one middleware by id, but no config",
|
||||
path: "/api/http/middlewares/foo@myprovider",
|
||||
conf: config.RuntimeConfiguration{},
|
||||
conf: dynamic.RuntimeConfiguration{},
|
||||
expected: expected{
|
||||
statusCode: http.StatusNotFound,
|
||||
},
|
||||
|
@ -906,18 +906,18 @@ func TestHandler_Configuration(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
path string
|
||||
conf config.RuntimeConfiguration
|
||||
conf dynamic.RuntimeConfiguration
|
||||
expected expected
|
||||
}{
|
||||
{
|
||||
desc: "Get rawdata",
|
||||
path: "/api/rawdata",
|
||||
conf: config.RuntimeConfiguration{
|
||||
Services: map[string]*config.ServiceInfo{
|
||||
conf: dynamic.RuntimeConfiguration{
|
||||
Services: map[string]*dynamic.ServiceInfo{
|
||||
"foo-service@myprovider": {
|
||||
Service: &config.Service{
|
||||
LoadBalancer: &config.LoadBalancerService{
|
||||
Servers: []config.Server{
|
||||
Service: &dynamic.Service{
|
||||
LoadBalancer: &dynamic.LoadBalancerService{
|
||||
Servers: []dynamic.Server{
|
||||
{
|
||||
URL: "http://127.0.0.1",
|
||||
},
|
||||
|
@ -926,32 +926,32 @@ func TestHandler_Configuration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
Middlewares: map[string]*config.MiddlewareInfo{
|
||||
Middlewares: map[string]*dynamic.MiddlewareInfo{
|
||||
"auth@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
BasicAuth: &config.BasicAuth{
|
||||
Middleware: &dynamic.Middleware{
|
||||
BasicAuth: &dynamic.BasicAuth{
|
||||
Users: []string{"admin:admin"},
|
||||
},
|
||||
},
|
||||
},
|
||||
"addPrefixTest@myprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/titi",
|
||||
},
|
||||
},
|
||||
},
|
||||
"addPrefixTest@anotherprovider": {
|
||||
Middleware: &config.Middleware{
|
||||
AddPrefix: &config.AddPrefix{
|
||||
Middleware: &dynamic.Middleware{
|
||||
AddPrefix: &dynamic.AddPrefix{
|
||||
Prefix: "/toto",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Routers: map[string]*config.RouterInfo{
|
||||
Routers: map[string]*dynamic.RouterInfo{
|
||||
"bar@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar`)",
|
||||
|
@ -959,7 +959,7 @@ func TestHandler_Configuration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"test@myprovider": {
|
||||
Router: &config.Router{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar.other`)",
|
||||
|
@ -967,11 +967,11 @@ func TestHandler_Configuration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TCPServices: map[string]*config.TCPServiceInfo{
|
||||
TCPServices: map[string]*dynamic.TCPServiceInfo{
|
||||
"tcpfoo-service@myprovider": {
|
||||
TCPService: &config.TCPService{
|
||||
LoadBalancer: &config.TCPLoadBalancerService{
|
||||
Servers: []config.TCPServer{
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
Servers: []dynamic.TCPServer{
|
||||
{
|
||||
Address: "127.0.0.1",
|
||||
},
|
||||
|
@ -980,16 +980,16 @@ func TestHandler_Configuration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TCPRouters: map[string]*config.TCPRouterInfo{
|
||||
TCPRouters: map[string]*dynamic.TCPRouterInfo{
|
||||
"tcpbar@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "tcpfoo-service@myprovider",
|
||||
Rule: "HostSNI(`foo.bar`)",
|
||||
},
|
||||
},
|
||||
"tcptest@myprovider": {
|
||||
TCPRouter: &config.TCPRouter{
|
||||
TCPRouter: &dynamic.TCPRouter{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "tcpfoo-service@myprovider",
|
||||
Rule: "HostSNI(`foo.bar.other`)",
|
||||
|
@ -1054,11 +1054,11 @@ func TestHandler_Configuration(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func generateHTTPRouters(nbRouters int) map[string]*config.RouterInfo {
|
||||
routers := make(map[string]*config.RouterInfo, nbRouters)
|
||||
func generateHTTPRouters(nbRouters int) map[string]*dynamic.RouterInfo {
|
||||
routers := make(map[string]*dynamic.RouterInfo, nbRouters)
|
||||
for i := 0; i < nbRouters; i++ {
|
||||
routers[fmt.Sprintf("bar%2d@myprovider", i)] = &config.RouterInfo{
|
||||
Router: &config.Router{
|
||||
routers[fmt.Sprintf("bar%2d@myprovider", i)] = &dynamic.RouterInfo{
|
||||
Router: &dynamic.Router{
|
||||
EntryPoints: []string{"web"},
|
||||
Service: "foo-service@myprovider",
|
||||
Rule: "Host(`foo.bar" + strconv.Itoa(i) + "`)",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue