Commit 3ea22ec1 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-workhorse into refactor-upstream

parents 06cad3f5 64270207
......@@ -2,6 +2,10 @@
Formerly known as 'gitlab-git-http-server'.
0.5.4
Fix /api/v3/projects routing bug introduced in 0.5.2-0.5.3.
0.5.3
Fixes merge error in 0.5.2.
......
......@@ -2,7 +2,7 @@ PREFIX=/usr/local
VERSION=$(shell git describe)-$(shell date -u +%Y%m%d.%H%M%S)
gitlab-workhorse: $(wildcard *.go)
go build -ldflags "-X main.Version ${VERSION}" -o gitlab-workhorse
go build -ldflags "-X main.Version=${VERSION}" -o gitlab-workhorse
install: gitlab-workhorse
install gitlab-workhorse ${PREFIX}/bin/
......
......@@ -53,6 +53,9 @@ gitlab-workhorse -authBackend http://localhost:8080/gitlab
## Installation
To install gitlab-workhorse you need [Go 1.5 or
newer](https://golang.org/dl).
To install into `/usr/local/bin` run `make install`.
```
......
......@@ -23,7 +23,7 @@ const gitProjectPattern = `^/[^/]+/[^/]+\.git/`
const apiPattern = `^/api/`
// A project ID in an API request is either a number or two strings 'namespace/project'
const projectsAPIPattern = `^/api/v3/projects/(\d+)|([^/]+/[^/]+)/`
const projectsAPIPattern = `^/api/v3/projects/((\d+)|([^/]+/[^/]+))/`
const ciAPIPattern = `^/ci/api/`
// Routing table
......
......@@ -276,6 +276,37 @@ func TestDownloadCacheCreate(t *testing.T) {
}
}
func TestRegularProjectsAPI(t *testing.T) {
apiResponse := "API RESPONSE"
ts := testAuthServer(nil, 200, apiResponse)
defer ts.Close()
ws := startWorkhorseServer(ts.URL)
defer ws.Close()
for _, resource := range []string{
"/api/v3/projects/123/repository/not/special",
"/api/v3/projects/foo%2Fbar/repository/not/special",
"/api/v3/projects/123/not/special",
"/api/v3/projects/foo%2Fbar/not/special",
} {
resp, err := http.Get(ws.URL + resource)
if err != nil {
t.Fatal(err)
}
defer resp.Body.Close()
buf := &bytes.Buffer{}
if _, err := io.Copy(buf, resp.Body); err != nil {
t.Error(err)
}
if buf.String() != apiResponse {
t.Errorf("GET %q: Expected %q, got %q", resource, apiResponse, buf.String())
}
if resp.StatusCode != 200 {
t.Errorf("GET %q: expected 200, got %d", resource, resp.StatusCode)
}
}
}
func TestAllowedXSendfileDownload(t *testing.T) {
contentFilename := "my-content"
prepareDownloadDir(t)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment