projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
adds missing fix for llfuse 0.42+
[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 e24679f579b3ebd47777c206753ba98ffb94ba4e..6b08eeecdc303a246cba91873fd5c44a4ddddb4a 100644
(file)
--- a/
services/arv-git-httpd/git_handler_test.go
+++ b/
services/arv-git-httpd/git_handler_test.go
@@
-4,7
+4,6
@@
import (
"net/http"
"net/http/httptest"
"net/url"
"net/http"
"net/http/httptest"
"net/url"
- "os"
"regexp"
check "gopkg.in/check.v1"
"regexp"
check "gopkg.in/check.v1"
@@
-12,42
+11,45
@@
import (
var _ = check.Suite(&GitHandlerSuite{})
var _ = check.Suite(&GitHandlerSuite{})
-type GitHandlerSuite struct
{}
+type GitHandlerSuite struct{}
func (s *GitHandlerSuite) TestEnvVars(c *check.C) {
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()
req := &http.Request{
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,
+ Method:
"GET",
+ URL:
u,
RemoteAddr: "[::1]:12345",
}
h := newGitHandler()
h.(*gitHandler).Path = "/bin/sh"
RemoteAddr: "[::1]:12345",
}
h := newGitHandler()
h.(*gitHandler).Path = "/bin/sh"
- h.(*gitHandler).Args = []string{"-c", "echo HTTP/1.1 200 OK; echo Content-Type: text/plain; echo; env"}
- os.Setenv("GITOLITE_HTTP_HOME", "/test/ghh")
- os.Setenv("GL_BYPASS_ACCESS_CHECKS", "yesplease")
+ h.(*gitHandler).Args = []string{"-c", "printf 'Content-Type: text/plain\r\n\r\n'; env"}
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) {
+func (s *GitHandlerSuite) TestCGIError
OnSplitHostPortError
(c *check.C) {
u, err := url.Parse("git.zzzzz.arvadosapi.com/test")
c.Check(err, check.Equals, nil)
resp := httptest.NewRecorder()
req := &http.Request{
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
",
+ Method:
"GET",
+ URL:
u,
+ RemoteAddr: "
test.bad.address.missing.port
",
}
h := newGitHandler()
h.ServeHTTP(resp, req)
}
h := newGitHandler()
h.ServeHTTP(resp, req)