mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-10 15:36:37 -04:00
tea previously set GIT_SSH_COMMAND=ssh for every SSH operation, even when it had no identity or passphrase to inject. Let git fall back to its own SSH command in that case so core.sshCommand, GIT_SSH_COMMAND, and the normal OpenSSH known_hosts handling are respected. Add regression coverage for ed25519 key parsing and CLI SSH auth setup. Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
34 lines
908 B
Go
34 lines
908 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPrepareCLIAuthSSHUsesGitDefaultCommandWithoutKey(t *testing.T) {
|
|
configs, env, cleanup, err := prepareCLIAuth(&AuthMethod{Scheme: "ssh", Username: "git"})
|
|
require.NoError(t, err)
|
|
require.Empty(t, configs)
|
|
require.Empty(t, env)
|
|
require.NotNil(t, cleanup)
|
|
cleanup()
|
|
}
|
|
|
|
func TestPrepareCLIAuthSSHInjectsConfiguredKey(t *testing.T) {
|
|
keyFile := "/tmp/tea test key"
|
|
configs, env, cleanup, err := prepareCLIAuth(&AuthMethod{Scheme: "ssh", KeyFile: keyFile})
|
|
require.NoError(t, err)
|
|
require.Empty(t, configs)
|
|
require.NotNil(t, cleanup)
|
|
cleanup()
|
|
|
|
require.Len(t, env, 1)
|
|
require.Contains(t, env[0], "GIT_SSH_COMMAND=ssh ")
|
|
require.Contains(t, env[0], "IdentitiesOnly=yes")
|
|
require.Contains(t, env[0], shellQuote(keyFile))
|
|
}
|