communicator/ssh: staticcheck
This commit is contained in:
parent
aeb96384fd
commit
63b521b8b7
|
@ -55,7 +55,6 @@ type Communicator struct {
|
|||
client *ssh.Client
|
||||
config *sshConfig
|
||||
conn net.Conn
|
||||
address string
|
||||
cancelKeepAlive context.CancelFunc
|
||||
|
||||
lock sync.Mutex
|
||||
|
|
|
@ -99,6 +99,7 @@ func newMockLineServer(t *testing.T, signer ssh.Signer, pubKey string) string {
|
|||
t.Log("Accepted channel")
|
||||
|
||||
go func(in <-chan *ssh.Request) {
|
||||
defer channel.Close()
|
||||
for req := range in {
|
||||
// since this channel's requests are serviced serially,
|
||||
// this will block keepalive probes, and can simulate a
|
||||
|
@ -112,8 +113,6 @@ func newMockLineServer(t *testing.T, signer ssh.Signer, pubKey string) string {
|
|||
}
|
||||
}
|
||||
}(requests)
|
||||
|
||||
defer channel.Close()
|
||||
}
|
||||
conn.Close()
|
||||
}()
|
||||
|
@ -714,34 +713,6 @@ func TestScriptPath_randSeed(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
const testClientPrivateKey = `-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEAxOgNXOJ/jrRDxBZTSk2X9otNy9zcpUmJr5ifDi5sy7j2ZiQS
|
||||
beBt1Wf+tLNWis8Cyq06ttEvjjRuM75yucyD6GrqDTXVCSm4PeOIQeDhPhw26wYZ
|
||||
O0h/mFgrAiCwaEl8AFXVBInOhVn/0nqgUpkwckh76bjTsNeifkiugK3cfJOuBdrU
|
||||
ZGbgugJjmYo4Cmv7ECo1gCFT5N+BAjOji3z3N5ClBH5HaWC77jH7kTH0k5cZ+ZRQ
|
||||
tG9EqLyvWlnzTAR/Yly0JInkOa16Ms1Au5sIJwEoJfHKsNVK06IlLob53nblwYW0
|
||||
H5gv1Kb/rS+nUkpPtA5YFShB7iZnPLPPv6qXSwIDAQABAoIBAC0UY1rMkB9/rbQK
|
||||
2G6+bPgI1HrDydAdkeQdsOxyPH43jlG8GGwHYZ3l/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EECgYEAto/iJB7ZlCM7EyV9JW0tsEt83rbKMQ/Ex0ShbBIejej0Xx7bwx60
|
||||
tVgay+bzJnNkXu6J4XVI98A/WsdI2kW4hL0STYdHV5HVA1l87V4ZbvTF2Bx8a8RJ
|
||||
OF3UjpMTWKqOprw9nAu5VuwNRVzORF8ER8rgGeaR2/gsSvIYFy9VXq8=
|
||||
-----END RSA PRIVATE KEY-----`
|
||||
|
||||
var testClientPublicKey = `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6A1c4n+OtEPEFlNKTZf2i03L3NylSYmvmJ8OLmzLuPZmJBJt4G3VZ/60s1aKzwLKrTq20S+ONG4zvnK5zIPoauoNNdUJKbg944hB4OE+HDbrBhk7SH+YWCsCILBoSXwAVdUEic6FWf/SeqBSmTBySHvpuNOw16J+SK6Ardx8k64F2tRkZuC6AmOZijgKa/sQKjWAIVPk34ECM6OLfPc3kKUEfkdpYLvuMfuRMfSTlxn5lFC0b0SovK9aWfNMBH9iXLQkieQ5rXoyzUC7mwgnASgl8cqw1UrToiUuhvneduXBhbQfmC/Upv+tL6dSSk+0DlgVKEHuJmc8s8+/qpdL`
|
||||
|
||||
func acceptUserPass(goodUser, goodPass string) func(ssh.ConnMetadata, []byte) (*ssh.Permissions, error) {
|
||||
|
|
|
@ -3,18 +3,8 @@ package ssh
|
|||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
func TestPasswordKeyboardInteractive_Impl(t *testing.T) {
|
||||
var raw interface{}
|
||||
raw = PasswordKeyboardInteractive("foo")
|
||||
if _, ok := raw.(ssh.KeyboardInteractiveChallenge); !ok {
|
||||
t.Fatal("PasswordKeyboardInteractive must implement KeyboardInteractiveChallenge")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPasswordKeybardInteractive_Challenge(t *testing.T) {
|
||||
p := PasswordKeyboardInteractive("foo")
|
||||
result, err := p("foo", "bar", []string{"one", "two"}, nil)
|
||||
|
|
|
@ -412,7 +412,7 @@ func readPrivateKey(pk string) (ssh.AuthMethod, error) {
|
|||
}
|
||||
|
||||
func connectToAgent(connInfo *connectionInfo) (*sshAgent, error) {
|
||||
if connInfo.Agent != true {
|
||||
if !connInfo.Agent {
|
||||
// No agent configured
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -547,13 +547,6 @@ func (s *sshAgent) sortSigners(signers []ssh.Signer) {
|
|||
continue
|
||||
}
|
||||
}
|
||||
|
||||
ss := []string{}
|
||||
for _, signer := range signers {
|
||||
pk := signer.PublicKey()
|
||||
k := pk.(*agent.Key)
|
||||
ss = append(ss, k.Comment)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *sshAgent) Signers() ([]ssh.Signer, error) {
|
||||
|
|
|
@ -81,10 +81,10 @@ func generateSSHKey(t *testing.T, idFile string) ssh.PublicKey {
|
|||
}
|
||||
|
||||
privFile, err := os.OpenFile(idFile, os.O_RDWR|os.O_CREATE, 0600)
|
||||
defer privFile.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer privFile.Close()
|
||||
privPEM := &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(priv)}
|
||||
if err := pem.Encode(privFile, privPEM); err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
Loading…
Reference in New Issue