Commit de4b10ee authored by JINMEI Tatuya's avatar JINMEI Tatuya

[1607] make sure ignoring irrelevant cases.

getAdditional() is now non virtual function and implements the common code
check.  the actual processing is delegated to a protected virtual function.
parent 9a5e82f8
;; test zone file used for ZoneFinderContext tests.
;; RRSIGs are (obviouslly) faked ones for testing.
example.org. 3600 IN SOA ns1.example.org. bugs.x.w.example.org. 20 3600 300 3600000 3600
example.org. 3600 IN SOA ns1.example.org. bugs.x.w.example.org. 22 3600 300 3600000 3600
example.org. 3600 IN NS ns1.example.org.
example.org. 3600 IN NS ns2.example.org.
example.org. 3600 IN MX 1 mx1.example.org.
......@@ -27,3 +27,9 @@ ns1.a.example.org. 3600 IN A 192.0.2.5
ns2.a.example.org. 3600 IN A 192.0.2.6
ns2.a.example.org. 3600 IN AAAA 2001:db8::6
mx.a.example.org. 3600 IN A 192.0.2.7
;; CNAME
alias.example.org. 3600 IN CNAME cname.example.org.
;; DNAME
dname.example.org. 3600 IN DNAME dname.example.com.
......@@ -256,4 +256,29 @@ TEST_P(ZoneFinderContextTest, getAdditionalWithSIG) {
sigresult_sets.begin(), sigresult_sets.end());
}
TEST_P(ZoneFinderContextTest, getAdditionalNoOP) {
// getAdditional() is only meaningful after SUCCESS or DELEGATION.
ZoneFinderContextPtr ctx = finder_->find(Name("nxdomain.example.org"),
RRType::NS());
EXPECT_EQ(ZoneFinder::NXDOMAIN, ctx->code);
ctx->getAdditional(REQUESTED_BOTH, result_sets_);
EXPECT_TRUE(result_sets_.empty());
ctx = finder_->find(qzone_, RRType::TXT());
EXPECT_EQ(ZoneFinder::NXRRSET, ctx->code);
ctx->getAdditional(REQUESTED_BOTH, result_sets_);
EXPECT_TRUE(result_sets_.empty());
ctx = finder_->find(Name("alias.example.org."), RRType::A());
EXPECT_EQ(ZoneFinder::CNAME, ctx->code);
ctx->getAdditional(REQUESTED_BOTH, result_sets_);
EXPECT_TRUE(result_sets_.empty());
ctx = finder_->find(Name("www.dname.example.org."), RRType::A());
EXPECT_EQ(ZoneFinder::DNAME, ctx->code);
ctx->getAdditional(REQUESTED_BOTH, result_sets_);
EXPECT_TRUE(result_sets_.empty());
}
}
......@@ -181,7 +181,21 @@ public:
return ((flags_ & RESULT_NSEC3_SIGNED) != 0);
}
virtual void getAdditional(
void getAdditional(
const std::vector<isc::dns::RRType>& requested_types,
std::vector<isc::dns::ConstRRsetPtr>& result)
{
// Perform common checks, and delegate the process the default
// or specialized implementation.
if (code != SUCCESS && code != DELEGATION) {
return;
}
getAdditionalImpl(requested_types, result);
}
protected:
virtual void getAdditionalImpl(
const std::vector<isc::dns::RRType>& requested_types,
std::vector<isc::dns::ConstRRsetPtr>& result);
......
......@@ -54,8 +54,8 @@ getAdditionalAddrs(ZoneFinder& finder, const Name& name,
}
void
ZoneFinder::Context::getAdditional(const vector<RRType>& requested_types,
vector<ConstRRsetPtr>& result)
ZoneFinder::Context::getAdditionalImpl(const vector<RRType>& requested_types,
vector<ConstRRsetPtr>& result)
{
RdataIteratorPtr rdata_iterator(rrset->getRdataIterator());
ZoneFinder::FindOptions options = ZoneFinder::FIND_DEFAULT;
......
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