diff options
author | 2020-09-28 16:53:00 +0200 | |
---|---|---|
committer | 2020-09-28 07:53:00 -0700 | |
commit | 35b40a84f212223b6da8bae103471f67e3eedac5 (patch) | |
tree | 9b9773c21cd214c37dce3936e9ff20ca0186713d /plugin/cache/cache_test.go | |
parent | 1a1ce9a9c8eadd0e6154dd473a6e22b1f9e37ca2 (diff) | |
download | coredns-35b40a84f212223b6da8bae103471f67e3eedac5.tar.gz coredns-35b40a84f212223b6da8bae103471f67e3eedac5.tar.zst coredns-35b40a84f212223b6da8bae103471f67e3eedac5.zip |
plugin/cache: Fix filtering (#4148)
The filtering of DNSSEC records in the cache plugin was not done
correctly. Also the change to introduced this bug didn't take into
account that the cache - by virtue of differentiating between DNSSEC and
no-DNSSEC - relied on not copying the data from the cache.
This change copies and then filters the data and factors the filtering
into a function that is used in two places (albeit with on ugly boolean
parameters to prevent copying things twice).
Add tests, do_test.go is moved to test/cache_test.go because the OPT
handing is done outside of the cache plugin. The core server re-attaches
the correct OPT when replying, so that makes for a better e2e test.
Added small unit test for filterRRslice and an explicit test that asks
for DNSSEC first and then plain, and vice versa to test cache behavior.
Fixes: #4146
Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/cache/cache_test.go')
-rw-r--r-- | plugin/cache/cache_test.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/plugin/cache/cache_test.go b/plugin/cache/cache_test.go index 717276e66..9417a59f6 100644 --- a/plugin/cache/cache_test.go +++ b/plugin/cache/cache_test.go @@ -216,13 +216,13 @@ func TestCache(t *testing.T) { resp := i.toMsg(m, time.Now().UTC(), state.Do()) if err := test.Header(tc.Case, resp); err != nil { - t.Logf("Bla %v", resp) + t.Logf("Cache %v", resp) t.Error(err) continue } if err := test.Section(tc.Case, test.Answer, resp.Answer); err != nil { - t.Logf("Bla %v -- %v", test.Answer, resp.Answer) + t.Logf("Cache %v -- %v", test.Answer, resp.Answer) t.Error(err) } if err := test.Section(tc.Case, test.Ns, resp.Ns); err != nil { |