diff options
author | Stan Hu <stanhu@gmail.com> | 2017-03-11 02:21:21 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2017-03-13 13:42:29 +0300 |
commit | de395b2806024af3846c93b3f10c9dc9416cd83d (patch) | |
tree | 56a4f2154dbda3314548f2101bbc47c1984bd56b /helpers_test.go | |
parent | fbcbce1277c57783568c2a2d828c0022d675932c (diff) |
Fix and clarify redirect HTTP logic
redirect-http seemed to suggest the Pages daemon would redirect from HTTPS to
HTTP, but it seems that the opposite was implied.
Fixes issue manifested by https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/1348
Diffstat (limited to 'helpers_test.go')
-rw-r--r-- | helpers_test.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/helpers_test.go b/helpers_test.go index 99a44ea1..60d04304 100644 --- a/helpers_test.go +++ b/helpers_test.go @@ -136,11 +136,11 @@ func (l ListenSpec) JoinHostPort() string { // GetPageFromProcess to do a HTTP GET against a listener. // // If run as root via sudo, the gitlab-pages process will drop privileges -func RunPagesProcess(t *testing.T, pagesPath string, listeners []ListenSpec, promPort string) (teardown func()) { +func RunPagesProcess(t *testing.T, pagesPath string, listeners []ListenSpec, promPort string, extraArgs ...string) (teardown func()) { _, err := os.Stat(pagesPath) assert.NoError(t, err) - args, tempfiles := getPagesArgs(t, listeners, promPort) + args, tempfiles := getPagesArgs(t, listeners, promPort, extraArgs) cmd := exec.Command(pagesPath, args...) cmd.Stdout = &tWriter{t} cmd.Stderr = &tWriter{t} @@ -168,7 +168,7 @@ func RunPagesProcess(t *testing.T, pagesPath string, listeners []ListenSpec, pro } } -func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string) (args, tempfiles []string) { +func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string, extraArgs []string) (args, tempfiles []string) { var hasHTTPS bool for _, spec := range listeners { @@ -196,6 +196,8 @@ func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string) (args, args = append(args, "-daemon-gid", "65534") // Root user can switch to "nobody" } + args = append(args, extraArgs...) + return } @@ -214,3 +216,15 @@ func GetPageFromListener(t *testing.T, spec ListenSpec, host, urlsuffix string) return InsecureHTTPSClient.Do(req) } + +func GetRedirectPage(t *testing.T, spec ListenSpec, host, 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 + + return InsecureHTTPSClient.Transport.RoundTrip(req) +} |