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

Function TestRunCommandWithFingerprint

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

Source from the content-addressed store, hash-verified

50}
51
52func TestRunCommandWithFingerprint(t *testing.T) {
53 // wrong fingerprint
54 sshConf := &MakeConfig{
55 Server: "localhost",
56 User: "drone-scp",
57 Port: "22",
58 KeyPath: "./tests/.ssh/id_rsa",
59 Fingerprint: "wrong",
60 }
61
62 outStr, errStr, isTimeout, err := sshConf.Run("whoami", 10)
63 assert.Equal(t, "", outStr)
64 assert.Equal(t, "", errStr)
65 assert.False(t, isTimeout)
66 assert.Error(t, err)
67
68 hostKey, err := getHostPublicKeyFile("/etc/ssh/ssh_host_rsa_key.pub")
69 assert.NoError(t, err)
70
71 sshConf = &MakeConfig{
72 Server: "localhost",
73 User: "drone-scp",
74 Port: "22",
75 KeyPath: "./tests/.ssh/id_rsa",
76 Fingerprint: ssh.FingerprintSHA256(hostKey),
77 }
78
79 outStr, errStr, isTimeout, err = sshConf.Run("whoami")
80 assert.Equal(t, "drone-scp\n", outStr)
81 assert.Equal(t, "", errStr)
82 assert.True(t, isTimeout)
83 assert.NoError(t, err)
84}
85
86func TestPrivateKeyAndPassword(t *testing.T) {
87 // provide password and ssh private key

Callers

nothing calls this directly

Calls 2

RunMethod · 0.95
getHostPublicKeyFileFunction · 0.85

Tested by

no test coverage detected