1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // ClientConn functional tests.
8 // These tests require a running ssh server listening on port 22
9 // on the local host. Functional tests will be skipped unless
10 // -ssh.user and -ssh.pass must be passed to gotest.
18 sshuser = flag.String("ssh.user", "", "ssh username")
19 sshpass = flag.String("ssh.pass", "", "ssh password")
20 sshprivkey = flag.String("ssh.privkey", "", "ssh privkey file")
23 func TestFuncPasswordAuth(t *testing.T) {
25 t.Log("ssh.user not defined, skipping test")
28 config := &ClientConfig{
31 ClientAuthPassword(password(*sshpass)),
34 conn, err := Dial("tcp", "localhost:22", config)
36 t.Fatalf("Unable to connect: %s", err)
41 func TestFuncPublickeyAuth(t *testing.T) {
43 t.Log("ssh.user not defined, skipping test")
47 if err := kc.loadPEM(*sshprivkey); err != nil {
48 t.Fatalf("unable to load private key: %s", err)
50 config := &ClientConfig{
53 ClientAuthPublickey(kc),
56 conn, err := Dial("tcp", "localhost:22", config)
58 t.Fatalf("unable to connect: %s", err)