summaryrefslogtreecommitdiff
path: root/internal/command/receivepack/gitalycall_test.go
diff options
context:
space:
mode:
authorLucas Charles <me@lucascharles.me>2021-02-17 13:49:46 -0800
committerLucas Charles <me@lucascharles.me>2021-03-15 13:47:11 -0700
commitd539068dc372e46d10adee89e9b96b59156a2bb6 (patch)
tree9c37f5ade4a95622b30a7a47befcb46b185b9682 /internal/command/receivepack/gitalycall_test.go
parente79f115d93a9f00f3e4f8a22ec770fdf4c3e1947 (diff)
downloadgitlab-shell-d539068dc372e46d10adee89e9b96b59156a2bb6.tar.gz
chore: Refactor env introspection to rely on command initialization496-move-env-introspection-to-sshenv
Refactors introspection of execution environment to rely on per-connection state (`gitlab-shell`) or per request (`gitlab-sshd`) Relates to https://gitlab.com/gitlab-org/gitlab-shell/-/issues/496
Diffstat (limited to 'internal/command/receivepack/gitalycall_test.go')
-rw-r--r--internal/command/receivepack/gitalycall_test.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/internal/command/receivepack/gitalycall_test.go b/internal/command/receivepack/gitalycall_test.go
index ea07477..d756248 100644
--- a/internal/command/receivepack/gitalycall_test.go
+++ b/internal/command/receivepack/gitalycall_test.go
@@ -13,6 +13,7 @@ import (
"gitlab.com/gitlab-org/gitlab-shell/internal/command/commandargs"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
+ "gitlab.com/gitlab-org/gitlab-shell/internal/sshenv"
"gitlab.com/gitlab-org/gitlab-shell/internal/testhelper"
"gitlab.com/gitlab-org/gitlab-shell/internal/testhelper/requesthandlers"
)
@@ -25,10 +26,6 @@ func TestReceivePack(t *testing.T) {
url, cleanup := testserver.StartHttpServer(t, requests)
defer cleanup()
- envCleanup, err := testhelper.Setenv("SSH_CONNECTION", "127.0.0.1 0")
- require.NoError(t, err)
- defer envCleanup()
-
testCases := []struct {
username string
keyId string
@@ -46,7 +43,12 @@ func TestReceivePack(t *testing.T) {
input := &bytes.Buffer{}
repo := "group/repo"
- args := &commandargs.Shell{CommandType: commandargs.ReceivePack, SshArgs: []string{"git-receive-pack", repo}}
+ env := sshenv.Env{
+ IsSSHConnection: true,
+ OriginalCommand: "git-receive-pack group/repo",
+ RemoteAddr: "127.0.0.1",
+ }
+ args := &commandargs.Shell{CommandType: commandargs.ReceivePack, SshArgs: []string{"git-receive-pack", repo}, Env: env}
if tc.username != "" {
args.GitlabUsername = tc.username
@@ -62,7 +64,7 @@ func TestReceivePack(t *testing.T) {
hook := testhelper.SetupLogger()
- err = cmd.Execute(context.Background())
+ err := cmd.Execute(context.Background())
require.NoError(t, err)
if tc.username != "" {