Repository navigation
Expand file tree
/
Copy patherrors_test.go
More file actions
60 lines (53 loc) · 1.44 KB
/
Copy patherrors_test.go
File metadata and controls
60 lines (53 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package gomap
import (
"errors"
"testing"
)
func TestValidateIdleScanRequiresZombie(t *testing.T) {
opts := ScanOptions{ScanType: IdleScan}
err := opts.Validate()
if err == nil {
t.Fatal("expected error for idle scan without zombie")
}
if !errors.Is(err, ErrInvalidScanOptions) {
t.Errorf("expected ErrInvalidScanOptions, got: %v", err)
}
}
func TestValidateFTPBounceRequiresServer(t *testing.T) {
opts := ScanOptions{ScanType: FTPBounceScan}
err := opts.Validate()
if err == nil {
t.Fatal("expected error for FTP bounce without server")
}
if !errors.Is(err, ErrInvalidScanOptions) {
t.Errorf("expected ErrInvalidScanOptions, got: %v", err)
}
}
func TestValidateVersionIntensityRange(t *testing.T) {
opts := ScanOptions{VersionIntensity: 10}
err := opts.Validate()
if err == nil {
t.Fatal("expected error for intensity > 9")
}
}
func TestValidateMinMaxRate(t *testing.T) {
opts := ScanOptions{MinRate: 1000, MaxRate: 100}
err := opts.Validate()
if err == nil {
t.Fatal("expected error when min-rate > max-rate")
}
}
func TestValidateConnectScanOK(t *testing.T) {
opts := ScanOptions{ScanType: ConnectScan}
err := opts.Validate()
if err != nil {
t.Errorf("connect scan should validate: %v", err)
}
}
func TestSentinelErrorsUsable(t *testing.T) {
// Ensure sentinel errors can be used with errors.Is
wrapped := errors.New("test")
if errors.Is(wrapped, ErrRawSocketRequired) {
t.Error("unrelated error should not match")
}
}