forked from projectdiscovery/nuclei
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp_probe_test.go
More file actions
59 lines (51 loc) · 1.53 KB
/
http_probe_test.go
File metadata and controls
59 lines (51 loc) · 1.53 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
package utils
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestDetermineSchemeOrder(t *testing.T) {
type testCase struct {
input string
expected []string
}
tests := []testCase{
// No port or uncommon ports should return https first
{"example.com", []string{"https", "http"}},
{"example.com:443", []string{"https", "http"}},
{"127.0.0.1", []string{"https", "http"}},
{"[fe80::1]:443", []string{"https", "http"}},
// Common HTTP ports should return http first
{"example.com:80", []string{"http", "https"}},
{"example.com:8080", []string{"http", "https"}},
{"127.0.0.1:80", []string{"http", "https"}},
{"127.0.0.1:8080", []string{"http", "https"}},
{"fe80::1", []string{"https", "http"}},
{"[fe80::1]:80", []string{"http", "https"}},
{"[fe80::1]:8080", []string{"http", "https"}},
}
for _, tc := range tests {
t.Run(tc.input, func(t *testing.T) {
actual := determineSchemeOrder(tc.input)
require.Equal(t, tc.expected, actual)
})
}
}
func TestDetermineSchemeOrderWithHighPorts(t *testing.T) {
type testCase struct {
input string
expected []string
}
tests := []testCase{
// Ports > 1024 should return http first
{"example.com:2048", []string{"http", "https"}},
{"example.com:8081", []string{"http", "https"}},
{"[fe80::1]:2048", []string{"http", "https"}},
{"[fe80::1]:12345", []string{"http", "https"}},
}
for _, tc := range tests {
t.Run(tc.input, func(t *testing.T) {
actual := determineSchemeOrder(tc.input)
require.Equal(t, tc.expected, actual)
})
}
}