diff options
author | 2016-10-28 07:50:16 +0100 | |
---|---|---|
committer | 2016-10-28 07:50:16 +0100 | |
commit | ba26f47d5c65295342402d2c9996eb74884935e0 (patch) | |
tree | f401e63018e4262b5cb7e3b8a8a59555b48721b6 /middleware/cache/cache_test.go | |
parent | 039596f319c40622293f883317c9d35d7bb79e0c (diff) | |
download | coredns-ba26f47d5c65295342402d2c9996eb74884935e0.tar.gz coredns-ba26f47d5c65295342402d2c9996eb74884935e0.tar.zst coredns-ba26f47d5c65295342402d2c9996eb74884935e0.zip |
middleware/caching (#360)
Add the rcode to the cached item and use this when we synthesize the
answer again. We could also infer the rcode from the reassembled
message, but this seems easier and is only an integer.
Also set the autoritative bit to 0 for all from-cache answers.
Fixes 357
Diffstat (limited to 'middleware/cache/cache_test.go')
-rw-r--r-- | middleware/cache/cache_test.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/middleware/cache/cache_test.go b/middleware/cache/cache_test.go index 7e80c66e0..31aeaa8ac 100644 --- a/middleware/cache/cache_test.go +++ b/middleware/cache/cache_test.go @@ -1,6 +1,8 @@ package cache import ( + "io/ioutil" + "log" "testing" "time" @@ -64,12 +66,30 @@ var cacheTestCases = []cacheTestCase{ }, in: test.Case{}, }, + { + RecursionAvailable: true, Authoritative: true, + Case: test.Case{ + Rcode: dns.RcodeNameError, + Qname: "example.org.", Qtype: dns.TypeA, + Ns: []dns.RR{ + test.SOA("example.org. 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082540 7200 3600 1209600 3600"), + }, + }, + in: test.Case{ + Rcode: dns.RcodeNameError, + Qname: "example.org.", Qtype: dns.TypeA, + Ns: []dns.RR{ + test.SOA("example.org. 3600 IN SOA sns.dns.icann.org. noc.dns.icann.org. 2016082540 7200 3600 1209600 3600"), + }, + }, + }, } func cacheMsg(m *dns.Msg, tc cacheTestCase) *dns.Msg { m.RecursionAvailable = tc.RecursionAvailable m.AuthenticatedData = tc.AuthenticatedData m.Authoritative = tc.Authoritative + m.Rcode = tc.Rcode m.Truncated = tc.Truncated m.Answer = tc.in.Answer m.Ns = tc.in.Ns @@ -89,6 +109,8 @@ func newTestCache(ttl time.Duration) (*Cache, *ResponseWriter) { func TestCache(t *testing.T) { c, crr := newTestCache(maxTTL) + log.SetOutput(ioutil.Discard) + for _, tc := range cacheTestCases { m := tc.in.Msg() m = cacheMsg(m, tc) |