diff options
author | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-04-06 18:23:58 +0300 |
---|---|---|
committer | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-06-30 22:50:19 +0300 |
commit | 9cf40354085f4b4446f06d4d03926dcaa6ab9565 (patch) | |
tree | eb6ade3a82feec5f9b258417f41a8fecd3e9aec9 /helpers_test.go | |
parent | c4a419ed595281f62977fd47aa30d225c4eddb5d (diff) |
Add support for private projects and authentication with GitLab API
Diffstat (limited to 'helpers_test.go')
-rw-r--r-- | helpers_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
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 |