test modified

This commit is contained in:
crusader
2018-09-01 15:07:15 +09:00
parent 5956cae93f
commit 6f259e2d9d
14 changed files with 226 additions and 193 deletions

View File

@@ -5,7 +5,7 @@ import (
"time"
omd "git.loafle.net/overflow/model/discovery"
omm "git.loafle.net/overflow/model/meta"
"git.loafle.net/overflow_scanner/probe/__test"
"git.loafle.net/overflow_scanner/probe/discovery/session"
"git.loafle.net/overflow_scanner/probe/discovery/types"
)
@@ -14,33 +14,27 @@ func TestScan(t *testing.T) {
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{},
DiscoverPort: &omd.DiscoverPort{
FirstScanRange: 1,
LastScanRange: 65535,
IncludeTCP: true,
},
},
__test.Zone(),
__test.DiscoverHost(
__test.DiscoveryConfig(),
1,
254,
__test.DiscoverPort(
nil,
1,
65535,
true,
false,
nil,
),
),
)
targetHost := &omd.Host{
MetaIPType: omm.ToMetaIPType(omm.MetaIPTypeEnumV4),
Name: "atGame",
Address: "192.168.1.1",
Mac: "00:11:32:7f:20:61",
Zone: s.Zone(),
}
targetHost := __test.Host(
"atGame",
"1",
"00:11:32:7f:20:61",
)
type args struct {
discoverySession session.DiscoverySession
@@ -85,7 +79,7 @@ func Test_scanPort(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
scanPort(tt.args.discoverySession, tt.args.ports, tt.args.targetHost, tt.args.port, tt.args.timeout)
tryConnect(tt.args.discoverySession, tt.args.ports, tt.args.targetHost, tt.args.port, tt.args.timeout)
})
}
}