diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-21 18:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-21 18:08:36 +0300 |
commit | 81884c35b86035f89364db482e4fff91718bb63a (patch) | |
tree | 49090a57dd0e6e49390f593bf24ee49dd8fb7b7f /workhorse/internal | |
parent | 6f3692902c2e5dc690593b8c44f77b86b5c28904 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'workhorse/internal')
-rw-r--r-- | workhorse/internal/git/info-refs.go | 5 | ||||
-rw-r--r-- | workhorse/internal/git/info-refs_test.go | 33 | ||||
-rw-r--r-- | workhorse/internal/upstream/routes.go | 24 |
3 files changed, 12 insertions, 50 deletions
diff --git a/workhorse/internal/git/info-refs.go b/workhorse/internal/git/info-refs.go index 6d0826a22f9..e5491a7b733 100644 --- a/workhorse/internal/git/info-refs.go +++ b/workhorse/internal/git/info-refs.go @@ -20,11 +20,6 @@ func GetInfoRefsHandler(a *api.API) http.Handler { return repoPreAuthorizeHandler(a, handleGetInfoRefs) } -func IsSmartInfoRefs(r *http.Request) bool { - service := r.URL.Query().Get("service") - return r.Method == "GET" && (service == "git-upload-pack" || service == "git-receive-pack") -} - func handleGetInfoRefs(rw http.ResponseWriter, r *http.Request, a *api.Response) { responseWriter := NewHttpResponseWriter(rw) // Log 0 bytes in because we ignore the request body (and there usually is none anyway). diff --git a/workhorse/internal/git/info-refs_test.go b/workhorse/internal/git/info-refs_test.go deleted file mode 100644 index ed66518b8d3..00000000000 --- a/workhorse/internal/git/info-refs_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package git - -import ( - "net/http" - "net/url" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestIsSmartInfoRefs(t *testing.T) { - testCases := []struct { - method string - url string - match bool - }{ - {"GET", "?service=git-upload-pack", true}, - {"GET", "?service=git-receive-pack", true}, - {"GET", "", false}, - {"GET", "?service=", false}, - {"GET", "?service=foo", false}, - {"POST", "?service=git-upload-pack", false}, - {"POST", "?service=git-receive-pack", false}, - } - - for _, tc := range testCases { - url, err := url.Parse(tc.url) - require.NoError(t, err) - - r := http.Request{Method: tc.method, URL: url} - require.Equal(t, tc.match, IsSmartInfoRefs(&r)) - } -} diff --git a/workhorse/internal/upstream/routes.go b/workhorse/internal/upstream/routes.go index b8a97a1b5f6..22c75c2904f 100644 --- a/workhorse/internal/upstream/routes.go +++ b/workhorse/internal/upstream/routes.go @@ -53,13 +53,13 @@ type uploadPreparers struct { } const ( - apiPattern = `\A/api/` - ciAPIPattern = `\A/ci/api/` - gitRepositoryPattern = `\A/.+\.git/` - projectPattern = `\A/([^/]+/){1,}[^/]+/` - snippetUploadPattern = `\A/uploads/personal_snippet` - userUploadPattern = `\A/uploads/user` - importPattern = `\A/import/` + apiPattern = `^/api/` + ciAPIPattern = `^/ci/api/` + gitProjectPattern = `^/([^/]+/){1,}[^/]+\.git/` + projectPattern = `^/([^/]+/){1,}[^/]+/` + snippetUploadPattern = `^/uploads/personal_snippet` + userUploadPattern = `^/uploads/user` + importPattern = `^/import/` ) func compileRegexp(regexpStr string) *regexp.Regexp { @@ -222,10 +222,10 @@ func (u *upstream) configureRoutes() { u.Routes = []routeEntry{ // Git Clone - u.route("GET", gitRepositoryPattern+`info/refs\z`, git.GetInfoRefsHandler(api), withMatcher(git.IsSmartInfoRefs)), - u.route("POST", gitRepositoryPattern+`git-upload-pack\z`, contentEncodingHandler(git.UploadPack(api)), withMatcher(isContentType("application/x-git-upload-pack-request"))), - u.route("POST", gitRepositoryPattern+`git-receive-pack\z`, contentEncodingHandler(git.ReceivePack(api)), withMatcher(isContentType("application/x-git-receive-pack-request"))), - u.route("PUT", gitRepositoryPattern+`gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`, lfs.PutStore(api, signingProxy, preparers.lfs), withMatcher(isContentType("application/octet-stream"))), + u.route("GET", gitProjectPattern+`info/refs\z`, git.GetInfoRefsHandler(api)), + u.route("POST", gitProjectPattern+`git-upload-pack\z`, contentEncodingHandler(git.UploadPack(api)), withMatcher(isContentType("application/x-git-upload-pack-request"))), + u.route("POST", gitProjectPattern+`git-receive-pack\z`, contentEncodingHandler(git.ReceivePack(api)), withMatcher(isContentType("application/x-git-receive-pack-request"))), + u.route("PUT", gitProjectPattern+`gitlab-lfs/objects/([0-9a-f]{64})/([0-9]+)\z`, lfs.PutStore(api, signingProxy, preparers.lfs), withMatcher(isContentType("application/octet-stream"))), // CI Artifacts u.route("POST", apiPattern+`v4/jobs/[0-9]+/artifacts\z`, contentEncodingHandler(artifacts.UploadArtifacts(api, signingProxy, preparers.artifacts))), @@ -262,7 +262,7 @@ func (u *upstream) configureRoutes() { u.route("POST", apiPattern+`v4/projects/[0-9]+/packages/pypi`, upload.Accelerate(api, signingProxy, preparers.packages)), // Debian Artifact Repository - u.route("PUT", apiPattern+`v4/projects/[0-9]+/-/packages/debian/incoming/`, upload.BodyUploader(api, signingProxy, preparers.packages)), + u.route("PUT", apiPattern+`v4/projects/[0-9]+/packages/debian/`, upload.BodyUploader(api, signingProxy, preparers.packages)), // We are porting API to disk acceleration // we need to declare each routes until we have fixed all the routes on the rails codebase. |