diff --git a/workhorse/cmd/gitlab-workhorse/gitaly_integration_test.go b/workhorse/cmd/gitlab-workhorse/gitaly_integration_test.go index 9e0f11b0df347aea200beafb03cb6a609ebe2e11..8d27376d10a222554215b31639870051cec4d848 100644 --- a/workhorse/cmd/gitlab-workhorse/gitaly_integration_test.go +++ b/workhorse/cmd/gitlab-workhorse/gitaly_integration_test.go @@ -174,32 +174,31 @@ func TestAllowedShallowClone(t *testing.T) { } } -// Disabled because of the broken master -// func TestAllowedPush(t *testing.T) { -// skipUnlessRealGitaly(t) - -// for _, gitalyAddress := range gitalyAddresses { -// t.Run(gitalyAddress, func(t *testing.T) { -// // Create the repository in the Gitaly server -// apiResponse := realGitalyOkBody(t, gitalyAddress) -// require.NoError(t, ensureGitalyRepository(t, apiResponse)) - -// // Prepare the test server and backend -// ts := testAuthServer(t, nil, nil, 200, apiResponse) -// ws := startWorkhorseServer(t, ts.URL) - -// // Do the git clone -// tmpDir := t.TempDir() -// cloneCmd := exec.Command("git", "clone", fmt.Sprintf("%s/%s", ws.URL, testRepo), tmpDir) -// runOrFail(t, cloneCmd) - -// // Perform the git push -// pushCmd := exec.Command("git", "push", fmt.Sprintf("%s/%s", ws.URL, testRepo), fmt.Sprintf("master:%s", newBranch())) -// pushCmd.Dir = tmpDir -// runOrFail(t, pushCmd) -// }) -// } -// } +func TestAllowedPush(t *testing.T) { + skipUnlessRealGitaly(t) + + for _, gitalyAddress := range gitalyAddresses { + t.Run(gitalyAddress, func(t *testing.T) { + // Create the repository in the Gitaly server + apiResponse := realGitalyOkBody(t, gitalyAddress) + require.NoError(t, ensureGitalyRepository(t, apiResponse)) + + // Prepare the test server and backend + ts := testAuthServer(t, nil, nil, 200, apiResponse) + ws := startWorkhorseServer(t, ts.URL) + + // Do the git clone + tmpDir := t.TempDir() + cloneCmd := exec.Command("git", "clone", fmt.Sprintf("%s/%s", ws.URL, testRepo), tmpDir) + runOrFail(t, cloneCmd) + + // Perform the git push + pushCmd := exec.Command("git", "push", fmt.Sprintf("%s/%s", ws.URL, testRepo), fmt.Sprintf("master:%s", newBranch())) + pushCmd.Dir = tmpDir + runOrFail(t, pushCmd) + }) + } +} func TestAllowedGetGitBlob(t *testing.T) { skipUnlessRealGitaly(t) diff --git a/workhorse/cmd/gitlab-workhorse/main_test.go b/workhorse/cmd/gitlab-workhorse/main_test.go index 5a1bc8ad9a60a2a47d475d163113a39acbe81437..9d11d00bd7be3d64db463d00bf189fdc5febed3f 100644 --- a/workhorse/cmd/gitlab-workhorse/main_test.go +++ b/workhorse/cmd/gitlab-workhorse/main_test.go @@ -795,6 +795,10 @@ func gitOkBody(t *testing.T) *api.Response { Repository: gitalypb.Repository{ StorageName: "default", RelativePath: "foo/bar.git", + // Gitaly requires a GlRepository to be set in requests that invoke the hooks. + // Set a placeholder to pass the validation. The value doesn't actually matter + // as the calls into Rails' internal API are disabled in tests. + GlRepository: "placeholder-1", }, } }