diff options
author | zeripath <art27@cantab.net> | 2019-08-14 12:19:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-14 12:19:13 +0100 |
commit | 176ba79e96f59d9ed04af272b80dfcf62fae3e65 (patch) | |
tree | b7d54ad55c2de21eea35f9d5808888bbe37316ef /integrations/git_helper_for_declarative_test.go | |
parent | cbe30783c7c94f08acc431c845463a05f3e2d225 (diff) | |
download | gitea-176ba79e96f59d9ed04af272b80dfcf62fae3e65.tar.gz gitea-176ba79e96f59d9ed04af272b80dfcf62fae3e65.zip |
Fix local runs of ssh-requiring integration tests (#7855)
Diffstat (limited to 'integrations/git_helper_for_declarative_test.go')
-rw-r--r-- | integrations/git_helper_for_declarative_test.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/integrations/git_helper_for_declarative_test.go b/integrations/git_helper_for_declarative_test.go index 235f4b4a9b..9190d4bb4e 100644 --- a/integrations/git_helper_for_declarative_test.go +++ b/integrations/git_helper_for_declarative_test.go @@ -24,20 +24,24 @@ import ( ) 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) //Setup ssh wrapper os.Setenv("GIT_SSH_COMMAND", - "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i "+ - filepath.Join(setting.AppWorkPath, keyFile)) + "ssh -o \"UserKnownHostsFile=/dev/null\" -o \"StrictHostKeyChecking=no\" -o \"IdentitiesOnly=yes\" -i \""+keyFile+"\"") os.Setenv("GIT_SSH_VARIANT", "ssh") callback(keyFile) - - defer os.RemoveAll(keyFile) - defer os.RemoveAll(keyFile + ".pub") } func createSSHUrl(gitPath string, u *url.URL) *url.URL { |