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

Function TestPrivateKeyAndPassword

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

Source from the content-addressed store, hash-verified

84}
85
86func TestPrivateKeyAndPassword(t *testing.T) {
87 // provide password and ssh private key
88 ssh := &MakeConfig{
89 Server: "localhost",
90 User: "drone-scp",
91 Port: "22",
92 Password: "1234",
93 KeyPath: "./tests/.ssh/id_rsa",
94 }
95
96 outStr, errStr, isTimeout, err := ssh.Run("whoami")
97 assert.Equal(t, "drone-scp\n", outStr)
98 assert.Equal(t, "", errStr)
99 assert.True(t, isTimeout)
100 assert.NoError(t, err)
101
102 // provide correct password and wrong private key
103 ssh = &MakeConfig{
104 Server: "localhost",
105 User: "drone-scp",
106 Port: "22",
107 Password: "1234",
108 KeyPath: "./tests/.ssh/id_rsa.pub",
109 }
110
111 outStr, errStr, isTimeout, err = ssh.Run("whoami")
112 assert.Equal(t, "drone-scp\n", outStr)
113 assert.Equal(t, "", errStr)
114 assert.True(t, isTimeout)
115 assert.NoError(t, err)
116
117 // provide wrong password and correct private key
118 ssh = &MakeConfig{
119 Server: "localhost",
120 User: "drone-scp",
121 Port: "22",
122 Password: "123456",
123 KeyPath: "./tests/.ssh/id_rsa",
124 }
125
126 outStr, errStr, isTimeout, err = ssh.Run("whoami")
127 assert.Equal(t, "drone-scp\n", outStr)
128 assert.Equal(t, "", errStr)
129 assert.True(t, isTimeout)
130 assert.NoError(t, err)
131}
132
133func TestRunCommand(t *testing.T) {
134 // wrong key

Callers

nothing calls this directly

Calls 1

RunMethod · 0.95

Tested by

no test coverage detected