41 lines
614 B
Go
41 lines
614 B
Go
package audit
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestCheckSSH(t *testing.T) {
|
|
|
|
MountPingDB()
|
|
|
|
host1 := "102.1.41.3:22" // should evaluate to false
|
|
host2 := "127.0.0.1:22" // should evaluate to true
|
|
|
|
if err := BeginSshPing(host1); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
if err := BeginSshPing(host2); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
res, err := CheckSshPing(host1)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if res {
|
|
panic("check host 1 - res should be false")
|
|
}
|
|
|
|
res2, err := CheckSshPing(host2)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if !res2 {
|
|
panic("check host 2 - res should be true")
|
|
}
|
|
}
|