From 9cf40354085f4b4446f06d4d03926dcaa6ab9565 Mon Sep 17 00:00:00 2001 From: Tuomo Ala-Vannesluoma Date: Fri, 6 Apr 2018 18:23:58 +0300 Subject: Add support for private projects and authentication with GitLab API --- helpers_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'helpers_test.go') diff --git a/helpers_test.go b/helpers_test.go index ccbbb6e3..1de79a35 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -248,11 +248,18 @@ func getPagesDaemonArgs(t *testing.T) []string { // 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 @@ -279,11 +286,18 @@ func DoPagesRequest(t *testing.T, req *http.Request) (*http.Response, error) { } func GetRedirectPage(t *testing.T, spec ListenSpec, host, urlsuffix string) (*http.Response, error) { + return GetRedirectPageWithCookie(t, spec, host, urlsuffix, "") +} + +func GetRedirectPageWithCookie(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 -- cgit v1.2.3