-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
dns_sec_test.go
69 lines (58 loc) · 1.88 KB
/
dns_sec_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
62
63
64
65
66
67
68
69
package paymail
import (
"fmt"
"testing"
)
// TestClient_CheckDNSSEC will test the method CheckDNSSEC()
func TestClient_CheckDNSSEC(t *testing.T) {
// t.Parallel() (turned off - race condition)
// Integration test (requires internet connection)
if testing.Short() {
t.Skip("skipping integration testing in short mode")
}
client := newTestClient(t)
var tests = []struct {
host string
expectedError bool
}{
{"", true},
{"---", true},
{"---.---", true},
{"*.---", true},
{"moneybutton", true},
{"asdfadfasdfasdfasdf10909.com", true},
{"google.com", false},
// {"relayx.io", false}, // Disabled for timeout issues
{"cloudflare.com", false},
{"mrz1836.com", false},
{"handcash-cloud-production.herokuapp.com", true},
}
for _, test := range tests {
if result := client.CheckDNSSEC(test.host); len(result.ErrorMessage) > 0 && !test.expectedError {
t.Errorf("%s Failed: [%s] inputted and error not expected but got: %s", t.Name(), test.host, result.ErrorMessage)
} else if len(result.ErrorMessage) == 0 && test.expectedError {
t.Errorf("%s Failed: [%s] inputted and error was expected", t.Name(), test.host)
}
}
// todo: test results, test using mock interfaces for DNS resolving
}
// ExampleClient_CheckDNSSEC example using CheckDNSSEC()
//
// See more examples in /examples/
func ExampleClient_CheckDNSSEC() {
client, _ := NewClient()
results := client.CheckDNSSEC("google.com")
if len(results.ErrorMessage) == 0 {
fmt.Printf("valid DNSSEC found for: %s", "google.com")
} else {
fmt.Printf("invalid DNSSEC found for: %s error: %s", "google.com", results.ErrorMessage)
}
// Output:valid DNSSEC found for: google.com
}
// BenchmarkClient_CheckDNSSEC benchmarks the method CheckDNSSEC()
func BenchmarkClient_CheckDNSSEC(b *testing.B) {
client, _ := NewClient(nil, nil, nil)
for i := 0; i < b.N; i++ {
_ = client.CheckDNSSEC("google.com")
}
}