ing
This commit is contained in:
parent
42c3ad9ab4
commit
f15521f202
|
@ -6,10 +6,10 @@ import (
|
||||||
|
|
||||||
omd "git.loafle.net/overflow/model/discovery"
|
omd "git.loafle.net/overflow/model/discovery"
|
||||||
omu "git.loafle.net/overflow/model/util"
|
omu "git.loafle.net/overflow/model/util"
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/protocol/mdns"
|
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/protocol/upnp"
|
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/internal/protocol/mdns"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/internal/protocol/upnp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Discoverer interface {
|
type Discoverer interface {
|
||||||
|
|
19
discovery/mock-discovery-request.go
Normal file
19
discovery/mock-discovery-request.go
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package discovery
|
||||||
|
|
||||||
|
import "git.loafle.net/overflow_scanner/probe/discovery/types"
|
||||||
|
|
||||||
|
func MockDiscoveryRequest(requesterID string, requestType types.DiscoveryRequestType, params ...interface{}) *mockDiscoveryRequest {
|
||||||
|
m := &mockDiscoveryRequest{}
|
||||||
|
m.requesterID = requesterID
|
||||||
|
m.requestType = requestType
|
||||||
|
m.params = params
|
||||||
|
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
type mockDiscoveryRequest struct {
|
||||||
|
ofDiscoveryRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dr *mockDiscoveryRequest) SendMessage(messageType types.DiscoveryMessageType, data interface{}, err error) {
|
||||||
|
}
|
|
@ -6,26 +6,33 @@ import (
|
||||||
|
|
||||||
omd "git.loafle.net/overflow/model/discovery"
|
omd "git.loafle.net/overflow/model/discovery"
|
||||||
omm "git.loafle.net/overflow/model/meta"
|
omm "git.loafle.net/overflow/model/meta"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/discovery"
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
||||||
"github.com/grandcat/zeroconf"
|
"github.com/grandcat/zeroconf"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestScan(t *testing.T) {
|
func TestScan(t *testing.T) {
|
||||||
s := session.MockDiscoverySession()
|
s := session.MockDiscoverySession()
|
||||||
s.InitWithDiscoverHost(
|
s.InitWithRequest(
|
||||||
nil,
|
discovery.MockDiscoveryRequest(
|
||||||
&omd.Zone{
|
"testRequester",
|
||||||
Network: "192.168.1.0/24",
|
types.DiscoveryRequestTypeHost,
|
||||||
Iface: "enp3s0",
|
[]interface{}{
|
||||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
&omd.Zone{
|
||||||
Address: "192.168.1.101",
|
Network: "192.168.1.0/24",
|
||||||
Mac: "44:8a:5b:f1:f1:f3",
|
Iface: "enp3s0",
|
||||||
},
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||||
&omd.DiscoverHost{
|
Address: "192.168.1.101",
|
||||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
Mac: "44:8a:5b:f1:f1:f3",
|
||||||
FirstScanRange: "192.168.1.1",
|
},
|
||||||
LastScanRange: "192.168.1.254",
|
&omd.DiscoverHost{
|
||||||
},
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||||
|
FirstScanRange: "192.168.1.1",
|
||||||
|
LastScanRange: "192.168.1.254",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
|
|
|
@ -5,25 +5,32 @@ import (
|
||||||
|
|
||||||
omd "git.loafle.net/overflow/model/discovery"
|
omd "git.loafle.net/overflow/model/discovery"
|
||||||
omm "git.loafle.net/overflow/model/meta"
|
omm "git.loafle.net/overflow/model/meta"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/discovery"
|
||||||
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
"git.loafle.net/overflow_scanner/probe/discovery/session"
|
||||||
|
"git.loafle.net/overflow_scanner/probe/discovery/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestScan(t *testing.T) {
|
func TestScan(t *testing.T) {
|
||||||
s := session.MockDiscoverySession()
|
s := session.MockDiscoverySession()
|
||||||
s.InitWithDiscoverHost(
|
s.InitWithRequest(
|
||||||
nil,
|
discovery.MockDiscoveryRequest(
|
||||||
&omd.Zone{
|
"testRequester",
|
||||||
Network: "192.168.1.0/24",
|
types.DiscoveryRequestTypeHost,
|
||||||
Iface: "enp3s0",
|
[]interface{}{
|
||||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
&omd.Zone{
|
||||||
Address: "192.168.1.101",
|
Network: "192.168.1.0/24",
|
||||||
Mac: "44:8a:5b:f1:f1:f3",
|
Iface: "enp3s0",
|
||||||
},
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||||
&omd.DiscoverHost{
|
Address: "192.168.1.101",
|
||||||
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
Mac: "44:8a:5b:f1:f1:f3",
|
||||||
FirstScanRange: "192.168.1.1",
|
},
|
||||||
LastScanRange: "192.168.1.254",
|
&omd.DiscoverHost{
|
||||||
},
|
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
|
||||||
|
FirstScanRange: "192.168.1.1",
|
||||||
|
LastScanRange: "192.168.1.254",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user