-
Notifications
You must be signed in to change notification settings - Fork 7
/
dns_test.go
51 lines (43 loc) · 1.11 KB
/
dns_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
package dane
/*
* Note: these test routines may not work unless you adapt this file
* to use validating DNS resolvers and appropriately configured DANE TLS
* servers you have access to.
*/
import (
"testing"
"github.com/miekg/dns"
)
var hostname = "www.example.com"
func TestSendQueryUDP(t *testing.T) {
query := NewQuery(hostname, dns.TypeA, dns.ClassINET)
msg, err := sendQueryUDP(query, resolver1)
if err != nil {
t.Fatalf("SendQueryUDP error: %s\n", err.Error())
}
_ = msg
}
func TestSendQueryTCP(t *testing.T) {
query := NewQuery(hostname, dns.TypeA, dns.ClassINET)
msg, err := sendQueryTCP(query, resolver1)
if err != nil {
t.Fatalf("SendQueryTCP error: %s\n", err.Error())
}
_ = msg
}
func TestGetAddresses(t *testing.T) {
iplist, err := GetAddresses(resolver1, hostname, true)
if err != nil {
t.Fatalf("GetAddresses error: %s\n", err.Error())
}
if len(iplist) == 0 {
t.Fatalf("GetAddresses: no addresses found for %s\n", hostname)
}
}
func TestGetTLSA(t *testing.T) {
tlsa, err := GetTLSA(resolver1, hostname, 443)
if err != nil {
t.Fatalf("GetTLSA error: %s\n", err.Error())
}
_ = tlsa
}