feat: Support scp files from proxy command. (#47)

* feat: Support scp files from proxy command.
This commit is contained in:
Bo-Yi Wu
2017-03-06 14:43:52 +08:00
committed by GitHub
parent 04c639cfa8
commit 72c123f390
5 changed files with 181 additions and 25 deletions
+38
View File
@@ -141,6 +141,43 @@ func TestSCPWildcardFileList(t *testing.T) {
}
}
func TestSCPFromProxySetting(t *testing.T) {
u, err := user.Lookup("drone-scp")
if err != nil {
t.Fatalf("Lookup: %v", err)
}
plugin := Plugin{
Config: Config{
Host: []string{"localhost"},
Username: "drone-scp",
Port: "22",
KeyPath: "tests/.ssh/id_rsa",
Source: []string{"tests/global/*"},
Target: []string{u.HomeDir + "/def"},
CommandTimeout: 60,
Proxy: defaultConfig{
Server: "localhost",
User: "drone-scp",
Port: "22",
KeyPath: "./tests/.ssh/id_rsa",
},
},
}
err = plugin.Exec()
assert.Nil(t, err)
// check file exist
if _, err := os.Stat(u.HomeDir + "/def/tests/global/c.txt"); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
if _, err := os.Stat(u.HomeDir + "/def/tests/global/d.txt"); os.IsNotExist(err) {
t.Fatalf("SCP-error: %v", err)
}
}
// func TestSCPFileFromSSHAgent(t *testing.T) {
// if os.Getenv("SSH_AUTH_SOCK") == "" {
// exec.Command("eval", "`ssh-agent -s`").Run()
@@ -235,6 +272,7 @@ func TestGlobList(t *testing.T) {
expects = []string{"tests/a.txt", "tests/b.txt"}
assert.Equal(t, expects, globList(paterns))
// remove item which file not found.
paterns = []string{"tests/aa.txt", "tests/b.txt"}
expects = []string{"tests/b.txt"}
assert.Equal(t, expects, globList(paterns))