Commit 4704ce33 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Test for presence of Gitlab-Workhorse headers

parent 504bd633
...@@ -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" {
......
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