Fix conversion of file upstreams
This commit is contained in:
parent
b40517bbe3
commit
bd619ab63e
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/oauth2-proxy/oauth2-proxy/pkg/logger"
|
"github.com/oauth2-proxy/oauth2-proxy/pkg/logger"
|
||||||
|
|
@ -87,6 +88,8 @@ func (l *LegacyUpstreams) convert() (Upstreams, error) {
|
||||||
if u.Fragment != "" {
|
if u.Fragment != "" {
|
||||||
upstream.ID = u.Fragment
|
upstream.ID = u.Fragment
|
||||||
upstream.Path = u.Fragment
|
upstream.Path = u.Fragment
|
||||||
|
// Trim the fragment from the end of the URI
|
||||||
|
upstream.URI = strings.SplitN(upstreamString, "#", 2)[0]
|
||||||
}
|
}
|
||||||
case "static":
|
case "static":
|
||||||
responseCode, err := strconv.Atoi(u.Host)
|
responseCode, err := strconv.Atoi(u.Host)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
legacyOpts.LegacyUpstreams.PassHostHeader = true
|
legacyOpts.LegacyUpstreams.PassHostHeader = true
|
||||||
legacyOpts.LegacyUpstreams.ProxyWebSockets = true
|
legacyOpts.LegacyUpstreams.ProxyWebSockets = true
|
||||||
legacyOpts.LegacyUpstreams.SSLUpstreamInsecureSkipVerify = true
|
legacyOpts.LegacyUpstreams.SSLUpstreamInsecureSkipVerify = true
|
||||||
legacyOpts.LegacyUpstreams.Upstreams = []string{"http://foo.bar/baz", "file://var/lib/website#/bar", "static://204"}
|
legacyOpts.LegacyUpstreams.Upstreams = []string{"http://foo.bar/baz", "file:///var/lib/website#/bar", "static://204"}
|
||||||
|
|
||||||
truth := true
|
truth := true
|
||||||
staticCode := 204
|
staticCode := 204
|
||||||
|
|
@ -38,7 +38,7 @@ var _ = Describe("Legacy Options", func() {
|
||||||
{
|
{
|
||||||
ID: "/bar",
|
ID: "/bar",
|
||||||
Path: "/bar",
|
Path: "/bar",
|
||||||
URI: "file://var/lib/website#/bar",
|
URI: "file:///var/lib/website",
|
||||||
FlushInterval: &flushInterval,
|
FlushInterval: &flushInterval,
|
||||||
InsecureSkipTLSVerify: true,
|
InsecureSkipTLSVerify: true,
|
||||||
PassHostHeader: &truth,
|
PassHostHeader: &truth,
|
||||||
|
|
@ -100,11 +100,11 @@ var _ = Describe("Legacy Options", func() {
|
||||||
FlushInterval: &flushInterval,
|
FlushInterval: &flushInterval,
|
||||||
}
|
}
|
||||||
|
|
||||||
validFileWithFragment := "file://var/lib/website#/bar"
|
validFileWithFragment := "file:///var/lib/website#/bar"
|
||||||
validFileWithFragmentUpstream := Upstream{
|
validFileWithFragmentUpstream := Upstream{
|
||||||
ID: "/bar",
|
ID: "/bar",
|
||||||
Path: "/bar",
|
Path: "/bar",
|
||||||
URI: validFileWithFragment,
|
URI: "file:///var/lib/website",
|
||||||
InsecureSkipTLSVerify: skipVerify,
|
InsecureSkipTLSVerify: skipVerify,
|
||||||
PassHostHeader: &passHostHeader,
|
PassHostHeader: &passHostHeader,
|
||||||
ProxyWebSockets: &proxyWebSockets,
|
ProxyWebSockets: &proxyWebSockets,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue