diff options
author | 2019-03-26 14:36:20 +0000 | |
---|---|---|
committer | 2019-03-26 14:36:20 +0000 | |
commit | 6492f777cdbaa75f1bdfc90c62a1b2b2e041501c (patch) | |
tree | 1b1f6ead652552ff68efcd4b57097c8d67d1385a | |
parent | 93f635023a7515087bb92d542f059d29a4d7c711 (diff) | |
download | coredns-6492f777cdbaa75f1bdfc90c62a1b2b2e041501c.tar.gz coredns-6492f777cdbaa75f1bdfc90c62a1b2b2e041501c.tar.zst coredns-6492f777cdbaa75f1bdfc90c62a1b2b2e041501c.zip |
pkg/response: add extra test for impossible msg (#2727)
Add another test case for impossible DNS messages which should not be
cached. This adds a check for a message that denies its own existence.
Fixes #2724.
Signed-off-by: Miek Gieben <miek@miek.nl>
-rw-r--r-- | plugin/pkg/response/typify_test.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/plugin/pkg/response/typify_test.go b/plugin/pkg/response/typify_test.go index 6be9aa8ff..f22b806fb 100644 --- a/plugin/pkg/response/typify_test.go +++ b/plugin/pkg/response/typify_test.go @@ -42,12 +42,24 @@ func TestTypifyRRSIG(t *testing.T) { } m = delegationMsgRRSIGFail() - m = addOpt(m) + m.Extra = append(m.Extra, test.OPT(4096, true)) if mt, _ := Typify(m, utc); mt != OtherError { t.Errorf("Message is wrongly typified, expected OtherError, got %s", mt) } } +func TestTypifyImpossible(t *testing.T) { + // create impossible message that denies it's own existence + m := new(dns.Msg) + m.SetQuestion("bar.www.example.org.", dns.TypeAAAA) + m.Rcode = dns.RcodeNameError // name does not exist + m.Answer = []dns.RR{test.CNAME("bar.www.example.org. IN CNAME foo.example.org.")} // but we add a cname with the name! + mt, _ := Typify(m, time.Now().UTC()) + if mt != OtherError { + t.Errorf("Impossible message not typified as OtherError, got %s", mt) + } +} + func delegationMsg() *dns.Msg { return &dns.Msg{ Ns: []dns.RR{ @@ -77,8 +89,3 @@ func delegationMsgRRSIGFail() *dns.Msg { ) return del } - -func addOpt(m *dns.Msg) *dns.Msg { - m.Extra = append(m.Extra, test.OPT(4096, true)) - return m -} |