As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit c13b1f48 authored by Vasilii Iakliushin's avatar Vasilii Iakliushin
Browse files

Pass Git-Protocol to the request

parent 54deaab0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/command/commandargs"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/gitlabnet/accessverifier"
Loading
Loading
@@ -20,6 +21,7 @@ var uploadPackHttpPrefix = []byte("001e# service=git-upload-pack\n0000")
type PullCommand struct {
Config *config.Config
ReadWriter *readwriter.ReadWriter
Args *commandargs.Shell
Response *accessverifier.Response
}
Loading
Loading
@@ -39,6 +41,8 @@ func (c *PullCommand) Execute(ctx context.Context) error {
// For Git over SSH routing
if data.GeoProxyFetchSSHDirectToPrimary {
client.Headers["Git-Protocol"] = c.Args.Env.GitProtocolVersion
return c.requestSSHUploadPack(ctx, client)
}
Loading
Loading
Loading
Loading
@@ -11,9 +11,11 @@ import (
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/gitlab-shell/v14/client/testserver"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/command/commandargs"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/gitlabnet/accessverifier"
"gitlab.com/gitlab-org/gitlab-shell/v14/internal/sshenv"
)
var cloneResponse = `0090want 11d731b83788cd556abea7b465c6bee52d89923c multi_ack_detailed side-band-64k thin-pack ofs-delta deepen-since deepen-not agent=git/2.41.0
Loading
Loading
@@ -69,10 +71,18 @@ func TestPullExecuteWithSSHUploadPack(t *testing.T) {
Response: &accessverifier.Response{
Payload: accessverifier.CustomPayload{
Data: accessverifier.CustomPayloadData{
PrimaryRepo: url, GeoProxyFetchDirectToPrimaryWithOptions: true, GeoProxyFetchSSHDirectToPrimary: true,
PrimaryRepo: url,
GeoProxyFetchDirectToPrimaryWithOptions: true,
GeoProxyFetchSSHDirectToPrimary: true,
RequestHeaders: map[string]string{"Authorization": "token"},
},
},
},
Args: &commandargs.Shell{
Env: sshenv.Env{
GitProtocolVersion: "version=2",
},
},
}
require.NoError(t, cmd.Execute(context.Background()))
Loading
Loading
@@ -189,6 +199,8 @@ func setupSSHPull(t *testing.T, uploadPackStatusCode int) string {
defer r.Body.Close()
require.True(t, strings.HasSuffix(string(body), "0009done\n"))
require.Equal(t, r.Header.Get("Git-Protocol"), "version=2")
require.Equal(t, r.Header.Get("Authorization"), "token")
w.Write([]byte("upload-pack-response"))
w.WriteHeader(uploadPackStatusCode)
Loading
Loading
Loading
Loading
@@ -51,6 +51,7 @@ func (c *Command) Execute(ctx context.Context) (context.Context, error) {
cmd := githttp.PullCommand{
Config: c.Config,
ReadWriter: c.ReadWriter,
Args: c.Args,
Response: response,
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment