probe/discovery/protocol/tcp/connection/connection_test.go

102 lines
1.9 KiB
Go
Raw Normal View History

2018-08-31 14:00:08 +00:00
package connection
2018-08-31 10:46:52 +00:00
import (
"testing"
2018-08-31 14:00:08 +00:00
"time"
2018-08-31 10:46:52 +00:00
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"
)
2018-08-31 14:00:08 +00:00
func TestScan(t *testing.T) {
2018-08-31 10:46:52 +00:00
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) {
2018-08-31 14:00:08 +00:00
if err := Scan(tt.args.discoverySession, tt.args.targetHost); (err != nil) != tt.wantErr {
t.Errorf("Scan() error = %v, wantErr %v", err, tt.wantErr)
2018-08-31 10:46:52 +00:00
}
})
}
}
2018-08-31 14:00:08 +00:00
func Test_scanPort(t *testing.T) {
2018-08-31 10:46:52 +00:00
type args struct {
discoverySession session.DiscoverySession
ports map[int]*omd.Port
2018-08-31 14:00:08 +00:00
targetHost *omd.Host
port int
timeout time.Duration
2018-08-31 10:46:52 +00:00
}
tests := []struct {
name string
args args
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
2018-09-01 06:07:15 +00:00
tryConnect(tt.args.discoverySession, tt.args.ports, tt.args.targetHost, tt.args.port, tt.args.timeout)
2018-08-31 10:46:52 +00:00
})
}
}
2018-08-31 14:00:08 +00:00
func TestUlimit(t *testing.T) {
2018-08-31 10:46:52 +00:00
tests := []struct {
2018-08-31 14:00:08 +00:00
name string
want int64
2018-08-31 10:46:52 +00:00
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
2018-08-31 14:00:08 +00:00
if got := Ulimit(); got != tt.want {
t.Errorf("Ulimit() = %v, want %v", got, tt.want)
2018-08-31 10:46:52 +00:00
}
})
}
}