Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-01-21 18:08:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-01-21 18:08:36 +0300
commit81884c35b86035f89364db482e4fff91718bb63a (patch)
tree49090a57dd0e6e49390f593bf24ee49dd8fb7b7f /workhorse/gitaly_test.go
parent6f3692902c2e5dc690593b8c44f77b86b5c28904 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'workhorse/gitaly_test.go')
-rw-r--r--workhorse/gitaly_test.go169
1 files changed, 0 insertions, 169 deletions
diff --git a/workhorse/gitaly_test.go b/workhorse/gitaly_test.go
index 3c3c957063c..95d6907ac6a 100644
--- a/workhorse/gitaly_test.go
+++ b/workhorse/gitaly_test.go
@@ -169,57 +169,6 @@ func TestGetInfoRefsProxiedToGitalyInterruptedStream(t *testing.T) {
waitDone(t, done)
}
-func TestGetInfoRefsRouting(t *testing.T) {
- gitalyServer, socketPath := startGitalyServer(t, codes.OK)
- defer gitalyServer.GracefulStop()
-
- apiResponse := gitOkBody(t)
- apiResponse.GitalyServer.Address = "unix:" + socketPath
- ts := testAuthServer(t, nil, nil, 200, apiResponse)
- defer ts.Close()
-
- ws := startWorkhorseServer(ts.URL)
- defer ws.Close()
-
- testCases := []struct {
- method string
- path string
- match bool
- }{
- {"GET", "/toplevel.git/info/refs?service=git-receive-pack", true},
- {"GET", "/toplevel.wiki.git/info/refs?service=git-upload-pack", true},
- {"GET", "/toplevel/child/project.git/info/refs?service=git-receive-pack", true},
- {"GET", "/toplevel/child/project.wiki.git/info/refs?service=git-upload-pack", true},
- {"GET", "/toplevel/child/project/snippets/123.git/info/refs?service=git-receive-pack", true},
- {"GET", "/snippets/123.git/info/refs?service=git-upload-pack", true},
- {"GET", "/foo/bar.git/info/refs", false},
- {"GET", "/foo/bar.git/info/refs?service=git-zzz-pack", false},
- {"GET", "/.git/info/refs?service=git-upload-pack", false},
- {"POST", "/toplevel.git/info/refs?service=git-receive-pack", false},
- }
-
- for _, tc := range testCases {
- t.Run(tc.path, func(t *testing.T) {
- req, err := http.NewRequest(tc.method, ws.URL+tc.path, nil)
- require.NoError(t, err)
-
- resp, err := http.DefaultClient.Do(req)
- require.NoError(t, err)
- defer resp.Body.Close()
-
- body := string(testhelper.ReadAll(t, resp.Body))
-
- if tc.match {
- require.Equal(t, 200, resp.StatusCode)
- require.Contains(t, body, "\x00", "expect response generated by test gitaly server")
- } else {
- require.Equal(t, 204, resp.StatusCode)
- require.Empty(t, body, "normal request has empty response body")
- }
- })
- }
-}
-
func waitDone(t *testing.T, done chan struct{}) {
t.Helper()
select {
@@ -310,65 +259,6 @@ func TestPostReceivePackProxiedToGitalyInterrupted(t *testing.T) {
waitDone(t, done)
}
-func TestPostReceivePackRouting(t *testing.T) {
- gitalyServer, socketPath := startGitalyServer(t, codes.OK)
- defer gitalyServer.GracefulStop()
-
- apiResponse := gitOkBody(t)
- apiResponse.GitalyServer.Address = "unix:" + socketPath
- ts := testAuthServer(t, nil, nil, 200, apiResponse)
- defer ts.Close()
-
- ws := startWorkhorseServer(ts.URL)
- defer ws.Close()
-
- testCases := []struct {
- method string
- path string
- contentType string
- match bool
- }{
- {"POST", "/toplevel.git/git-receive-pack", "application/x-git-receive-pack-request", true},
- {"POST", "/toplevel.wiki.git/git-receive-pack", "application/x-git-receive-pack-request", true},
- {"POST", "/toplevel/child/project.git/git-receive-pack", "application/x-git-receive-pack-request", true},
- {"POST", "/toplevel/child/project.wiki.git/git-receive-pack", "application/x-git-receive-pack-request", true},
- {"POST", "/toplevel/child/project/snippets/123.git/git-receive-pack", "application/x-git-receive-pack-request", true},
- {"POST", "/snippets/123.git/git-receive-pack", "application/x-git-receive-pack-request", true},
- {"POST", "/foo/bar/git-receive-pack", "application/x-git-receive-pack-request", false},
- {"POST", "/foo/bar.git/git-zzz-pack", "application/x-git-receive-pack-request", false},
- {"POST", "/.git/git-receive-pack", "application/x-git-receive-pack-request", false},
- {"POST", "/toplevel.git/git-receive-pack", "application/x-git-upload-pack-request", false},
- {"GET", "/toplevel.git/git-receive-pack", "application/x-git-receive-pack-request", false},
- }
-
- for _, tc := range testCases {
- t.Run(tc.path, func(t *testing.T) {
- req, err := http.NewRequest(
- tc.method,
- ws.URL+tc.path,
- bytes.NewReader(testhelper.GitalyReceivePackResponseMock),
- )
- require.NoError(t, err)
-
- req.Header.Set("Content-Type", tc.contentType)
-
- resp, err := http.DefaultClient.Do(req)
- require.NoError(t, err)
- defer resp.Body.Close()
-
- body := string(testhelper.ReadAll(t, resp.Body))
-
- if tc.match {
- require.Equal(t, 200, resp.StatusCode)
- require.Contains(t, body, "\x00", "expect response generated by test gitaly server")
- } else {
- require.Equal(t, 204, resp.StatusCode)
- require.Empty(t, body, "normal request has empty response body")
- }
- })
- }
-}
-
// ReaderFunc is an adapter to turn a conforming function into an io.Reader.
type ReaderFunc func(b []byte) (int, error)
@@ -486,65 +376,6 @@ func TestPostUploadPackProxiedToGitalyInterrupted(t *testing.T) {
waitDone(t, done)
}
-func TestPostUploadPackRouting(t *testing.T) {
- gitalyServer, socketPath := startGitalyServer(t, codes.OK)
- defer gitalyServer.GracefulStop()
-
- apiResponse := gitOkBody(t)
- apiResponse.GitalyServer.Address = "unix:" + socketPath
- ts := testAuthServer(t, nil, nil, 200, apiResponse)
- defer ts.Close()
-
- ws := startWorkhorseServer(ts.URL)
- defer ws.Close()
-
- testCases := []struct {
- method string
- path string
- contentType string
- match bool
- }{
- {"POST", "/toplevel.git/git-upload-pack", "application/x-git-upload-pack-request", true},
- {"POST", "/toplevel.wiki.git/git-upload-pack", "application/x-git-upload-pack-request", true},
- {"POST", "/toplevel/child/project.git/git-upload-pack", "application/x-git-upload-pack-request", true},
- {"POST", "/toplevel/child/project.wiki.git/git-upload-pack", "application/x-git-upload-pack-request", true},
- {"POST", "/toplevel/child/project/snippets/123.git/git-upload-pack", "application/x-git-upload-pack-request", true},
- {"POST", "/snippets/123.git/git-upload-pack", "application/x-git-upload-pack-request", true},
- {"POST", "/foo/bar/git-upload-pack", "application/x-git-upload-pack-request", false},
- {"POST", "/foo/bar.git/git-zzz-pack", "application/x-git-upload-pack-request", false},
- {"POST", "/.git/git-upload-pack", "application/x-git-upload-pack-request", false},
- {"POST", "/toplevel.git/git-upload-pack", "application/x-git-receive-pack-request", false},
- {"GET", "/toplevel.git/git-upload-pack", "application/x-git-upload-pack-request", false},
- }
-
- for _, tc := range testCases {
- t.Run(tc.path, func(t *testing.T) {
- req, err := http.NewRequest(
- tc.method,
- ws.URL+tc.path,
- bytes.NewReader(testhelper.GitalyReceivePackResponseMock),
- )
- require.NoError(t, err)
-
- req.Header.Set("Content-Type", tc.contentType)
-
- resp, err := http.DefaultClient.Do(req)
- require.NoError(t, err)
- defer resp.Body.Close()
-
- body := string(testhelper.ReadAll(t, resp.Body))
-
- if tc.match {
- require.Equal(t, 200, resp.StatusCode)
- require.Contains(t, body, "\x00", "expect response generated by test gitaly server")
- } else {
- require.Equal(t, 204, resp.StatusCode)
- require.Empty(t, body, "normal request has empty response body")
- }
- })
- }
-}
-
func TestGetDiffProxiedToGitalySuccessfully(t *testing.T) {
gitalyServer, socketPath := startGitalyServer(t, codes.OK)
defer gitalyServer.GracefulStop()