Commit 6492f777 authored by Miek Gieben's avatar Miek Gieben Committed by GitHub

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: default avatarMiek Gieben <miek@miek.nl>
parent 93f63502
...@@ -42,12 +42,24 @@ func TestTypifyRRSIG(t *testing.T) { ...@@ -42,12 +42,24 @@ func TestTypifyRRSIG(t *testing.T) {
} }
m = delegationMsgRRSIGFail() m = delegationMsgRRSIGFail()
m = addOpt(m) m.Extra = append(m.Extra, test.OPT(4096, true))
if mt, _ := Typify(m, utc); mt != OtherError { if mt, _ := Typify(m, utc); mt != OtherError {
t.Errorf("Message is wrongly typified, expected OtherError, got %s", mt) 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 { func delegationMsg() *dns.Msg {
return &dns.Msg{ return &dns.Msg{
Ns: []dns.RR{ Ns: []dns.RR{
...@@ -77,8 +89,3 @@ func delegationMsgRRSIGFail() *dns.Msg { ...@@ -77,8 +89,3 @@ func delegationMsgRRSIGFail() *dns.Msg {
) )
return del return del
} }
func addOpt(m *dns.Msg) *dns.Msg {
m.Extra = append(m.Extra, test.OPT(4096, true))
return m
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment