diff --git a/gitaly_test.go b/gitaly_test.go index 323c705c4cac2555f8e875c3fae983b1498113cf..13ee1711c2f91df8aacf66d7712231be624abedf 100644 --- a/gitaly_test.go +++ b/gitaly_test.go @@ -31,8 +31,9 @@ func TestFailedCloneNoGitaly(t *testing.T) { require.NoError(t, os.RemoveAll(scratchDir)) authBody := &api.Response{ - GL_ID: "user-123", - RepoPath: repoPath(t), + GL_ID: "user-123", + GL_USERNAME: "username", + RepoPath: repoPath(t), // This will create a failure to connect to Gitaly GitalyServer: gitaly.Server{Address: "unix:/nonexistent"}, } @@ -132,6 +133,7 @@ func TestPostReceivePackProxiedToGitalySuccessfully(t *testing.T) { apiResponse.Repository.StorageName, apiResponse.Repository.RelativePath, apiResponse.GL_ID, + apiResponse.GL_USERNAME, string(testhelper.GitalyReceivePackResponseMock), }, "\000") diff --git a/internal/git/receive-pack.go b/internal/git/receive-pack.go index 41957f427b5a5b240131b6452d3ad8a4eddd1736..aa84c76de4bffba41707a9609a273e72db920727 100644 --- a/internal/git/receive-pack.go +++ b/internal/git/receive-pack.go @@ -52,7 +52,7 @@ func handleReceivePackWithGitaly(ctx context.Context, a *api.Response, clientReq return fmt.Errorf("smarthttp.ReceivePack: %v", err) } - if err := smarthttp.ReceivePack(ctx, &a.Repository, a.GL_ID, a.GL_REPOSITORY, clientRequest, clientResponse); err != nil { + if err := smarthttp.ReceivePack(ctx, &a.Repository, a.GL_ID, a.GL_USERNAME, a.GL_REPOSITORY, clientRequest, clientResponse); err != nil { return fmt.Errorf("smarthttp.ReceivePack: %v", err) } diff --git a/internal/gitaly/smarthttp.go b/internal/gitaly/smarthttp.go index dcd063fd43461de303b257c60e2a1f669a94bcb9..d549b2f27812f2d3dcb5ad02b08ce5af89cf60df 100644 --- a/internal/gitaly/smarthttp.go +++ b/internal/gitaly/smarthttp.go @@ -39,7 +39,7 @@ func infoRefsReader(stream infoRefsClient) io.Reader { }) } -func (client *SmartHTTPClient) ReceivePack(ctx context.Context, repo *pb.Repository, glId string, glRepository string, clientRequest io.Reader, clientResponse io.Writer) error { +func (client *SmartHTTPClient) ReceivePack(ctx context.Context, repo *pb.Repository, glId string, glUsername string, glRepository string, clientRequest io.Reader, clientResponse io.Writer) error { stream, err := client.PostReceivePack(ctx) if err != nil { return err @@ -48,6 +48,7 @@ func (client *SmartHTTPClient) ReceivePack(ctx context.Context, repo *pb.Reposit rpcRequest := &pb.PostReceivePackRequest{ Repository: repo, GlId: glId, + GlUsername: glUsername, GlRepository: glRepository, } diff --git a/internal/testhelper/gitaly.go b/internal/testhelper/gitaly.go index f0c2bc9136a2156f5cdbadee99e299349d88d9d2..1093fa0dfebb62a80070602a160d0e78985b8928 100644 --- a/internal/testhelper/gitaly.go +++ b/internal/testhelper/gitaly.go @@ -99,6 +99,7 @@ func (s *GitalyTestServer) PostReceivePack(stream pb.SmartHTTPService_PostReceiv repo.GetStorageName(), repo.GetRelativePath(), req.GlId, + req.GlUsername, }, "\000") + "\000") // The body of the request starts in the second message diff --git a/main_test.go b/main_test.go index 53e5141ca37876641ca1acd528109e3d0b30bbc6..4ea648f9bd0cb803ce8fd9b18bdf14f53b2531b8 100644 --- a/main_test.go +++ b/main_test.go @@ -722,8 +722,9 @@ func runOrFail(t *testing.T, cmd *exec.Cmd) { func gitOkBody(t *testing.T) *api.Response { repoPath := repoPath(t) return &api.Response{ - GL_ID: "user-123", - RepoPath: repoPath, + GL_ID: "user-123", + GL_USERNAME: "username", + RepoPath: repoPath, Repository: pb.Repository{ StorageName: "default", RelativePath: "foo/bar.git",