git.iko.soy/typeable/oauth2-proxy
on master help sign in
Test for a file:/// upstream combined with regex path rewrite
b618ed7Ian Roberts
pkg/upstream/proxy_test.go+17
@@ -51,6 +51,12 @@ var _ = Describe("Proxy Suite", func() {
51 Path: "/files/",
51 Path: "/files/",
52 URI: fmt.Sprintf("file:///%s", filesDir),
52 URI: fmt.Sprintf("file:///%s", filesDir),
53 },
53 },
54+ {
55+ ID: "rewrite-file-backend",
56+ Path: "^/rewrite-files/.*/(.*)$",
57+ RewriteTarget: "/$1",
58+ URI: fmt.Sprintf("file:///%s", filesDir),
59+ },
54 {
60 {
55 ID: "static-backend",
61 ID: "static-backend",
56 Path: "/static/",
62 Path: "/static/",
@@ -174,6 +180,17 @@ var _ = Describe("Proxy Suite", func() {
174 },
180 },
175 upstream: "file-backend",
181 upstream: "file-backend",
176 }),
182 }),
183+ Entry("with a request to the File backend with rewrite", &proxyTableInput{
184+ target: "http://example.localhost/rewrite-files/anything-at-all/foo",
185+ response: testHTTPResponse{
186+ code: 200,
187+ header: map[string][]string{
188+ contentType: {textPlainUTF8},
189+ },
190+ raw: "foo",
191+ },
192+ upstream: "rewrite-file-backend",
193+ }),
177 Entry("with a request to the Static backend", &proxyTableInput{
194 Entry("with a request to the Static backend", &proxyTableInput{
178 target: "http://example.localhost/static/bar",
195 target: "http://example.localhost/static/bar",
179 response: testHTTPResponse{
196 response: testHTTPResponse{