projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '12025-perm-cache-version'
[arvados.git]
/
services
/
arv-git-httpd
/
git_handler_test.go
diff --git
a/services/arv-git-httpd/git_handler_test.go
b/services/arv-git-httpd/git_handler_test.go
index 6a4b46f401bf57ef38b042ee538794f30b50c1c9..0cf7de4e22c229545bde64edaa03aa9dcb2612a6 100644
(file)
--- a/
services/arv-git-httpd/git_handler_test.go
+++ b/
services/arv-git-httpd/git_handler_test.go
@@
-1,10
+1,13
@@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
package main
import (
"net/http"
"net/http/httptest"
"net/url"
package main
import (
"net/http"
"net/http/httptest"
"net/url"
- "os"
"regexp"
check "gopkg.in/check.v1"
"regexp"
check "gopkg.in/check.v1"
@@
-15,6
+18,10
@@
var _ = check.Suite(&GitHandlerSuite{})
type GitHandlerSuite struct{}
func (s *GitHandlerSuite) TestEnvVars(c *check.C) {
type GitHandlerSuite struct{}
func (s *GitHandlerSuite) TestEnvVars(c *check.C) {
+ theConfig = defaultConfig()
+ theConfig.RepoRoot = "/"
+ theConfig.GitoliteHome = "/test/ghh"
+
u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
c.Check(err, check.Equals, nil)
resp := httptest.NewRecorder()
u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
c.Check(err, check.Equals, nil)
resp := httptest.NewRecorder()
@@
-26,29
+33,27
@@
func (s *GitHandlerSuite) TestEnvVars(c *check.C) {
h := newGitHandler()
h.(*gitHandler).Path = "/bin/sh"
h.(*gitHandler).Args = []string{"-c", "printf 'Content-Type: text/plain\r\n\r\n'; env"}
h := newGitHandler()
h.(*gitHandler).Path = "/bin/sh"
h.(*gitHandler).Args = []string{"-c", "printf 'Content-Type: text/plain\r\n\r\n'; env"}
- os.Setenv("GITOLITE_HTTP_HOME", "/test/ghh")
- os.Setenv("GL_BYPASS_ACCESS_CHECKS", "yesplease")
h.ServeHTTP(resp, req)
c.Check(resp.Code, check.Equals, http.StatusOK)
body := resp.Body.String()
h.ServeHTTP(resp, req)
c.Check(resp.Code, check.Equals, http.StatusOK)
body := resp.Body.String()
+ c.Check(body, check.Matches, `(?ms).*^PATH=.*:/test/ghh/bin$.*`)
c.Check(body, check.Matches, `(?ms).*^GITOLITE_HTTP_HOME=/test/ghh$.*`)
c.Check(body, check.Matches, `(?ms).*^GITOLITE_HTTP_HOME=/test/ghh$.*`)
- c.Check(body, check.Matches, `(?ms).*^GL_BYPASS_ACCESS_CHECKS=
yesplease
$.*`)
+ c.Check(body, check.Matches, `(?ms).*^GL_BYPASS_ACCESS_CHECKS=
1
$.*`)
c.Check(body, check.Matches, `(?ms).*^REMOTE_HOST=::1$.*`)
c.Check(body, check.Matches, `(?ms).*^REMOTE_PORT=12345$.*`)
c.Check(body, check.Matches, `(?ms).*^REMOTE_HOST=::1$.*`)
c.Check(body, check.Matches, `(?ms).*^REMOTE_PORT=12345$.*`)
- c.Check(body, check.Matches, `(?ms).*^SERVER_ADDR=`+regexp.QuoteMeta(theConfig.
Addr
)+`$.*`)
+ c.Check(body, check.Matches, `(?ms).*^SERVER_ADDR=`+regexp.QuoteMeta(theConfig.
Listen
)+`$.*`)
}
}
-func (s *GitHandlerSuite) TestCGIError(c *check.C) {
- log.Printf("git_handler_test: TestCGIError() - expecting a SplitHostPort error, so it is safe to ignore!")
+func (s *GitHandlerSuite) TestCGIErrorOnSplitHostPortError(c *check.C) {
u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
c.Check(err, check.Equals, nil)
resp := httptest.NewRecorder()
req := &http.Request{
Method: "GET",
URL: u,
u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
c.Check(err, check.Equals, nil)
resp := httptest.NewRecorder()
req := &http.Request{
Method: "GET",
URL: u,
- RemoteAddr: "
bogus", // intentionally invalid (will trigger SplitHostPort error below)
+ RemoteAddr: "
test.bad.address.missing.port",
}
h := newGitHandler()
h.ServeHTTP(resp, req)
}
h := newGitHandler()
h.ServeHTTP(resp, req)