Commit 7e6fdf11 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Remove default roundtripper fallback

parent 4d86b01f
......@@ -8,6 +8,7 @@ import (
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
......@@ -27,7 +28,7 @@ func runPreAuthorizeHandler(t *testing.T, suffix string, url *regexp.Regexp, api
if err != nil {
t.Fatal(err)
}
a := api.NewAPI(helper.URLMustParse(ts.URL), "123", nil)
a := api.NewAPI(helper.URLMustParse(ts.URL), "123", badgateway.TestRoundTripper)
response := httptest.NewRecorder()
a.PreAuthorizeHandler(okHandler, suffix).ServeHTTP(response, httpRequest)
......
......@@ -20,9 +20,6 @@ type API struct {
}
func NewAPI(myURL *url.URL, version string, roundTripper *badgateway.RoundTripper) *API {
if roundTripper == nil {
roundTripper = badgateway.NewRoundTripper("", 0)
}
return &API{
Client: &http.Client{Transport: roundTripper},
URL: myURL,
......
......@@ -15,6 +15,7 @@ import (
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
......@@ -90,8 +91,8 @@ func testUploadArtifacts(contentType string, body io.Reader, t *testing.T, ts *h
}
httpRequest.Header.Set("Content-Type", contentType)
response := httptest.NewRecorder()
apiClient := api.NewAPI(helper.URLMustParse(ts.URL), "123", nil)
proxyClient := proxy.NewProxy(helper.URLMustParse(ts.URL), "123", nil)
apiClient := api.NewAPI(helper.URLMustParse(ts.URL), "123", badgateway.TestRoundTripper)
proxyClient := proxy.NewProxy(helper.URLMustParse(ts.URL), "123", badgateway.TestRoundTripper)
UploadArtifacts(apiClient, proxyClient).ServeHTTP(response, httpRequest)
return response
}
......
......@@ -23,6 +23,8 @@ var DefaultTransport = &http.Transport{
TLSHandshakeTimeout: 10 * time.Second, // from http.DefaultTransport
}
var TestRoundTripper = NewRoundTripper("", 0)
type RoundTripper struct {
Transport *http.Transport
}
......
......@@ -21,11 +21,7 @@ func NewProxy(myURL *url.URL, version string, roundTripper *badgateway.RoundTrip
u := *myURL // Make a copy of p.URL
u.Path = ""
p.reverseProxy = httputil.NewSingleHostReverseProxy(&u)
if roundTripper != nil {
p.reverseProxy.Transport = roundTripper
} else {
p.reverseProxy.Transport = badgateway.NewRoundTripper("", 0)
}
p.reverseProxy.Transport = roundTripper
return &p
}
......
......@@ -14,6 +14,7 @@ import (
"strings"
"testing"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/badgateway"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/proxy"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
......@@ -75,7 +76,7 @@ func TestUploadHandlerForwardingRawData(t *testing.T) {
response := httptest.NewRecorder()
handler := proxy.NewProxy(helper.URLMustParse(ts.URL), "123", nil)
handler := proxy.NewProxy(helper.URLMustParse(ts.URL), "123", badgateway.TestRoundTripper)
HandleFileUploads(response, httpRequest, handler, tempPath, nil)
testhelper.AssertResponseCode(t, response, 202)
if response.Body.String() != "RESPONSE" {
......@@ -149,7 +150,7 @@ func TestUploadHandlerRewritingMultiPartData(t *testing.T) {
httpRequest.Header.Set("Content-Type", writer.FormDataContentType())
response := httptest.NewRecorder()
handler := proxy.NewProxy(helper.URLMustParse(ts.URL), "123", nil)
handler := proxy.NewProxy(helper.URLMustParse(ts.URL), "123", badgateway.TestRoundTripper)
HandleFileUploads(response, httpRequest, handler, tempPath, &testFormProcessor{})
testhelper.AssertResponseCode(t, response, 202)
......
......@@ -21,6 +21,9 @@ import (
const testVersion = "123"
func newProxy(url string, rt *badgateway.RoundTripper) *proxy.Proxy {
if rt == nil {
rt = badgateway.TestRoundTripper
}
return proxy.NewProxy(helper.URLMustParse(url), testVersion, rt)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment