mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-28 06:16:31 +01:00
Fix local runs of ssh-requiring integration tests (#7855)
This commit is contained in:
parent
cbe30783c7
commit
176ba79e96
@ -24,20 +24,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func withKeyFile(t *testing.T, keyname string, callback func(string)) {
|
func withKeyFile(t *testing.T, keyname string, callback func(string)) {
|
||||||
keyFile := filepath.Join(setting.AppDataPath, keyname)
|
|
||||||
err := ssh.GenKeyPair(keyFile)
|
tmpDir, err := ioutil.TempDir("", "key-file")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
|
err = os.Chmod(tmpDir, 0700)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
keyFile := filepath.Join(tmpDir, keyname)
|
||||||
|
err = ssh.GenKeyPair(keyFile)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
//Setup ssh wrapper
|
//Setup ssh wrapper
|
||||||
os.Setenv("GIT_SSH_COMMAND",
|
os.Setenv("GIT_SSH_COMMAND",
|
||||||
"ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "+
|
"ssh -o \"UserKnownHostsFile=/dev/null\" -o \"StrictHostKeyChecking=no\" -o \"IdentitiesOnly=yes\" -i \""+keyFile+"\"")
|
||||||
filepath.Join(setting.AppWorkPath, keyFile))
|
|
||||||
os.Setenv("GIT_SSH_VARIANT", "ssh")
|
os.Setenv("GIT_SSH_VARIANT", "ssh")
|
||||||
|
|
||||||
callback(keyFile)
|
callback(keyFile)
|
||||||
|
|
||||||
defer os.RemoveAll(keyFile)
|
|
||||||
defer os.RemoveAll(keyFile + ".pub")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createSSHUrl(gitPath string, u *url.URL) *url.URL {
|
func createSSHUrl(gitPath string, u *url.URL) *url.URL {
|
||||||
|
Loading…
Reference in New Issue
Block a user