proxy: preserve path and query string for http->https redirect (#1456)

This commit is contained in:
Caleb Doxsey 2020-09-24 15:12:56 -06:00 committed by GitHub
parent 83415ee52f
commit 29b2fa4e60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -130,16 +130,17 @@ func waitSig(t *testing.T, c <-chan os.Signal, sig os.Signal) {
func TestRedirectHandler(t *testing.T) {
tests := []struct {
name string
url string
wantStatus int
wantBody string
}{
{"http://example", http.StatusMovedPermanently, "<a href=\"https://example\">Moved Permanently</a>.\n\n"},
{"http://example:8080", http.StatusMovedPermanently, "<a href=\"https://example\">Moved Permanently</a>.\n\n"},
{"http://example:8080/some/path?x=y", http.StatusMovedPermanently, "<a href=\"https://example/some/path?x=y\">Moved Permanently</a>.\n\n"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, "http://example/", nil)
t.Run(tt.url, func(t *testing.T) {
req := httptest.NewRequest(http.MethodGet, tt.url, nil)
rr := httptest.NewRecorder()
RedirectHandler().ServeHTTP(rr, req)
if diff := cmp.Diff(tt.wantStatus, rr.Code); diff != "" {