feat(kv): add more tests.
This commit is contained in:
parent
944008661f
commit
b9f1f7752d
2 changed files with 157 additions and 9 deletions
|
@ -121,6 +121,26 @@ func TestFiller(t *testing.T) {
|
||||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/weight", Value: []byte("0")},
|
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/weight", Value: []byte("0")},
|
||||||
{Key: "traefik/frontends/frontend.with.dot", Value: []byte("")},
|
{Key: "traefik/frontends/frontend.with.dot", Value: []byte("")},
|
||||||
{Key: "traefik/frontends/frontend.with.dot/backend", Value: []byte("backend.with.dot.too")},
|
{Key: "traefik/frontends/frontend.with.dot/backend", Value: []byte("backend.with.dot.too")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors", Value: []byte("")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/bar", Value: []byte("")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/bar/backend", Value: []byte("error")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/bar/query", Value: []byte("/test2")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/bar/status", Value: []byte("400-405")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/foo", Value: []byte("")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/foo/backend", Value: []byte("error")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/foo/query", Value: []byte("/test1")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/errors/foo/status", Value: []byte("500-501, 503-599")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit", Value: []byte("")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/extractorfunc", Value: []byte("client.ip")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset", Value: []byte("")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/bar", Value: []byte("")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/bar/average", Value: []byte("3")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/bar/burst", Value: []byte("6")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/bar/period", Value: []byte("9")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/foo", Value: []byte("")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/foo/average", Value: []byte("6")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/foo/burst", Value: []byte("12")},
|
||||||
|
{Key: "traefik/frontends/frontend.with.dot/ratelimit/rateset/foo/period", Value: []byte("18")},
|
||||||
{Key: "traefik/frontends/frontend.with.dot/routes", Value: []byte("")},
|
{Key: "traefik/frontends/frontend.with.dot/routes", Value: []byte("")},
|
||||||
{Key: "traefik/frontends/frontend.with.dot/routes/route.with.dot", Value: []byte("")},
|
{Key: "traefik/frontends/frontend.with.dot/routes/route.with.dot", Value: []byte("")},
|
||||||
{Key: "traefik/frontends/frontend.with.dot/routes/route.with.dot/rule", Value: []byte("Host:test.localhost")},
|
{Key: "traefik/frontends/frontend.with.dot/routes/route.with.dot/rule", Value: []byte("Host:test.localhost")},
|
||||||
|
@ -129,7 +149,12 @@ func TestFiller(t *testing.T) {
|
||||||
pairs1 := filler("traefik",
|
pairs1 := filler("traefik",
|
||||||
frontend("frontend.with.dot",
|
frontend("frontend.with.dot",
|
||||||
withPair("backend", "backend.with.dot.too"),
|
withPair("backend", "backend.with.dot.too"),
|
||||||
withPair("routes/route.with.dot/rule", "Host:test.localhost")),
|
withPair("routes/route.with.dot/rule", "Host:test.localhost"),
|
||||||
|
withErrorPage("foo", "error", "/test1", "500-501, 503-599"),
|
||||||
|
withErrorPage("bar", "error", "/test2", "400-405"),
|
||||||
|
withRateLimit("client.ip",
|
||||||
|
withLimit("foo", "6", "12", "18"),
|
||||||
|
withLimit("bar", "3", "6", "9"))),
|
||||||
backend("backend.with.dot.too",
|
backend("backend.with.dot.too",
|
||||||
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
|
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
|
||||||
withPair("servers/server.with.dot/weight", "0"),
|
withPair("servers/server.with.dot/weight", "0"),
|
||||||
|
@ -140,7 +165,20 @@ func TestFiller(t *testing.T) {
|
||||||
pairs2 := filler("traefik",
|
pairs2 := filler("traefik",
|
||||||
entry("frontends/frontend.with.dot",
|
entry("frontends/frontend.with.dot",
|
||||||
withPair("backend", "backend.with.dot.too"),
|
withPair("backend", "backend.with.dot.too"),
|
||||||
withPair("routes/route.with.dot/rule", "Host:test.localhost")),
|
withPair("routes/route.with.dot/rule", "Host:test.localhost"),
|
||||||
|
withPair("errors/foo/backend", "error"),
|
||||||
|
withPair("errors/foo/query", "/test1"),
|
||||||
|
withPair("errors/foo/status", "500-501, 503-599"),
|
||||||
|
withPair("errors/bar/backend", "error"),
|
||||||
|
withPair("errors/bar/query", "/test2"),
|
||||||
|
withPair("errors/bar/status", "400-405"),
|
||||||
|
withPair("ratelimit/extractorfunc", "client.ip"),
|
||||||
|
withPair("ratelimit/rateset/foo/average", "6"),
|
||||||
|
withPair("ratelimit/rateset/foo/burst", "12"),
|
||||||
|
withPair("ratelimit/rateset/foo/period", "18"),
|
||||||
|
withPair("ratelimit/rateset/bar/average", "3"),
|
||||||
|
withPair("ratelimit/rateset/bar/burst", "6"),
|
||||||
|
withPair("ratelimit/rateset/bar/period", "9")),
|
||||||
entry("backends/backend.with.dot.too",
|
entry("backends/backend.with.dot.too",
|
||||||
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
|
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
|
||||||
withPair("servers/server.with.dot/weight", "0"),
|
withPair("servers/server.with.dot/weight", "0"),
|
||||||
|
|
|
@ -4,7 +4,9 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/containous/flaeg"
|
||||||
"github.com/containous/traefik/provider/label"
|
"github.com/containous/traefik/provider/label"
|
||||||
"github.com/containous/traefik/tls"
|
"github.com/containous/traefik/tls"
|
||||||
"github.com/containous/traefik/types"
|
"github.com/containous/traefik/types"
|
||||||
|
@ -46,9 +48,11 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
Frontends: map[string]*types.Frontend{
|
Frontends: map[string]*types.Frontend{
|
||||||
"frontend.with.dot": {
|
"frontend.with.dot": {
|
||||||
Backend: "backend.with.dot.too",
|
Backend: "backend.with.dot.too",
|
||||||
PassHostHeader: true,
|
PassHostHeader: true,
|
||||||
EntryPoints: []string{},
|
EntryPoints: []string{},
|
||||||
|
WhitelistSourceRange: []string{},
|
||||||
|
BasicAuth: []string{},
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"route.with.dot": {
|
"route.with.dot": {
|
||||||
Rule: "Host:test.localhost",
|
Rule: "Host:test.localhost",
|
||||||
|
@ -79,7 +83,46 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
withPair(pathFrontendBackend, "backend1"),
|
withPair(pathFrontendBackend, "backend1"),
|
||||||
withPair(pathFrontendPriority, "6"),
|
withPair(pathFrontendPriority, "6"),
|
||||||
withPair(pathFrontendPassHostHeader, "false"),
|
withPair(pathFrontendPassHostHeader, "false"),
|
||||||
|
withPair(pathFrontendPassTLSCert, "true"),
|
||||||
withPair(pathFrontendEntryPoints, "http,https"),
|
withPair(pathFrontendEntryPoints, "http,https"),
|
||||||
|
withPair(pathFrontendWhiteListSourceRange, "1.1.1.1/24, 1234:abcd::42/32"),
|
||||||
|
withPair(pathFrontendBasicAuth, "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/, test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"),
|
||||||
|
withPair(pathFrontendRedirectEntryPoint, "https"),
|
||||||
|
withPair(pathFrontendRedirectRegex, "nope"),
|
||||||
|
withPair(pathFrontendRedirectReplacement, "nope"),
|
||||||
|
withErrorPage("foo", "error", "/test1", "500-501, 503-599"),
|
||||||
|
withErrorPage("bar", "error", "/test2", "400-405"),
|
||||||
|
withRateLimit("client.ip",
|
||||||
|
withLimit("foo", "6", "12", "18"),
|
||||||
|
withLimit("bar", "3", "6", "9")),
|
||||||
|
|
||||||
|
withPair(pathFrontendCustomRequestHeaders+"Access-Control-Allow-Methods", "POST,GET,OPTIONS"),
|
||||||
|
withPair(pathFrontendCustomRequestHeaders+"Content-Type", "application/json; charset=utf-8"),
|
||||||
|
withPair(pathFrontendCustomRequestHeaders+"X-Custom-Header", "test"),
|
||||||
|
withPair(pathFrontendCustomResponseHeaders+"Access-Control-Allow-Methods", "POST,GET,OPTIONS"),
|
||||||
|
withPair(pathFrontendCustomResponseHeaders+"Content-Type", "application/json; charset=utf-8"),
|
||||||
|
withPair(pathFrontendCustomResponseHeaders+"X-Custom-Header", "test"),
|
||||||
|
withPair(pathFrontendSSLProxyHeaders+"Access-Control-Allow-Methods", "POST,GET,OPTIONS"),
|
||||||
|
withPair(pathFrontendSSLProxyHeaders+"Content-Type", "application/json; charset=utf-8"),
|
||||||
|
withPair(pathFrontendSSLProxyHeaders+"X-Custom-Header", "test"),
|
||||||
|
withPair(pathFrontendAllowedHosts, "example.com, ssl.example.com"),
|
||||||
|
withPair(pathFrontendHostsProxyHeaders, "foo, bar, goo, hor"),
|
||||||
|
withPair(pathFrontendSTSSeconds, "666"),
|
||||||
|
withPair(pathFrontendSSLHost, "foo"),
|
||||||
|
withPair(pathFrontendCustomFrameOptionsValue, "foo"),
|
||||||
|
withPair(pathFrontendContentSecurityPolicy, "foo"),
|
||||||
|
withPair(pathFrontendPublicKey, "foo"),
|
||||||
|
withPair(pathFrontendReferrerPolicy, "foo"),
|
||||||
|
withPair(pathFrontendSSLRedirect, "true"),
|
||||||
|
withPair(pathFrontendSSLTemporaryRedirect, "true"),
|
||||||
|
withPair(pathFrontendSTSIncludeSubdomains, "true"),
|
||||||
|
withPair(pathFrontendSTSPreload, "true"),
|
||||||
|
withPair(pathFrontendForceSTSHeader, "true"),
|
||||||
|
withPair(pathFrontendFrameDeny, "true"),
|
||||||
|
withPair(pathFrontendContentTypeNosniff, "true"),
|
||||||
|
withPair(pathFrontendBrowserXSSFilter, "true"),
|
||||||
|
withPair(pathFrontendIsDevelopment, "true"),
|
||||||
|
|
||||||
withPair("routes/route1/rule", "Host:test.localhost"),
|
withPair("routes/route1/rule", "Host:test.localhost"),
|
||||||
withPair("routes/route2/rule", "Path:/foo")),
|
withPair("routes/route2/rule", "Path:/foo")),
|
||||||
entry("tlsconfiguration/foo",
|
entry("tlsconfiguration/foo",
|
||||||
|
@ -116,16 +159,49 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
},
|
},
|
||||||
HealthCheck: &types.HealthCheck{
|
HealthCheck: &types.HealthCheck{
|
||||||
Path: "/health",
|
Path: "/health",
|
||||||
Port: 0,
|
Port: 80,
|
||||||
Interval: "30s",
|
Interval: "30s",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Frontends: map[string]*types.Frontend{
|
Frontends: map[string]*types.Frontend{
|
||||||
"frontend1": {
|
"frontend1": {
|
||||||
Priority: 6,
|
Priority: 6,
|
||||||
EntryPoints: []string{"http", "https"},
|
EntryPoints: []string{"http", "https"},
|
||||||
Backend: "backend1",
|
Backend: "backend1",
|
||||||
|
PassTLSCert: true,
|
||||||
|
WhitelistSourceRange: []string{"1.1.1.1/24", "1234:abcd::42/32"},
|
||||||
|
BasicAuth: []string{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"},
|
||||||
|
Redirect: &types.Redirect{
|
||||||
|
EntryPoint: "https",
|
||||||
|
},
|
||||||
|
Errors: map[string]*types.ErrorPage{
|
||||||
|
"foo": {
|
||||||
|
Backend: "error",
|
||||||
|
Query: "/test1",
|
||||||
|
Status: []string{"500-501", "503-599"},
|
||||||
|
},
|
||||||
|
"bar": {
|
||||||
|
Backend: "error",
|
||||||
|
Query: "/test2",
|
||||||
|
Status: []string{"400-405"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RateLimit: &types.RateLimit{
|
||||||
|
ExtractorFunc: "client.ip",
|
||||||
|
RateSet: map[string]*types.Rate{
|
||||||
|
"foo": {
|
||||||
|
Average: 6,
|
||||||
|
Burst: 12,
|
||||||
|
Period: flaeg.Duration(18 * time.Second),
|
||||||
|
},
|
||||||
|
"bar": {
|
||||||
|
Average: 3,
|
||||||
|
Burst: 6,
|
||||||
|
Period: flaeg.Duration(9 * time.Second),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
Routes: map[string]types.Route{
|
Routes: map[string]types.Route{
|
||||||
"route1": {
|
"route1": {
|
||||||
Rule: "Host:test.localhost",
|
Rule: "Host:test.localhost",
|
||||||
|
@ -134,6 +210,40 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
||||||
Rule: "Path:/foo",
|
Rule: "Path:/foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Headers: &types.Headers{
|
||||||
|
CustomRequestHeaders: map[string]string{
|
||||||
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
"X-Custom-Header": "test",
|
||||||
|
},
|
||||||
|
CustomResponseHeaders: map[string]string{
|
||||||
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
"X-Custom-Header": "test",
|
||||||
|
},
|
||||||
|
SSLProxyHeaders: map[string]string{
|
||||||
|
"Access-Control-Allow-Methods": "POST,GET,OPTIONS",
|
||||||
|
"Content-Type": "application/json; charset=utf-8",
|
||||||
|
"X-Custom-Header": "test",
|
||||||
|
},
|
||||||
|
AllowedHosts: []string{"example.com", "ssl.example.com"},
|
||||||
|
HostsProxyHeaders: []string{"foo", "bar", "goo", "hor"},
|
||||||
|
STSSeconds: 666,
|
||||||
|
SSLHost: "foo",
|
||||||
|
CustomFrameOptionsValue: "foo",
|
||||||
|
ContentSecurityPolicy: "foo",
|
||||||
|
PublicKey: "foo",
|
||||||
|
ReferrerPolicy: "foo",
|
||||||
|
SSLRedirect: true,
|
||||||
|
SSLTemporaryRedirect: true,
|
||||||
|
STSIncludeSubdomains: true,
|
||||||
|
STSPreload: true,
|
||||||
|
ForceSTSHeader: true,
|
||||||
|
FrameDeny: true,
|
||||||
|
ContentTypeNosniff: true,
|
||||||
|
BrowserXSSFilter: true,
|
||||||
|
IsDevelopment: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
TLSConfiguration: []*tls.Configuration{
|
TLSConfiguration: []*tls.Configuration{
|
||||||
|
|
Loading…
Reference in a new issue