probe/discovery/target/service/service-tcp_test.go
crusader bf7500671e ing
2018-09-03 16:59:17 +09:00

162 lines
3.1 KiB
Go

package service
import (
"net"
"reflect"
"testing"
omd "git.loafle.net/overflow/model/discovery"
osm "git.loafle.net/overflow/service_matcher-go"
"git.loafle.net/overflow_scanner/probe/__test"
"git.loafle.net/overflow_scanner/probe/discovery/session"
"git.loafle.net/overflow_scanner/probe/discovery/types"
)
func Test_scanTCP(t *testing.T) {
s := session.NewMockDiscoverySession(
"testRequester",
types.DiscoveryRequestTypeHost,
__test.Zone(),
__test.DiscoverHost(
__test.DiscoveryConfig(),
1,
254,
__test.DiscoverPort(
nil,
1,
65535,
true,
false,
__test.DiscoverService(
nil,
),
),
),
)
targetHost := __test.Host(
"atGame",
"1",
"00:11:32:7f:20:61",
)
type args struct {
discoverySession session.DiscoverySession
targetPort *omd.Port
}
tests := []struct {
name string
args args
wantErr bool
}{
// {
// name: "80",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "80",
// ),
// },
// wantErr: false,
// },
{
name: "139",
args: args{
discoverySession: s,
targetPort: __test.Port(
targetHost,
"139",
),
},
wantErr: false,
},
// {
// name: "443",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "443",
// ),
// },
// wantErr: false,
// },
// {
// name: "445",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "445",
// ),
// },
// wantErr: false,
// },
// {
// name: "548",
// args: args{
// discoverySession: s,
// targetPort: __test.Port(
// targetHost,
// "548",
// ),
// },
// wantErr: false,
// },
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := scanTCP(tt.args.discoverySession, tt.args.targetPort); (err != nil) != tt.wantErr {
t.Errorf("scanTCP() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func Test_hadlePrePacket(t *testing.T) {
type args struct {
info osm.MatchInfo
_connector connector
conn net.Conn
packet *osm.Packet
}
tests := []struct {
name string
args args
want osm.Matcher
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := hadlePrePacket(tt.args.info, tt.args._connector, tt.args.conn, tt.args.packet); !reflect.DeepEqual(got, tt.want) {
t.Errorf("hadlePrePacket() = %v, want %v", got, tt.want)
}
})
}
}
func Test_hadlePostPacket(t *testing.T) {
type args struct {
info osm.MatchInfo
_connector connector
targetPort *omd.Port
limitedMatchers []osm.Matcher
}
tests := []struct {
name string
args args
want osm.Matcher
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := hadlePostPacket(tt.args.info, tt.args._connector, tt.args.targetPort, tt.args.limitedMatchers); !reflect.DeepEqual(got, tt.want) {
t.Errorf("hadlePostPacket() = %v, want %v", got, tt.want)
}
})
}
}