We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 92f5f6d commit 0648439Copy full SHA for 0648439
http/http_test.go
@@ -11,11 +11,23 @@ import (
11
"github.com/stretchr/testify/assert"
12
)
13
14
-type countServer struct {
15
- count int
16
-}
+func TestIsPrivateIP(t *testing.T) {
+ tests := []struct {
+ ip string
17
+ expected bool
18
+ }{
19
+ {"216.58.194.206", false},
20
+ {"127.0.0.1", true},
21
+ {"10.0.0.1", true},
22
+ {"192.168.0.1", true},
23
+ {"172.16.0.0", true},
24
+ {"169.254.169.254", true},
25
+ }
26
-func (c *countServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
27
+ for _, tt := range tests {
28
+ ip := net.ParseIP(tt.ip)
29
+ assert.Equal(t, tt.expected, isPrivateIP(ip))
30
31
}
32
33
func TestSafeHTTPClient(t *testing.T) {
0 commit comments