git.iko.soy/typeable/oauth2-proxy
on master help sign in
Fix conversion of file upstreams
commitbd619ab63e19c402449c44f705aee0ca2189e913 authorJoel Speed <joel.speed@hotmail.co.uk> dateMon 31 Aug 2020, 14:05 (6 years ago) parentb40517b
2 files changed+7−4
pkg/apis/options/legacy_options.go+3 pkg/apis/options/legacy_options_test.go+4−4
pkg/apis/options/legacy_options.go+3
@@ -4,6 +4,7 @@ import (
44 "fmt"
55 "net/url"
66 "strconv"
7+ "strings"
78 "time"
89
910 "github.com/oauth2-proxy/oauth2-proxy/pkg/logger"
@@ -87,6 +88,8 @@ func (l *LegacyUpstreams) convert() (Upstreams, error) {
8788 if u.Fragment != "" {
8889 upstream.ID = u.Fragment
8990 upstream.Path = u.Fragment
91+ // Trim the fragment from the end of the URI
92+ upstream.URI = strings.SplitN(upstreamString, "#", 2)[0]
9093 }
9194 case "static":
9295 responseCode, err := strconv.Atoi(u.Host)
pkg/apis/options/legacy_options_test.go+4−4
@@ -21,7 +21,7 @@ var _ = Describe("Legacy Options", func() {
2121 legacyOpts.LegacyUpstreams.PassHostHeader = true
2222 legacyOpts.LegacyUpstreams.ProxyWebSockets = true
2323 legacyOpts.LegacyUpstreams.SSLUpstreamInsecureSkipVerify = true
24− legacyOpts.LegacyUpstreams.Upstreams = []string{"http://foo.bar/baz", "file://var/lib/website#/bar", "static://204"}
24+ legacyOpts.LegacyUpstreams.Upstreams = []string{"http://foo.bar/baz", "file:///var/lib/website#/bar", "static://204"}
2525
2626 truth := true
2727 staticCode := 204
@@ -38,7 +38,7 @@ var _ = Describe("Legacy Options", func() {
3838 {
3939 ID: "/bar",
4040 Path: "/bar",
41− URI: "file://var/lib/website#/bar",
41+ URI: "file:///var/lib/website",
4242 FlushInterval: &flushInterval,
4343 InsecureSkipTLSVerify: true,
4444 PassHostHeader: &truth,
@@ -100,11 +100,11 @@ var _ = Describe("Legacy Options", func() {
100100 FlushInterval: &flushInterval,
101101 }
102102
103− validFileWithFragment := "file://var/lib/website#/bar"
103+ validFileWithFragment := "file:///var/lib/website#/bar"
104104 validFileWithFragmentUpstream := Upstream{
105105 ID: "/bar",
106106 Path: "/bar",
107− URI: validFileWithFragment,
107+ URI: "file:///var/lib/website",
108108 InsecureSkipTLSVerify: skipVerify,
109109 PassHostHeader: &passHostHeader,
110110 ProxyWebSockets: &proxyWebSockets,