-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgodnsbl_test.go
61 lines (45 loc) · 1.44 KB
/
godnsbl_test.go
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
61
package godnsbl
import (
"testing"
"sync"
)
func TestGetDnsblRespFunc(t *testing.T) {
var wg sync.WaitGroup
var resp DnsblReturn
wg.Add(1)
go getDnsblResp(&wg, &resp, getFlipIP("127.0.0.2"), "b.barracudacentral.org")
wg.Wait()
if len(resp.Responses) != 1{
t.Errorf("Expected length of responses to be 1, got: %d", len(resp.Responses))
}
if resp.Responses[0].Status != "ok"{
t.Errorf("Expected status to be ok, got : %s", resp.Responses[0].Status)
}
if resp.Responses[0].Msg != ""{
t.Errorf("No message expected, got : %s", resp.Responses[0].Msg)
}
if resp.Responses[0].Listed != true{
t.Errorf("Expected blacklist to be true, got : %s", resp.Responses[0].Listed)
}
if resp.Responses[0].Name != "b.barracudacentral.org"{
t.Errorf("Expected name to be b.barracudacentral.org, got : %s", resp.Responses[0].Name)
}
if resp.Responses[0].RespTime == 0{
t.Errorf("Response time should not be zero")
}
if resp.Responses[0].Resp != "127.0.0.2"{
t.Errorf("Resp should be 127.0.0.2, got: %s", resp.Responses[0].Resp)
}
}
func TestCheckBlacklistFunc(t *testing.T) {
resp := CheckBlacklist("127.0.0.2")
if resp.Listed != true{
t.Errorf("Expected blacklist to be true, got : %s", resp.Listed)
}
}
func TestGetflipIPFunc(t *testing.T) {
flipped := getFlipIP("10.11.12.13")
if flipped != "13.12.11.10"{
t.Errorf("IP did not flip properly, expecting 13.12.11.10 got: %s", flipped)
}
}