probe/discovery/protocol/tcp/syn/synv4_test.go

138 lines
2.9 KiB
Go
Raw Normal View History

2018-08-31 14:00:08 +00:00
package syn
2018-08-31 10:46:52 +00:00
import (
"reflect"
"testing"
omd "git.loafle.net/overflow/model/discovery"
2018-09-01 06:07:15 +00:00
"git.loafle.net/overflow_scanner/probe/__test"
2018-08-31 10:46:52 +00:00
"git.loafle.net/overflow_scanner/probe/discovery/session"
"git.loafle.net/overflow_scanner/probe/discovery/types"
"git.loafle.net/overflow_scanner/probe/internal/pcap"
"github.com/google/gopacket/layers"
)
func Test_scanV4(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,
__test.DiscoverPort(
nil,
1,
65535,
true,
false,
nil,
),
),
2018-08-31 10:46:52 +00:00
)
2018-09-01 06:07:15 +00:00
targetHost := __test.Host(
"atGame",
"1",
"00:11:32:7f:20:61",
)
2018-08-31 10:46:52 +00:00
type args struct {
discoverySession session.DiscoverySession
targetHost *omd.Host
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "1",
args: args{
discoverySession: s,
targetHost: targetHost,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := scanV4(tt.args.discoverySession, tt.args.targetHost); (err != nil) != tt.wantErr {
t.Errorf("scanV4() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_sendTCP4(t *testing.T) {
type args struct {
discoverySession session.DiscoverySession
ps pcap.PCapScanner
host *omd.Host
}
tests := []struct {
name string
args args
wantErr bool
}{
2018-09-03 10:33:20 +00:00
// TODO: Add test cases.
2018-08-31 10:46:52 +00:00
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := sendTCP4(tt.args.discoverySession, tt.args.ps, tt.args.host); (err != nil) != tt.wantErr {
t.Errorf("sendTCP4() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_handlePacketTCP4(t *testing.T) {
type args struct {
discoverySession session.DiscoverySession
host *omd.Host
ports map[int]*omd.Port
packet *layers.TCP
}
tests := []struct {
name string
args args
want *omd.Port
}{
2018-09-03 10:33:20 +00:00
// TODO: Add test cases.
2018-08-31 10:46:52 +00:00
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := handlePacketTCP4(tt.args.discoverySession, tt.args.host, tt.args.ports, tt.args.packet); !reflect.DeepEqual(got, tt.want) {
t.Errorf("handlePacketTCP4() = %v, want %v", got, tt.want)
}
})
}
}
func Test_makePacketPortTCP4(t *testing.T) {
type args struct {
host *omd.Host
}
tests := []struct {
name string
args args
want *PortPacketTCP4
wantErr bool
}{
2018-09-03 10:33:20 +00:00
// TODO: Add test cases.
2018-08-31 10:46:52 +00:00
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := makePacketPortTCP4(tt.args.host)
if (err != nil) != tt.wantErr {
t.Errorf("makePacketPortTCP4() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("makePacketPortTCP4() = %v, want %v", got, tt.want)
}
})
}
}