diff options
author | 2017-03-14 21:32:21 +0000 | |
---|---|---|
committer | 2017-03-14 21:32:21 +0000 | |
commit | 5ac6020f45786d937ba754a61ed63f86ad4f7d0d (patch) | |
tree | e8db50a06c4250f547f5389fb15ff13186bac834 /test | |
parent | 5b32a07ae66b352869a685823ba2961b7e03db08 (diff) | |
download | coredns-5ac6020f45786d937ba754a61ed63f86ad4f7d0d.tar.gz coredns-5ac6020f45786d937ba754a61ed63f86ad4f7d0d.tar.zst coredns-5ac6020f45786d937ba754a61ed63f86ad4f7d0d.zip |
Pr 586 tweaks (#594)
* add proxy tcp
* add truncated for tcp to udp response
* move truncation to scrubbing
* add test that executes upstream over tcp
* middleware/proxy: some tweaks
rename force-tcp to force_tcp to be inline with the rest and use
a dnsOptions struct to put the options in to allow it to be extended.
Add some parse tests as well.
* Fix test and rename dnsOptions Options
Diffstat (limited to 'test')
-rw-r--r-- | test/proxy_test.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/proxy_test.go b/test/proxy_test.go index cb9f1b298..7e85a0c87 100644 --- a/test/proxy_test.go +++ b/test/proxy_test.go @@ -56,6 +56,50 @@ func TestLookupProxy(t *testing.T) { } } +func TestLookupDnsWithForcedTcp(t *testing.T) { + t.Parallel() + name, rm, err := test.TempFile(".", exampleOrg) + if err != nil { + t.Fatalf("failed to create zone: %s", err) + } + defer rm() + + corefile := `example.org:0 { + file ` + name + ` +} +` + + i, err := CoreDNSServer(corefile) + if err != nil { + t.Fatalf("Could not get CoreDNS serving instance: %s", err) + } + + _, tcp := CoreDNSServerPorts(i, 0) + if tcp == "" { + t.Fatalf("Could not get TCP listening port") + } + defer i.Stop() + + log.SetOutput(ioutil.Discard) + + p := proxy.NewLookupWithOption([]string{tcp}, proxy.Options{ForceTCP: true}) + state := request.Request{W: &test.ResponseWriter{}, Req: new(dns.Msg)} + resp, err := p.Lookup(state, "example.org.", dns.TypeA) + if err != nil { + t.Fatal("Expected to receive reply, but didn't") + } + // expect answer section with A record in it + if len(resp.Answer) == 0 { + t.Fatalf("Expected to at least one RR in the answer section, got none: %s", resp) + } + if resp.Answer[0].Header().Rrtype != dns.TypeA { + t.Errorf("Expected RR to A, got: %d", resp.Answer[0].Header().Rrtype) + } + if resp.Answer[0].(*dns.A).A.String() != "127.0.0.1" { + t.Errorf("Expected 127.0.0.1, got: %s", resp.Answer[0].(*dns.A).A.String()) + } +} + func BenchmarkLookupProxy(b *testing.B) { t := new(testing.T) name, rm, err := test.TempFile(".", exampleOrg) |