From 84c84a097eb405f6e539284273bc7375949da339 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 5 Nov 2024 15:31:07 +0100 Subject: [PATCH] Add test --- pdns/recursordist/test-syncres_cc1.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pdns/recursordist/test-syncres_cc1.cc b/pdns/recursordist/test-syncres_cc1.cc index 86278fbe64..d51953fd2f 100644 --- a/pdns/recursordist/test-syncres_cc1.cc +++ b/pdns/recursordist/test-syncres_cc1.cc @@ -1772,17 +1772,26 @@ BOOST_AUTO_TEST_CASE(test_cname_length) BOOST_CHECK_EQUAL(ret.size(), length); BOOST_CHECK_EQUAL(length, SyncRes::s_max_CNAMES_followed + 1); - // Currently a CNAME bounds check originating from the record cache causes an ImmediateServFail - // exception. This is different from the non-cached case, tested above. There a ServFail is - // returned with a partial CNAME chain. This should be fixed one way or another. For details, see - // how the result of syncres.cc:scanForCNAMELoop() is handled in the two cases. + // The CNAME bounds check originating from the record cache causes an ImmediateServFail + // exception. This is different from the non-cached case, tested above. ret.clear(); - length = 0; BOOST_CHECK_EXCEPTION(sr->beginResolve(target, QType(QType::A), QClass::IN, ret), ImmediateServFailException, [&](const ImmediateServFailException& isfe) { return isfe.reason == "max number of CNAMEs exceeded"; }); + BOOST_CHECK_EQUAL(ret.size(), SyncRes::s_max_CNAMES_followed + 1); + + // Again, now with QName Minimization on, originally this would fail as the result was collected + // in a temp vector and the throw would skip the copy of the temp vector into the end result + sr->setQNameMinimization(); + ret.clear(); + BOOST_CHECK_EXCEPTION(sr->beginResolve(target, QType(QType::A), QClass::IN, ret), + ImmediateServFailException, + [&](const ImmediateServFailException& isfe) { + return isfe.reason == "max number of CNAMEs exceeded"; + }); + BOOST_CHECK_EQUAL(ret.size(), SyncRes::s_max_CNAMES_followed + 1); } BOOST_AUTO_TEST_CASE(test_cname_target_servfail) -- 2.47.2