aboutsummaryrefslogtreecommitdiff
path: root/test/edns0_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/edns0_test.go')
-rw-r--r--test/edns0_test.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/edns0_test.go b/test/edns0_test.go
new file mode 100644
index 000000000..6cb1af958
--- /dev/null
+++ b/test/edns0_test.go
@@ -0,0 +1,33 @@
+package test
+
+import (
+ "testing"
+
+ "github.com/miekg/dns"
+)
+
+func TestEDNS0(t *testing.T) {
+ corefile := `.:0 {
+ whoami
+}
+`
+
+ i, udp, _, err := CoreDNSServerAndPorts(corefile)
+ if err != nil {
+ t.Fatalf("Could not get CoreDNS serving instance: %s", err)
+ }
+ defer i.Stop()
+
+ m := new(dns.Msg)
+ m.SetQuestion("example.org.", dns.TypeSOA)
+ m.SetEdns0(4096, true)
+
+ resp, err := dns.Exchange(m, udp)
+ if err != nil {
+ t.Fatalf("Expected to receive reply, but didn't: %v", err)
+ }
+ opt := resp.Extra[len(resp.Extra)-1]
+ if opt.Header().Rrtype != dns.TypeOPT {
+ t.Errorf("Last RR must be OPT record")
+ }
+}