Add configoption to exclude routes from tls upgrading (#2203)
* Add configoption to exclude routes from tls upgrading * Add tests for IsLocationInLocationList * Seperate elements in NoTLSRedirectLocations by comma * Set NoTLSRedirectLocations to "/.well-known/acme-challenge/" by default * Remove trailing slash from "/.well-known/acme-challenge" default
This commit is contained in:
parent
977cfcb4c7
commit
94deb3a01a
5 changed files with 60 additions and 1 deletions
|
|
@ -645,3 +645,26 @@ func TestBuildAuthSignURL(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsLocationInLocationList(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
location *ingress.Location
|
||||
rawLocationList string
|
||||
expected bool
|
||||
}{
|
||||
{&ingress.Location{Path: "/match"}, "/match", true},
|
||||
{&ingress.Location{Path: "/match"}, ",/match", true},
|
||||
{&ingress.Location{Path: "/match"}, "/dontmatch", false},
|
||||
{&ingress.Location{Path: "/match"}, ",/dontmatch", false},
|
||||
{&ingress.Location{Path: "/match"}, "/dontmatch,/match", true},
|
||||
{&ingress.Location{Path: "/match"}, "/dontmatch,/dontmatcheither", false},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
result := isLocationInLocationList(testCase.location, testCase.rawLocationList)
|
||||
if result != testCase.expected {
|
||||
t.Errorf(" expected %v but return %v, path: '%s', rawLocation: '%s'", testCase.expected, result, testCase.location.Path, testCase.rawLocationList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue