forked from projectdiscovery/cdncheck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcdncheck_test.go
More file actions
32 lines (25 loc) · 1.15 KB
/
cdncheck_test.go
File metadata and controls
32 lines (25 loc) · 1.15 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
package cdncheck
import (
"net"
"testing"
"github.com/stretchr/testify/require"
)
func TestCDNCheckValid(t *testing.T) {
client := New()
found, provider, itemType, err := client.Check(net.ParseIP("2400:cb00::1"))
require.Equal(t, "cloudflare", provider, "could not get correct provider")
require.Equal(t, "waf", itemType, "could not get correct item type")
require.Nil(t, err, "Could not check ip in ranger")
require.True(t, found, "Could not check cloudlfare ip blacklist")
found, provider, itemType, err = client.Check(net.ParseIP("173.245.48.12"))
require.Equal(t, "cloudflare", provider, "could not get correct provider")
require.Equal(t, "waf", itemType, "could not get correct item type")
require.Nil(t, err, "Could not check ip in ranger")
require.True(t, found, "Could not check cloudlfare ip blacklist")
found, _, _, err = client.Check(net.ParseIP("::1"))
require.Nil(t, err, "Could not check ip in ranger")
require.False(t, found, "Localhost IP found in blacklist")
found, _, _, err = client.Check(net.ParseIP("127.0.0.1"))
require.Nil(t, err, "Could not check ip in ranger")
require.False(t, found, "Localhost IP found in blacklist")
}