Fix tests to accept entrypoints
This commit is contained in:
parent
c22598c8ff
commit
81cb00573f
14 changed files with 107 additions and 79 deletions
|
@ -46,9 +46,10 @@ func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) {
|
||||||
// TODO validate : run on 80
|
// TODO validate : run on 80
|
||||||
resp, err := http.Get("http://127.0.0.1:8000/")
|
resp, err := http.Get("http://127.0.0.1:8000/")
|
||||||
|
|
||||||
// Expected a 404 as we did not configure anything
|
// Expected no response as we did not configure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(resp, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(err, checker.NotNil)
|
||||||
|
c.Assert(err.Error(), checker.Contains, fmt.Sprintf("getsockopt: connection refused"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleSuite) TestWithWebConfig(c *check.C) {
|
func (s *SimpleSuite) TestWithWebConfig(c *check.C) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
checker "github.com/vdemeester/shakers"
|
checker "github.com/vdemeester/shakers"
|
||||||
check "gopkg.in/check.v1"
|
check "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
@ -19,7 +20,8 @@ func (s *ConsulSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
// TODO validate : run on 80
|
// TODO validate : run on 80
|
||||||
resp, err := http.Get("http://127.0.0.1:8000/")
|
resp, err := http.Get("http://127.0.0.1:8000/")
|
||||||
|
|
||||||
// Expected a 404 as we did not comfigure anything
|
// Expected no response as we did not configure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(resp, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(err, checker.NotNil)
|
||||||
|
c.Assert(err.Error(), checker.Contains, fmt.Sprintf("getsockopt: connection refused"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
# Reverse proxy port
|
defaultEntryPoints = ["http"]
|
||||||
#
|
|
||||||
# Optional
|
[entryPoints]
|
||||||
# Default: ":80"
|
[entryPoints.http]
|
||||||
#
|
address = ":8000"
|
||||||
# port = ":80"
|
|
||||||
port = ":8000"
|
|
||||||
#
|
|
||||||
# LogLevel
|
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
[consul]
|
[consul]
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
# Reverse proxy port
|
defaultEntryPoints = ["http"]
|
||||||
#
|
|
||||||
# Optional
|
[entryPoints]
|
||||||
# Default: ":80"
|
[entryPoints.http]
|
||||||
#
|
address = ":8000"
|
||||||
# port = ":80"
|
|
||||||
port = ":8000"
|
|
||||||
#
|
|
||||||
# LogLevel
|
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
[docker]
|
[docker]
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
# Reverse proxy port
|
defaultEntryPoints = ["http"]
|
||||||
#
|
|
||||||
# Optional
|
[entryPoints]
|
||||||
# Default: ":80"
|
[entryPoints.http]
|
||||||
#
|
address = ":8000"
|
||||||
# port = ":80"
|
|
||||||
port = ":8000"
|
|
||||||
#
|
|
||||||
# LogLevel
|
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
[file]
|
[file]
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
# Reverse proxy port
|
defaultEntryPoints = ["http"]
|
||||||
#
|
|
||||||
# Optional
|
[entryPoints]
|
||||||
# Default: ":80"
|
[entryPoints.http]
|
||||||
#
|
address = ":8000"
|
||||||
# port = ":80"
|
|
||||||
port = ":8000"
|
|
||||||
#
|
|
||||||
# LogLevel
|
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
[file]
|
[file]
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
port = ":4443"
|
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
[[certificates]]
|
defaultEntryPoints = ["https"]
|
||||||
CertFile = "fixtures/https/snitest.com.cert"
|
|
||||||
KeyFile = "fixtures/https/snitest.com.key"
|
|
||||||
|
|
||||||
[[certificates]]
|
[entryPoints]
|
||||||
CertFile = "fixtures/https/snitest.org.cert"
|
[entryPoints.https]
|
||||||
KeyFile = "fixtures/https/snitest.org.key"
|
address = ":4443"
|
||||||
|
[entryPoints.https.tls]
|
||||||
|
[[entryPoints.https.tls.certificates]]
|
||||||
|
CertFile = "fixtures/https/snitest.com.cert"
|
||||||
|
KeyFile = "fixtures/https/snitest.com.key"
|
||||||
|
[[entryPoints.https.tls.certificates]]
|
||||||
|
CertFile = "fixtures/https/snitest.org.cert"
|
||||||
|
KeyFile = "fixtures/https/snitest.org.key"
|
||||||
|
|
||||||
[file]
|
[file]
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
# Reverse proxy port
|
defaultEntryPoints = ["http"]
|
||||||
#
|
|
||||||
# Optional
|
[entryPoints]
|
||||||
# Default: ":80"
|
[entryPoints.http]
|
||||||
#
|
address = ":8000"
|
||||||
# port = ":80"
|
|
||||||
port = ":8000"
|
|
||||||
#
|
|
||||||
# LogLevel
|
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
|
||||||
[marathon]
|
[marathon]
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
# Reverse proxy port
|
defaultEntryPoints = ["http"]
|
||||||
#
|
|
||||||
# Optional
|
[entryPoints]
|
||||||
# Default: ":80"
|
[entryPoints.http]
|
||||||
#
|
address = ":8000"
|
||||||
port = ":8000"
|
|
||||||
#
|
|
||||||
# LogLevel
|
|
||||||
logLevel = "DEBUG"
|
|
|
@ -1,6 +1,9 @@
|
||||||
port = ":8000"
|
|
||||||
logLevel = "DEBUG"
|
logLevel = "DEBUG"
|
||||||
|
defaultEntryPoints = ["http"]
|
||||||
|
|
||||||
|
[entryPoints]
|
||||||
|
[entryPoints.http]
|
||||||
|
address = ":8000"
|
||||||
|
|
||||||
[web]
|
[web]
|
||||||
|
|
||||||
address = ":8080"
|
address = ":8080"
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"fmt"
|
||||||
checker "github.com/vdemeester/shakers"
|
checker "github.com/vdemeester/shakers"
|
||||||
check "gopkg.in/check.v1"
|
check "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
@ -19,7 +20,8 @@ func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
|
||||||
// TODO validate : run on 80
|
// TODO validate : run on 80
|
||||||
resp, err := http.Get("http://127.0.0.1:8000/")
|
resp, err := http.Get("http://127.0.0.1:8000/")
|
||||||
|
|
||||||
// Expected a 404 as we did not configure anything
|
// Expected no response as we did not configure anything
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(resp, checker.IsNil)
|
||||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
c.Assert(err, checker.NotNil)
|
||||||
|
c.Assert(err.Error(), checker.Contains, fmt.Sprintf("getsockopt: connection refused"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -683,6 +683,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
||||||
expectedFrontends: map[string]*types.Frontend{
|
expectedFrontends: map[string]*types.Frontend{
|
||||||
`"frontend-Host-test-docker-localhost"`: {
|
`"frontend-Host-test-docker-localhost"`: {
|
||||||
Backend: "backend-test",
|
Backend: "backend-test",
|
||||||
|
EntryPoints: []string{},
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
`"route-frontend-Host-test-docker-localhost"`: {
|
`"route-frontend-Host-test-docker-localhost"`: {
|
||||||
Rule: "Host",
|
Rule: "Host",
|
||||||
|
@ -710,6 +711,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
||||||
Config: &docker.Config{
|
Config: &docker.Config{
|
||||||
Labels: map[string]string{
|
Labels: map[string]string{
|
||||||
"traefik.backend": "foobar",
|
"traefik.backend": "foobar",
|
||||||
|
"traefik.frontend.entryPoints": "http,https",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
NetworkSettings: &docker.NetworkSettings{
|
NetworkSettings: &docker.NetworkSettings{
|
||||||
|
@ -737,6 +739,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
||||||
expectedFrontends: map[string]*types.Frontend{
|
expectedFrontends: map[string]*types.Frontend{
|
||||||
`"frontend-Host-test1-docker-localhost"`: {
|
`"frontend-Host-test1-docker-localhost"`: {
|
||||||
Backend: "backend-foobar",
|
Backend: "backend-foobar",
|
||||||
|
EntryPoints: []string{"http", "https"},
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
`"route-frontend-Host-test1-docker-localhost"`: {
|
`"route-frontend-Host-test1-docker-localhost"`: {
|
||||||
Rule: "Host",
|
Rule: "Host",
|
||||||
|
@ -746,6 +749,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
`"frontend-Host-test2-docker-localhost"`: {
|
`"frontend-Host-test2-docker-localhost"`: {
|
||||||
Backend: "backend-foobar",
|
Backend: "backend-foobar",
|
||||||
|
EntryPoints: []string{},
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
`"route-frontend-Host-test2-docker-localhost"`: {
|
`"route-frontend-Host-test2-docker-localhost"`: {
|
||||||
Rule: "Host",
|
Rule: "Host",
|
||||||
|
|
|
@ -176,7 +176,7 @@ func TestKvGet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
actual := c.provider.get(c.keys...)
|
actual := c.provider.get("", c.keys...)
|
||||||
if actual != c.expected {
|
if actual != c.expected {
|
||||||
t.Fatalf("expected %v, got %v for %v and %v", c.expected, actual, c.keys, c.provider)
|
t.Fatalf("expected %v, got %v for %v and %v", c.expected, actual, c.keys, c.provider)
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ func TestKvGet(t *testing.T) {
|
||||||
Error: true,
|
Error: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
actual := provider.get("anything")
|
actual := provider.get("", "anything")
|
||||||
if actual != "" {
|
if actual != "" {
|
||||||
t.Fatalf("Should have return nil, got %v", actual)
|
t.Fatalf("Should have return nil, got %v", actual)
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ func TestMarathonLoadConfig(t *testing.T) {
|
||||||
expectedFrontends: map[string]*types.Frontend{
|
expectedFrontends: map[string]*types.Frontend{
|
||||||
`frontend-test`: {
|
`frontend-test`: {
|
||||||
Backend: "backend-test",
|
Backend: "backend-test",
|
||||||
|
EntryPoints: []string{},
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
`route-host-test`: {
|
`route-host-test`: {
|
||||||
Rule: "Host",
|
Rule: "Host",
|
||||||
|
@ -735,6 +736,36 @@ func TestMarathonGetPassHostHeader(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMarathonGetEntryPoints(t *testing.T) {
|
||||||
|
provider := &Marathon{}
|
||||||
|
|
||||||
|
applications := []struct {
|
||||||
|
application marathon.Application
|
||||||
|
expected []string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
application: marathon.Application{},
|
||||||
|
expected: []string{},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
application: marathon.Application{
|
||||||
|
Labels: map[string]string{
|
||||||
|
"traefik.frontend.entryPoints": "http,https",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expected: []string{"http", "https"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, a := range applications {
|
||||||
|
actual := provider.getEntryPoints(a.application)
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(actual, a.expected) {
|
||||||
|
t.Fatalf("expected %#v, got %#v", a.expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMarathonGetFrontendValue(t *testing.T) {
|
func TestMarathonGetFrontendValue(t *testing.T) {
|
||||||
provider := &Marathon{
|
provider := &Marathon{
|
||||||
Domain: "docker.localhost",
|
Domain: "docker.localhost",
|
||||||
|
|
Loading…
Reference in a new issue