aboutsummaryrefslogtreecommitdiff
path: root/test/server_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'test/server_test.go')
-rw-r--r--test/server_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/server_test.go b/test/server_test.go
index c58915ee7..54e44722d 100644
--- a/test/server_test.go
+++ b/test/server_test.go
@@ -1,7 +1,11 @@
package test
import (
+ "reflect"
"testing"
+ "unsafe"
+
+ "github.com/coredns/coredns/core/dnsserver"
"github.com/miekg/dns"
)
@@ -107,3 +111,30 @@ func TestReverseExpansion(t *testing.T) {
t.Errorf("Expected 0 RRs in additional section, got %d", len(r.Extra))
}
}
+
+func TestMultiZoneBlockConfigs(t *testing.T) {
+ corefile := `.:40000 .:40001 .:40002 {
+ debug
+ }`
+
+ server, err := CoreDNSServer(corefile)
+ defer server.Stop()
+
+ if err != nil {
+ t.Fatalf("Could not get CoreDNS serving instance: %s", err)
+ }
+
+ // unsafe reflection to read unexported fields "context" and "configs" within context
+ ctxVal := reflect.ValueOf(server).Elem().FieldByName("context")
+ ctxVal2 := reflect.NewAt(ctxVal.Type(), unsafe.Pointer(ctxVal.UnsafeAddr())).Elem()
+ configs := reflect.ValueOf(ctxVal2.Interface()).Elem().FieldByName("configs")
+ configs2 := reflect.NewAt(configs.Type(), unsafe.Pointer(configs.UnsafeAddr())).Elem()
+
+ for i := 0; i < 3; i++ {
+ v := configs2.Index(i)
+ config := v.Interface().(*dnsserver.Config)
+ if !config.Debug {
+ t.Fatalf("Debug was not set for %s://%s:%s", config.Transport, config.Zone, config.Port)
+ }
+ }
+}