From ed934d468191bafed15e260d7861b94bd49bbe87 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer <jacob@gitlab.com> Date: Wed, 5 Apr 2017 16:57:38 +0200 Subject: [PATCH] Stop using GitalySocketPath --- internal/api/api.go | 8 ------ main_test.go | 59 ++++++++++++++++++--------------------------- 2 files changed, 23 insertions(+), 44 deletions(-) diff --git a/internal/api/api.go b/internal/api/api.go index 1f09b0c2f8375..dd26c74a5147a 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -89,8 +89,6 @@ type Response struct { Entry string `json:"entry"` // Used to communicate terminal session details Terminal *TerminalSettings - // Path to Gitaly Socket (deprecated in favor of GitalyAddress) - GitalySocketPath string // GitalyAddress is a unix:// or tcp:// address to reach a Gitaly service on GitalyAddress string // Repository object for making gRPC requests to Gitaly. This will @@ -222,12 +220,6 @@ func (api *API) PreAuthorize(suffix string, r *http.Request) (httpResponse *http authResponse.Repository.Path = authResponse.RepoPath } - if socketPath := authResponse.GitalySocketPath; socketPath != "" && authResponse.GitalyAddress == "" { - // We are transitioning away from the GitalySocketPath response field. - // Until all the new code is in place, keep backwards compatibility. - authResponse.GitalyAddress = "unix://" + socketPath - } - return httpResponse, authResponse, nil } diff --git a/main_test.go b/main_test.go index d3ea9375100b2..4154a6491a9b0 100644 --- a/main_test.go +++ b/main_test.go @@ -145,7 +145,7 @@ func TestFailedCloneNoGitaly(t *testing.T) { GL_ID: "user-123", RepoPath: repoPath(t), // This will create a failure to connect to Gitaly - GitalySocketPath: "/nonexistent", + GitalyAddress: "unix:/nonexistent", } // Prepare test server and backend @@ -603,43 +603,30 @@ func TestGetInfoRefsProxiedToGitalySuccessfully(t *testing.T) { defer gitalyServer.Stop() gitalyAddress := "unix://" + socketPath + apiResponse.GitalyAddress = gitalyAddress - addressCases := []struct { - socketPath string - address string - }{ - {socketPath: "/nonexistent,/should/be/ignored", address: gitalyAddress}, - {socketPath: socketPath}, - } - - for _, ac := range addressCases { - func() { - apiResponse.GitalySocketPath = ac.socketPath - apiResponse.GitalyAddress = ac.address - - ts := testAuthServer(nil, 200, apiResponse) - defer ts.Close() + ts := testAuthServer(nil, 200, apiResponse) + defer ts.Close() - ws := startWorkhorseServer(ts.URL) - defer ws.Close() + ws := startWorkhorseServer(ts.URL) + defer ws.Close() - resource := "/gitlab-org/gitlab-test.git/info/refs?service=git-upload-pack" - resp, err := http.Get(ws.URL + resource) - if err != nil { - t.Fatal(err) - } - defer resp.Body.Close() - responseBody, err := ioutil.ReadAll(resp.Body) - if err != nil { - t.Error(err) - } + resource := "/gitlab-org/gitlab-test.git/info/refs?service=git-upload-pack" + resp, err := http.Get(ws.URL + resource) + if err != nil { + t.Fatal(err) + } + defer resp.Body.Close() + responseBody, err := ioutil.ReadAll(resp.Body) + if err != nil { + t.Error(err) + } - expectedContent := testhelper.GitalyInfoRefsResponseMock - if !bytes.Equal(responseBody, []byte(expectedContent)) { - t.Errorf("GET %q: Expected %q, got %q", resource, expectedContent, responseBody) - } - }() + expectedContent := testhelper.GitalyInfoRefsResponseMock + if !bytes.Equal(responseBody, []byte(expectedContent)) { + t.Errorf("GET %q: Expected %q, got %q", resource, expectedContent, responseBody) } + } func TestPostReceivePackProxiedToGitalySuccessfully(t *testing.T) { @@ -733,7 +720,7 @@ func TestGetInfoRefsHandledLocallyDueToEmptyGitalySocketPath(t *testing.T) { defer gitalyServer.Stop() apiResponse := gitOkBody(t) - apiResponse.GitalySocketPath = "" + apiResponse.GitalyAddress = "" ts := testAuthServer(nil, 200, apiResponse) defer ts.Close() @@ -766,7 +753,7 @@ func TestPostReceivePackHandledLocallyDueToEmptyGitalySocketPath(t *testing.T) { defer gitalyServer.Stop() apiResponse := gitOkBody(t) - apiResponse.GitalySocketPath = "" + apiResponse.GitalyAddress = "" ts := testAuthServer(nil, 200, apiResponse) defer ts.Close() @@ -797,7 +784,7 @@ func TestPostUploadPackHandledLocallyDueToEmptyGitalySocketPath(t *testing.T) { defer gitalyServer.Stop() apiResponse := gitOkBody(t) - apiResponse.GitalySocketPath = "" + apiResponse.GitalyAddress = "" ts := testAuthServer(nil, 200, apiResponse) defer ts.Close() -- GitLab