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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
4704ce33
Commit
4704ce33
authored
May 25, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test for presence of Gitlab-Workhorse headers
parent
504bd633
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
proxy_test.go
proxy_test.go
+12
-1
No files found.
proxy_test.go
View file @
4704ce33
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
"regexp"
"regexp"
"strings"
"testing"
"testing"
"time"
"time"
...
@@ -17,8 +18,10 @@ import (
...
@@ -17,8 +18,10 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/testhelper"
)
)
const
testVersion
=
"123"
func
newProxy
(
url
string
,
rt
*
badgateway
.
RoundTripper
)
*
proxy
.
Proxy
{
func
newProxy
(
url
string
,
rt
*
badgateway
.
RoundTripper
)
*
proxy
.
Proxy
{
return
proxy
.
NewProxy
(
helper
.
URLMustParse
(
url
),
"123"
,
rt
)
return
proxy
.
NewProxy
(
helper
.
URLMustParse
(
url
),
testVersion
,
rt
)
}
}
func
TestProxyRequest
(
t
*
testing
.
T
)
{
func
TestProxyRequest
(
t
*
testing
.
T
)
{
...
@@ -31,6 +34,14 @@ func TestProxyRequest(t *testing.T) {
...
@@ -31,6 +34,14 @@ func TestProxyRequest(t *testing.T) {
t
.
Fatal
(
"Missing custom header"
)
t
.
Fatal
(
"Missing custom header"
)
}
}
if
h
:=
r
.
Header
.
Get
(
"Gitlab-Workhorse"
);
h
!=
testVersion
{
t
.
Fatalf
(
"Missing GitLab-Workhorse header: want %q, got %q"
,
testVersion
,
h
)
}
if
h
:=
r
.
Header
.
Get
(
"Gitlab-Worhorse-Proxy-Start"
);
!
strings
.
HasPrefix
(
h
,
"1"
)
{
t
.
Fatalf
(
"Expect Gitlab-Worhorse-Proxy-Start to start with 1, got %q"
,
h
)
}
var
body
bytes
.
Buffer
var
body
bytes
.
Buffer
io
.
Copy
(
&
body
,
r
.
Body
)
io
.
Copy
(
&
body
,
r
.
Body
)
if
body
.
String
()
!=
"REQUEST"
{
if
body
.
String
()
!=
"REQUEST"
{
...
...
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