From b618ed7150ce84e7a9811b4304fe665650e49729 Mon Sep 17 00:00:00 2001 From: Ian Roberts Date: Thu, 21 Sep 2023 14:55:05 +0100 Subject: [PATCH] Test for a file:/// upstream combined with regex path rewrite --- pkg/upstream/proxy_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/upstream/proxy_test.go b/pkg/upstream/proxy_test.go index b685eae0..516d1a83 100644 --- a/pkg/upstream/proxy_test.go +++ b/pkg/upstream/proxy_test.go @@ -51,6 +51,12 @@ var _ = Describe("Proxy Suite", func() { Path: "/files/", URI: fmt.Sprintf("file:///%s", filesDir), }, + { + ID: "rewrite-file-backend", + Path: "^/rewrite-files/.*/(.*)$", + RewriteTarget: "/$1", + URI: fmt.Sprintf("file:///%s", filesDir), + }, { ID: "static-backend", Path: "/static/", @@ -174,6 +180,17 @@ var _ = Describe("Proxy Suite", func() { }, upstream: "file-backend", }), + Entry("with a request to the File backend with rewrite", &proxyTableInput{ + target: "http://example.localhost/rewrite-files/anything-at-all/foo", + response: testHTTPResponse{ + code: 200, + header: map[string][]string{ + contentType: {textPlainUTF8}, + }, + raw: "foo", + }, + upstream: "rewrite-file-backend", + }), Entry("with a request to the Static backend", &proxyTableInput{ target: "http://example.localhost/static/bar", response: testHTTPResponse{