probe/discovery/protocol/icmp/privileged/icmpv4_test.go

115 lines
2.5 KiB
Go
Raw Normal View History

2018-09-01 02:19:03 +00:00
package privileged
2018-08-31 10:05:49 +00:00
import (
"net"
"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:05:49 +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"
)
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, nil),
2018-08-31 10:05:49 +00:00
)
type args struct {
discoverySession session.DiscoverySession
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "1",
args: args{
discoverySession: s,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := scanV4(tt.args.discoverySession); (err != nil) != tt.wantErr {
t.Errorf("scanV4() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_sendICMP4(t *testing.T) {
type args struct {
ps pcap.PCapScanner
zone *omd.Zone
targetHosts []net.IP
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := sendICMP4(tt.args.ps, tt.args.zone, tt.args.targetHosts); (err != nil) != tt.wantErr {
t.Errorf("sendICMP4() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_handlePacketICMP4(t *testing.T) {
type args struct {
zone *omd.Zone
targetHosts []net.IP
hosts map[string]*omd.Host
packet gopacket.Packet
}
tests := []struct {
name string
args args
want *omd.Host
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := handlePacketICMP4(tt.args.zone, tt.args.targetHosts, tt.args.hosts, tt.args.packet); !reflect.DeepEqual(got, tt.want) {
t.Errorf("handlePacketICMP4() = %v, want %v", got, tt.want)
}
})
}
}
func Test_makeMessageICMP4(t *testing.T) {
tests := []struct {
name string
want []byte
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := makeMessageICMP4()
if (err != nil) != tt.wantErr {
t.Errorf("makeMessageICMP4() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("makeMessageICMP4() = %v, want %v", got, tt.want)
}
})
}
}