diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/acceptance/auth_test.go | 8 | ||||
-rw-r--r-- | test/acceptance/encodings_test.go | 5 | ||||
-rw-r--r-- | test/acceptance/helpers_test.go | 42 | ||||
-rw-r--r-- | test/acceptance/serving_test.go | 6 |
4 files changed, 16 insertions, 45 deletions
diff --git a/test/acceptance/auth_test.go b/test/acceptance/auth_test.go index 3c616f7c..c3155400 100644 --- a/test/acceptance/auth_test.go +++ b/test/acceptance/auth_test.go @@ -94,9 +94,13 @@ func TestWhenLoginCallbackWithUnencryptedCode(t *testing.T) { url, err := url.Parse(rsp.Header.Get("Location")) require.NoError(t, err) + header := http.Header{ + "Cookie": []string{cookie}, + } + // Go to auth page with correct state will cause fetching the token - authrsp, err := GetPageFromListenerWithCookie(t, httpsListener, "projects.gitlab-example.com", "/auth?code=1&state="+ - url.Query().Get("state"), cookie) + authrsp, err := GetPageFromListenerWithHeaders(t, httpsListener, "projects.gitlab-example.com", "/auth?code=1&state="+ + url.Query().Get("state"), header) require.NoError(t, err) defer authrsp.Body.Close() diff --git a/test/acceptance/encodings_test.go b/test/acceptance/encodings_test.go index 096107dd..18f2c492 100644 --- a/test/acceptance/encodings_test.go +++ b/test/acceptance/encodings_test.go @@ -64,7 +64,10 @@ func TestCompressedEncoding(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - rsp, err := GetCompressedPageFromListener(t, httpListener, "group.gitlab-example.com", "index.html", tt.encoding) + header := http.Header{ + "Accept-Encoding": []string{tt.encoding}, + } + rsp, err := GetPageFromListenerWithHeaders(t, httpListener, "group.gitlab-example.com", "index.html", header) require.NoError(t, err) defer rsp.Body.Close() diff --git a/test/acceptance/helpers_test.go b/test/acceptance/helpers_test.go index 4abbe33d..caa4ec3b 100644 --- a/test/acceptance/helpers_test.go +++ b/test/acceptance/helpers_test.go @@ -369,34 +369,7 @@ func contains(slice []string, s string) bool { // Does a HTTP(S) GET against the listener specified, setting a fake // Host: and constructing the URL from the listener and the URL suffix. func GetPageFromListener(t *testing.T, spec ListenSpec, host, urlsuffix string) (*http.Response, error) { - return GetPageFromListenerWithCookie(t, spec, host, urlsuffix, "") -} - -func GetPageFromListenerWithCookie(t *testing.T, spec ListenSpec, host, urlsuffix string, cookie string) (*http.Response, error) { - url := spec.URL(urlsuffix) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, err - } - if cookie != "" { - req.Header.Set("Cookie", cookie) - } - - req.Host = host - - return DoPagesRequest(t, spec, req) -} - -func GetCompressedPageFromListener(t *testing.T, spec ListenSpec, host, urlsuffix string, encoding string) (*http.Response, error) { - url := spec.URL(urlsuffix) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, err - } - req.Host = host - req.Header.Set("Accept-Encoding", encoding) - - return DoPagesRequest(t, spec, req) + return GetPageFromListenerWithHeaders(t, spec, host, urlsuffix, http.Header{}) } func GetPageFromListenerWithHeaders(t *testing.T, spec ListenSpec, host, urlSuffix string, header http.Header) (*http.Response, error) { @@ -414,19 +387,6 @@ func GetPageFromListenerWithHeaders(t *testing.T, spec ListenSpec, host, urlSuff return DoPagesRequest(t, spec, req) } -func GetProxiedPageFromListener(t *testing.T, spec ListenSpec, host, xForwardedHost, urlsuffix string) (*http.Response, error) { - url := spec.URL(urlsuffix) - req, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, err - } - - req.Host = host - req.Header.Set("X-Forwarded-Host", xForwardedHost) - - return DoPagesRequest(t, spec, req) -} - func DoPagesRequest(t *testing.T, spec ListenSpec, req *http.Request) (*http.Response, error) { t.Logf("curl -X %s -H'Host: %s' %s", req.Method, req.Host, req.URL) diff --git a/test/acceptance/serving_test.go b/test/acceptance/serving_test.go index c6a7d3ef..c79894f4 100644 --- a/test/acceptance/serving_test.go +++ b/test/acceptance/serving_test.go @@ -342,7 +342,11 @@ func TestKnownHostInReverseProxySetupReturns200(t *testing.T) { withListeners([]ListenSpec{proxyListener}), ) - rsp, err := GetProxiedPageFromListener(t, proxyListener, "127.0.0.1", "group.gitlab-example.com", "project/") + header := http.Header{ + "X-Forwarded-Host": []string{"group.gitlab-example.com"}, + } + + rsp, err := GetPageFromListenerWithHeaders(t, proxyListener, "127.0.0.1", "project/", header) require.NoError(t, err) rsp.Body.Close() |