mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 18:53:13 -05:00 
			
		
		
		
	* tests: CoreDNSServerAndPorts Copy from kubernetes.go and renamed to fit the style, adapted almost all callers. This is a mechanicl change, no testdata was changed. * typos
		
			
				
	
	
		
			43 lines
		
	
	
		
			931 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			931 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package test
 | 
						|
 | 
						|
import (
 | 
						|
	"io/ioutil"
 | 
						|
	"log"
 | 
						|
	"testing"
 | 
						|
 | 
						|
	"github.com/coredns/coredns/middleware/proxy"
 | 
						|
	"github.com/coredns/coredns/middleware/test"
 | 
						|
	"github.com/coredns/coredns/request"
 | 
						|
 | 
						|
	"github.com/miekg/dns"
 | 
						|
)
 | 
						|
 | 
						|
func TestEmptySecondaryZone(t *testing.T) {
 | 
						|
	// Corefile that fails to transfer example.org.
 | 
						|
	corefile := `example.org:0 {
 | 
						|
		secondary {
 | 
						|
			transfer from 127.0.0.1:1717
 | 
						|
		}
 | 
						|
	}
 | 
						|
`
 | 
						|
 | 
						|
	i, udp, _, err := CoreDNSServerAndPorts(corefile)
 | 
						|
	if err != nil {
 | 
						|
		t.Fatalf("Could not get CoreDNS serving instance: %s", err)
 | 
						|
	}
 | 
						|
	defer i.Stop()
 | 
						|
 | 
						|
	log.SetOutput(ioutil.Discard)
 | 
						|
 | 
						|
	p := proxy.NewLookup([]string{udp})
 | 
						|
	state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)}
 | 
						|
 | 
						|
	resp, err := p.Lookup(state, "www.example.org.", dns.TypeA)
 | 
						|
	if err != nil {
 | 
						|
		t.Fatal("Expected to receive reply, but didn't")
 | 
						|
	}
 | 
						|
	if resp.Rcode != dns.RcodeServerFailure {
 | 
						|
		t.Fatalf("Expected reply to be a SERVFAIL, got %d", resp.Rcode)
 | 
						|
	}
 | 
						|
}
 |