2018-08-29 12:04:23 +00:00
|
|
|
package upnp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
omd "git.loafle.net/overflow/model/discovery"
|
|
|
|
omm "git.loafle.net/overflow/model/meta"
|
|
|
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
2018-08-29 18:37:40 +00:00
|
|
|
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
2018-08-29 12:04:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestScan(t *testing.T) {
|
2018-08-31 02:32:25 +00:00
|
|
|
s := session.NewMockDiscoverySession(
|
|
|
|
"testRequester",
|
|
|
|
types.DiscoveryRequestTypeHost,
|
|
|
|
&omd.Zone{
|
|
|
|
Network: "192.168.1.0/24",
|
|
|
|
Iface: "enp3s0",
|
|
|
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
|
|
|
Address: "192.168.1.101",
|
|
|
|
Mac: "44:8a:5b:f1:f1:f3",
|
|
|
|
},
|
|
|
|
&omd.DiscoverHost{
|
|
|
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
|
|
|
FirstScanRange: "192.168.1.1",
|
|
|
|
LastScanRange: "192.168.1.254",
|
|
|
|
DiscoveryConfig: &omd.DiscoveryConfig{},
|
|
|
|
},
|
2018-08-29 12:04:23 +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-29 12:04:23 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "1",
|
|
|
|
args: args{
|
|
|
|
discoverySession: s,
|
|
|
|
},
|
2018-08-31 05:15:46 +00:00
|
|
|
wantErr: false,
|
2018-08-29 12:04:23 +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-29 12:04:23 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|