-
Notifications
You must be signed in to change notification settings - Fork 0
/
SSHTools_test.go
64 lines (55 loc) · 1.51 KB
/
SSHTools_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package icinga2_go_checktools
import (
"testing"
)
var ict *SSHTools
func Test_NewSSHTools_ArubaController1(t *testing.T) {
var err error
ict, err = NewSSHTools("10.10.3.9", "icinga", "", "~/.ssh/id_rsa", 22)
if err != nil {
t.Errorf("Error establishing SSH connection to 10.10.3.9 => %s", err)
}
}
func Test_SendSSHhasPTY_ArubaController1(t *testing.T) {
err := ict.SendSSHhasPTY([]string{"no paging\r", "show user-table role TDH_Guest\r"}, `(?m)^\(.*\)\s#$`)
if err != nil {
t.Errorf("Error sending SSH Command: %s", err)
return
}
if ict.Stdout == "" {
t.Errorf("Error command return no response\n")
} else {
t.Logf("%s", ict.Stdout)
}
}
func Test_SendSSHhasPTY_ArubaController2(t *testing.T) {
err := ict.SendSSHhasPTY([]string{"no paging\r", "show user-table role TDH_WEB_AUTH\r"}, `(?m)^\(.*\)\s#$`)
if err != nil {
t.Errorf("Error sending SSH Command: %s", err)
return
}
if ict.Stdout == "" {
t.Errorf("Error command return no response\n")
} else {
t.Logf("%s", ict.Stdout)
}
}
func Test_NewSSHConnection_CISCO2960(t *testing.T) {
var err error
ict, err = NewSSHTools("10.10.100.31", "icinga", "", "~/.ssh/id_rsa", 22)
if err != nil {
t.Errorf("Error establishing SSH connection to 10.10.100.31 => %s", err)
}
}
func Test_SendSSH_CISCO2960(t *testing.T) {
err := ict.SendSSH("show interface SwStatus")
if err != nil {
t.Errorf("Error sending SSH Command: %s", err)
return
}
if ict.Stdout == "" {
t.Errorf("Error command return no response\n")
} else {
t.Logf("%s", ict.Stdout)
}
}