Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
7e6fdf11
Commit
7e6fdf11
authored
Aug 11, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove default roundtripper fallback
parent
4d86b01f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
14 additions
and
13 deletions
+14
-13
authorization_test.go
authorization_test.go
+2
-1
internal/api/api.go
internal/api/api.go
+0
-3
internal/artifacts/artifacts_upload_test.go
internal/artifacts/artifacts_upload_test.go
+3
-2
internal/badgateway/roundtripper.go
internal/badgateway/roundtripper.go
+2
-0
internal/proxy/proxy.go
internal/proxy/proxy.go
+1
-5
internal/upload/uploads_test.go
internal/upload/uploads_test.go
+3
-2
proxy_test.go
proxy_test.go
+3
-0
No files found.
authorization_test.go
View file @
7e6fdf11
...
...
@@ -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
)
...
...
internal/api/api.go
View file @
7e6fdf11
...
...
@@ -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
,
...
...
internal/artifacts/artifacts_upload_test.go
View file @
7e6fdf11
...
...
@@ -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
}
...
...
internal/badgateway/roundtripper.go
View file @
7e6fdf11
...
...
@@ -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
}
...
...
internal/proxy/proxy.go
View file @
7e6fdf11
...
...
@@ -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
}
...
...
internal/upload/uploads_test.go
View file @
7e6fdf11
...
...
@@ -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
)
...
...
proxy_test.go
View file @
7e6fdf11
...
...
@@ -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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment