use native golang SSH library but ssh-keygen when enable built-in SSH server to remove dependent on that command lines (#5976)

* use native golang SSH library but ssh-keygen when enable built-in SSH server to remove dependent on that command lines

* fix tests and add comment head
This commit is contained in:
Lunny Xiao 2019-02-07 15:13:12 +08:00 committed by techknowlogick
parent 06a1739553
commit 2d213b64d1
2 changed files with 45 additions and 4 deletions

View file

@ -12,20 +12,20 @@ import (
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"testing"
"time"
"code.gitea.io/git"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/ssh"
"github.com/Unknwon/com"
"github.com/stretchr/testify/assert"
)
func withKeyFile(t *testing.T, keyname string, callback func(string)) {
keyFile := filepath.Join(setting.AppDataPath, keyname)
err := exec.Command("ssh-keygen", "-f", keyFile, "-t", "rsa", "-N", "").Run()
err := ssh.GenKeyPair(keyFile)
assert.NoError(t, err)
//Setup ssh wrapper