MCPcopy Create free account
hub / github.com/appleboy/easyssh-proxy / TestSCPCommand

Function TestSCPCommand

easyssh_test.go:186–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestSCPCommand(t *testing.T) {
187 // wrong key
188 ssh := &MakeConfig{
189 Server: "localhost",
190 User: "drone-scp",
191 Port: "22",
192 KeyPath: "./tests/.ssh/id_rsa.pub",
193 }
194
195 err := ssh.Scp("./tests/a.txt", "a.txt")
196 assert.Error(t, err)
197
198 ssh = &MakeConfig{
199 Server: "localhost",
200 User: "drone-scp",
201 Port: "22",
202 KeyPath: "./tests/.ssh/id_rsa",
203 }
204
205 err = ssh.Scp("./tests/a.txt", "a.txt")
206 assert.NoError(t, err)
207
208 u, err := user.Lookup("drone-scp")
209 if err != nil {
210 t.Fatalf("Lookup: %v", err)
211 }
212
213 // check file exist
214 if _, err := os.Stat(path.Join(u.HomeDir, "a.txt")); os.IsNotExist(err) {
215 t.Fatalf("SCP-error: %v", err)
216 }
217}
218
219func TestSCPCommandWithKey(t *testing.T) {
220 ssh := &MakeConfig{

Callers

nothing calls this directly

Calls 1

ScpMethod · 0.95

Tested by

no test coverage detected