Redirection: permanent move option.

This commit is contained in:
Ludovic Fernandez 2018-01-31 19:10:04 +01:00 committed by Traefiker
parent c944d203fb
commit 58d6681824
83 changed files with 622 additions and 8611 deletions

View file

@ -64,6 +64,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
label.TraefikFrontendRedirectEntryPoint: "https",
label.TraefikFrontendRedirectRegex: "nope",
label.TraefikFrontendRedirectReplacement: "nope",
label.TraefikFrontendRedirectPermanent: "true",
label.TraefikFrontendRule: "Host:traefik.io",
label.TraefikFrontendWhitelistSourceRange: "10.10.10.10",
@ -199,6 +200,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
EntryPoint: "https",
Regex: "",
Replacement: "",
Permanent: true,
},
},
},
@ -1041,6 +1043,21 @@ func TestGetRedirect(t *testing.T) {
EntryPoint: "https",
},
},
{
desc: "should return a struct when entry point redirect label (permanent)",
service: rancherData{
Labels: map[string]string{
label.TraefikFrontendRedirectEntryPoint: "https",
label.TraefikFrontendRedirectPermanent: "true",
},
Health: "healthy",
State: "active",
},
expected: &types.Redirect{
EntryPoint: "https",
Permanent: true,
},
},
{
desc: "should return a struct when regex redirect labels",
service: rancherData{
@ -1056,6 +1073,23 @@ func TestGetRedirect(t *testing.T) {
Replacement: "$1",
},
},
{
desc: "should return a struct when regex redirect labels (permanent)",
service: rancherData{
Labels: map[string]string{
label.TraefikFrontendRedirectRegex: "(.*)",
label.TraefikFrontendRedirectReplacement: "$1",
label.TraefikFrontendRedirectPermanent: "true",
},
Health: "healthy",
State: "active",
},
expected: &types.Redirect{
Regex: "(.*)",
Replacement: "$1",
Permanent: true,
},
},
}
for _, test := range testCases {