diff options
author | Lucas Charles <me@lucascharles.me> | 2021-02-17 13:49:46 -0800 |
---|---|---|
committer | Lucas Charles <me@lucascharles.me> | 2021-03-15 13:47:11 -0700 |
commit | d539068dc372e46d10adee89e9b96b59156a2bb6 (patch) | |
tree | 9c37f5ade4a95622b30a7a47befcb46b185b9682 /internal/handler/exec_test.go | |
parent | e79f115d93a9f00f3e4f8a22ec770fdf4c3e1947 (diff) | |
download | gitlab-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/handler/exec_test.go')
-rw-r--r-- | internal/handler/exec_test.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/internal/handler/exec_test.go b/internal/handler/exec_test.go index 0dbd538..915bf5a 100644 --- a/internal/handler/exec_test.go +++ b/internal/handler/exec_test.go @@ -12,7 +12,7 @@ import ( pb "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "gitlab.com/gitlab-org/gitlab-shell/internal/config" "gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier" - "gitlab.com/gitlab-org/gitlab-shell/internal/testhelper" + "gitlab.com/gitlab-org/gitlab-shell/internal/sshenv" ) func makeHandler(t *testing.T, err error) func(context.Context, *grpc.ClientConn) (int32, error) { @@ -89,12 +89,12 @@ func TestGetConnMetadata(t *testing.T) { func TestPrepareContext(t *testing.T) { tests := []struct { - name string - gc *GitalyCommand - sshConnectionEnv string - repo *pb.Repository - response *accessverifier.Response - want map[string]string + name string + gc *GitalyCommand + env sshenv.Env + repo *pb.Repository + response *accessverifier.Response + want map[string]string }{ { name: "client_identity", @@ -102,7 +102,11 @@ func TestPrepareContext(t *testing.T) { Config: &config.Config{}, Address: "tcp://localhost:9999", }, - sshConnectionEnv: "10.0.0.1 1234 127.0.0.1 5678", + env: sshenv.Env{ + GitProtocolVersion: "protocol", + IsSSHConnection: true, + RemoteAddr: "10.0.0.1", + }, repo: &pb.Repository{ StorageName: "default", RelativePath: "@hashed/5f/9c/5f9c4ab08cac7457e9111a30e4664920607ea2c115a1433d7be98e97e64244ca.git", @@ -128,13 +132,9 @@ func TestPrepareContext(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - cleanup, err := testhelper.Setenv("SSH_CONNECTION", tt.sshConnectionEnv) - require.NoError(t, err) - defer cleanup() - ctx := context.Background() - ctx, cancel := tt.gc.PrepareContext(ctx, tt.repo, tt.response, "protocol") + ctx, cancel := tt.gc.PrepareContext(ctx, tt.repo, tt.response, tt.env) defer cancel() md, exists := metadata.FromOutgoingContext(ctx) |