forked from kbolino/pageant
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pageant_test.go
41 lines (37 loc) · 873 Bytes
/
pageant_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package pageant
import (
"testing"
"golang.org/x/crypto/ssh/agent"
)
// Pageant must be running for this test to work.
func TestNewConn(t *testing.T) {
conn, err := NewConn()
if err != nil {
t.Fatalf("error on NewConn: %s", err)
} else if conn == nil {
t.Fatalf("NewConn returned nil")
}
err = conn.Close()
if err != nil {
t.Fatalf("error on Conn.Close: %s", err)
}
}
// Pageant must be running and have at least 1 key loaded for this test to work.
func TestSSHAgentList(t *testing.T) {
conn, err := NewConn()
if err != nil {
t.Fatalf("error on NewConn: %s", err)
}
defer conn.Close()
sshAgent := agent.NewClient(conn)
keys, err := sshAgent.List()
if err != nil {
t.Fatalf("error on agent.List: %s", err)
}
if len(keys) == 0 {
t.Fatalf("no keys listed by Pagent")
}
for i, key := range keys {
t.Logf("key %d: %s", i, key.Comment)
}
}