Skip to content

Commit a61a5d5

Browse files
author
Jozef Reisinger
committed
add more tests
1 parent f10b11d commit a61a5d5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

checkip_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,36 @@ func TestRun(t *testing.T) {
2727
t.Fatalf("%s considered suspiscious by %d info checkers", test.ip, got)
2828
}
2929
}
30+
31+
// checkers can tell you wether the IP address is suspicious.
32+
checkers := []Checker{
33+
&AbuseIPDB{},
34+
&CINSArmy{},
35+
&ET{},
36+
&OTX{},
37+
&IPsum{},
38+
&Shodan{},
39+
&ThreatCrowd{},
40+
&VirusTotal{},
41+
}
42+
43+
checkers = append(checkers, infoCheckers...)
44+
45+
tests = []struct {
46+
ip string
47+
suspicious int
48+
}{
49+
{"1.1.1.1", 1},
50+
{"1.1.1.2", 0},
51+
{"8.8.8.8", 0},
52+
{"8.8.4.4", 2},
53+
}
54+
55+
for _, test := range tests {
56+
ipaddr := net.ParseIP(test.ip)
57+
got := Run(checkers, ipaddr)
58+
if got != test.suspicious {
59+
t.Fatalf("%s considered suspiscious by %d info checkers", test.ip, got)
60+
}
61+
}
3062
}

0 commit comments

Comments
 (0)