| 
									
										
										
										
											2017-06-01 12:33:40 +01:00
										 |  |  | package test | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"io/ioutil" | 
					
						
							|  |  |  | 	"log" | 
					
						
							|  |  |  | 	"testing" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-14 09:36:06 +01:00
										 |  |  | 	"github.com/coredns/coredns/plugin/proxy" | 
					
						
							|  |  |  | 	"github.com/coredns/coredns/plugin/test" | 
					
						
							| 
									
										
										
										
											2017-06-01 12:33:40 +01:00
										 |  |  | 	"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 | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | ` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-24 11:35:14 +01:00
										 |  |  | 	i, udp, _, err := CoreDNSServerAndPorts(corefile) | 
					
						
							| 
									
										
										
										
											2017-06-01 12:33:40 +01:00
										 |  |  | 	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) | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } |