2018-08-29 12:04:23 +00:00
|
|
|
package snmp
|
|
|
|
|
|
|
|
import (
|
2018-08-31 02:32:25 +00:00
|
|
|
"net"
|
2018-08-29 12:04:23 +00:00
|
|
|
"testing"
|
|
|
|
|
2018-08-31 02:32:25 +00:00
|
|
|
omcc "git.loafle.net/overflow/model/config/credential"
|
2018-09-01 06:07:15 +00:00
|
|
|
"git.loafle.net/overflow_scanner/probe/__test"
|
2018-08-30 12:56:32 +00:00
|
|
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
|
|
|
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
2018-08-29 12:04:23 +00:00
|
|
|
)
|
|
|
|
|
2018-08-31 02:32:25 +00:00
|
|
|
func TestScan(t *testing.T) {
|
|
|
|
s := session.NewMockDiscoverySession(
|
|
|
|
"testRequester",
|
|
|
|
types.DiscoveryRequestTypeHost,
|
2018-09-01 06:07:15 +00:00
|
|
|
__test.Zone(),
|
|
|
|
__test.DiscoverHost(__test.DiscoveryConfig(), 1, 254, nil),
|
2018-08-30 12:56:32 +00:00
|
|
|
)
|
2018-08-29 12:04:23 +00:00
|
|
|
|
2018-08-31 02:32:25 +00:00
|
|
|
type args struct {
|
|
|
|
discoverySession session.DiscoverySession
|
|
|
|
}
|
|
|
|
tests := []struct {
|
2018-08-31 05:15:46 +00:00
|
|
|
name string
|
|
|
|
args args
|
|
|
|
wantErr bool
|
2018-08-31 02:32:25 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "1",
|
|
|
|
args: args{
|
|
|
|
discoverySession: s,
|
|
|
|
},
|
2018-08-31 05:15:46 +00:00
|
|
|
wantErr: false,
|
2018-08-31 02:32:25 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2018-08-31 05:15:46 +00:00
|
|
|
if err := Scan(tt.args.discoverySession); (err != nil) != tt.wantErr {
|
|
|
|
t.Errorf("Scan() error = %v, wantErr %v", err, tt.wantErr)
|
|
|
|
}
|
2018-08-31 02:32:25 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2018-08-29 12:04:23 +00:00
|
|
|
|
2018-08-31 02:32:25 +00:00
|
|
|
func Test_scanV2(t *testing.T) {
|
|
|
|
type args struct {
|
|
|
|
target net.IP
|
|
|
|
discoverySession session.DiscoverySession
|
|
|
|
credential *omcc.SNMPCredential
|
|
|
|
}
|
|
|
|
tests := []struct {
|
|
|
|
name string
|
|
|
|
args args
|
|
|
|
want bool
|
|
|
|
}{
|
|
|
|
// TODO: Add test cases.
|
|
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
|
|
if got := scanV2(tt.args.target, tt.args.discoverySession, tt.args.credential); got != tt.want {
|
|
|
|
t.Errorf("scanV2() = %v, want %v", got, tt.want)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2018-08-29 12:04:23 +00:00
|
|
|
}
|