Also adjust tests.
# them as separate RRs.
dummy_record = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.NS(),
RRTTL(0))
- dummy_record.add_rdata(Rdata(RRType.NS(), TEST_RRCLASS, "ns.example"))
+ dummy_record.add_rdata(Rdata(RRType.NS(), TEST_RRCLASS, "ns.example."))
self.server.handle_request((self.__sock, TEST_SERVER6, TEST_CLIENT6,
create_msg(prereq=[dummy_record,
dummy_record])))
self.ns_rrset = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.NS(),
RRTTL(3600))
self.ns_rrset.add_rdata(Rdata(RRType.NS(), TEST_RRCLASS,
- 'ns.example.com'))
+ 'ns.example.com.'))
self.a_rrset = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.A(),
RRTTL(3600))
self.a_rrset.add_rdata(Rdata(RRType.A(), TEST_RRCLASS, '192.0.2.1'))
def test_soacheck_referral_response(self):
self.conn.response_generator = self._create_soa_response_data
self.soa_response_params['answers'] = []
- self.soa_response_params['authorities'] = [create_ns('ns.example.com')]
+ self.soa_response_params['authorities'] = [create_ns('ns.example.com.')]
self.assertRaises(XfrinProtocolError, self.conn._check_soa_serial)
def test_soacheck_nodata_response(self):
self.xfrsess._request_data = self.mdata
self.xfrsess._server.get_db_file = lambda : TESTDATA_SRCDIR + \
'test.sqlite3'
- self.ns_name = 'a.dns.example.com'
+ self.ns_name = 'a.dns.example.com.'
def check_axfr_stream(self, response):
'''Common checks for AXFR(-style) response for the test zone.
// It should normally just result in DELEGATION; if GLUE_OK is specified,
// the other RR should be visible.
this->expected_rdatas_.clear();
- this->expected_rdatas_.push_back("ns.example.com");
+ this->expected_rdatas_.push_back("ns.example.com.");
doFindTest(*finder, Name("brokenns1.example.org"), this->qtype_,
RRType::NS(), this->rrttl_, ZoneFinder::DELEGATION,
this->expected_rdatas_, this->empty_rdatas_,
// Some insane case: DS under a zone cut. It's included in the DB, but
// shouldn't be visible via finder.
this->expected_rdatas_.clear();
- this->expected_rdatas_.push_back("ns.example.com");
+ this->expected_rdatas_.push_back("ns.example.com.");
doFindTest(*finder, Name("child.insecdelegation.example.org"),
RRType::DS(), RRType::NS(), this->rrttl_,
ZoneFinder::DELEGATION, this->expected_rdatas_,
// Likewise. Inconsistent name compression policy.
const ConstRdataPtr ns_rdata =
- createRdata(RRType::NS(), RRClass::IN(), "ns.example");
+ createRdata(RRType::NS(), RRClass::IN(), "ns.example.");
encoder_.start(RRClass::IN(), RRType::DNAME());
EXPECT_THROW(encoder_.addRdata(*ns_rdata), isc::BadValue);
{"example.org. 300 IN A 192.0.2.1", &rr_a_},
{"ns.example.org. 300 IN A 192.0.2.2", &rr_ns_a_},
// This one will place rr_ns_a_ at a zone cut, making it a glue:
- {"ns.example.org. 300 IN NS 192.0.2.2", &rr_ns_ns_},
+ {"ns.example.org. 300 IN NS 192.0.2.2.", &rr_ns_ns_},
{"ns.example.org. 300 IN AAAA 2001:db8::2", &rr_ns_aaaa_},
{"cname.example.org. 300 IN CNAME canonical.example.org",
&rr_cname_},
def test_add_rdata(self):
# no iterator to read out yet (TODO: add addition test once implemented)
- self.assertRaises(TypeError, self.rrset_a.add_rdata, Rdata(RRType("NS"), RRClass("IN"), "test.name"))
+ self.assertRaises(TypeError, self.rrset_a.add_rdata, Rdata(RRType("NS"), RRClass("IN"), "test.name."))
pass
def test_to_text(self):
ns = RRset(Name('example'), RRClass.IN(), rrtype,
RRTTL(0))
ns.add_rdata(Rdata(RRType.NS(), RRClass.IN(),
- 'example.org'))
+ 'example.org.'))
return ns
return None
// BEGIN_RDATA_NAMESPACE
NS::NS(const std::string& namestr) :
- nsname_(namestr)
-{}
+ // Fill in dummy name and replace them soon below.
+ nsname_(Name::ROOT_NAME())
+{
+ try {
+ std::istringstream ss(namestr);
+ MasterLexer lexer;
+ lexer.pushSource(ss);
+
+ nsname_ = createNameFromLexer(lexer, NULL);
+
+ if (lexer.getNextToken().getType() != MasterToken::END_OF_FILE) {
+ isc_throw(InvalidRdataText, "extra input text for NS: "
+ << namestr);
+ }
+ } catch (const MasterLexer::LexerError& ex) {
+ isc_throw(InvalidRdataText, "Failed to construct NS from '" <<
+ namestr << "': " << ex.what());
+ }
+}
NS::NS(InputBuffer& buffer, size_t) :
nsname_(buffer)
// there's nothing to specialize
};
-const generic::NS rdata_ns("ns.example.com");
-const generic::NS rdata_ns2("ns2.example.com");
+const generic::NS rdata_ns("ns.example.com.");
+const generic::NS rdata_ns2("ns2.example.com.");
const uint8_t wiredata_ns[] = {
0x02, 0x6e, 0x73, 0x07, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x03,
0x63, 0x6f, 0x6d, 0x00 };
0x03, 0x6e, 0x73, 0x32, 0xc0, 0x03 };
TEST_F(Rdata_NS_Test, createFromText) {
- EXPECT_EQ(0, rdata_ns.compare(generic::NS("ns.example.com")));
+ EXPECT_EQ(0, rdata_ns.compare(generic::NS("ns.example.com.")));
// explicitly add a trailing dot. should be the same RDATA.
EXPECT_EQ(0, rdata_ns.compare(generic::NS("ns.example.com.")));
// should be case sensitive.
- EXPECT_EQ(0, rdata_ns.compare(generic::NS("NS.EXAMPLE.COM")));
+ EXPECT_EQ(0, rdata_ns.compare(generic::NS("NS.EXAMPLE.COM.")));
// RDATA of a class-independent type should be recognized for any
// "unknown" class.
EXPECT_EQ(0, rdata_ns.compare(*createRdata(RRType("NS"), RRClass(65000),
- "ns.example.com")));
+ "ns.example.com.")));
}
TEST_F(Rdata_NS_Test, createFromWire) {
"rdata_ns_fromWire", 71),
DNSMessageFORMERR);
- EXPECT_EQ(0, generic::NS("ns2.example.com").compare(
+ EXPECT_EQ(0, generic::NS("ns2.example.com.").compare(
*rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
"rdata_ns_fromWire", 55)));
EXPECT_THROW(*rdataFactoryFromFile(RRType("NS"), RRClass("IN"),
}
TEST_F(Rdata_NS_Test, compare) {
- generic::NS small("a.example");
- generic::NS large("example");
+ generic::NS small("a.example.");
+ generic::NS large("example.");
EXPECT_TRUE(Name("a.example") > Name("example"));
EXPECT_GT(0, small.compare(large));
}
TEST_F(Rdata_NS_Test, getNSName) {
- EXPECT_EQ(Name("ns.example.com"), rdata_ns.getNSName());
+ EXPECT_EQ(Name("ns.example.com."), rdata_ns.getNSName());
}
}
// Pointer version of addRdata() doesn't type check and does allow to
//add a different type of Rdata as a result.
rrset_a_empty.addRdata(createRdata(RRType::NS(), RRClass::IN(),
- "ns.example.com"));
+ "ns.example.com."));
EXPECT_EQ(3, rrset_a_empty.getRdataCount());
}
// Likewise, if the SOA RRset contains non SOA Rdata, it should be a bug.
rrsets_->removeRRset(zname_, zclass_, RRType::SOA());
soa_.reset(new RRset(zname_, zclass_, RRType::SOA(), RRTTL(60)));
- soa_->addRdata(createRdata(RRType::NS(), zclass_, "ns.example.com"));
+ soa_->addRdata(createRdata(RRType::NS(), zclass_, "ns.example.com."));
rrsets_->addRRset(soa_);
EXPECT_THROW(checkZone(zname_, zclass_, *rrsets_, callbacks_), Unexpected);
checkIssues(); // no error/warning should be reported
rrsets_->removeRRset(ns_name, zclass_, RRType::CNAME());
rrsets_->removeRRset(zname_, zclass_, RRType::NS());
ns_.reset(new RRset(zname_, zclass_, RRType::NS(), RRTTL(60)));
- ns_->addRdata(generic::NS("ns.example.org"));
+ ns_->addRdata(generic::NS("ns.example.org."));
rrsets_->addRRset(ns_);
EXPECT_TRUE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
checkIssues();
rrsets_->addRRset(ns_);
RRsetPtr child_ns(new RRset(Name("child.example.com"), zclass_,
RRType::NS(), RRTTL(60)));
- child_ns->addRdata(generic::NS("ns.example.org"));
+ child_ns->addRdata(generic::NS("ns.example.org."));
rrsets_->addRRset(child_ns);
EXPECT_TRUE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
checkIssues();
// Zone cut at the NS name. Same result.
rrsets_->removeRRset(child_ns->getName(), zclass_, RRType::NS());
child_ns.reset(new RRset(ns_name, zclass_, RRType::NS(), RRTTL(60)));
- child_ns->addRdata(generic::NS("ns.example.org"));
+ child_ns->addRdata(generic::NS("ns.example.org."));
rrsets_->addRRset(child_ns);
EXPECT_TRUE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
checkIssues();
rrsets_->removeRRset(child_ns->getName(), zclass_, RRType::NS());
child_ns.reset(new RRset(Name("another.ns.child.example.com"), zclass_,
RRType::NS(), RRTTL(60)));
- child_ns->addRdata(generic::NS("ns.example.org"));
+ child_ns->addRdata(generic::NS("ns.example.org."));
rrsets_->addRRset(child_ns);
EXPECT_TRUE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
expected_warns_.push_back("zone example.com/IN: NS has no address");
// this implementation prefers the NS and skips further checks.
ns_.reset(new RRset(Name("child.example.com"), zclass_, RRType::NS(),
RRTTL(60)));
- ns_->addRdata(generic::NS("ns.example.org"));
+ ns_->addRdata(generic::NS("ns.example.org."));
rrsets_->addRRset(ns_);
EXPECT_TRUE(checkZone(zname_, zclass_, *rrsets_, callbacks_));
checkIssues();
// But we do not answer it right away. We create a new zone and
// let this nameserver entry get out.
- rrns_->addRdata(rdata::generic::NS("example.cz"));
+ rrns_->addRdata(rdata::generic::NS("example.cz."));
nsas.lookupAndAnswer(EXAMPLE_CO_UK, RRClass::IN(), rrns_, getCallback());
// It really should ask something, one of the nameservers
rrch_->addRdata(ConstRdataPtr(new RdataTest<A>("1324")));
// NS records take a single name
- rrns_->addRdata(rdata::generic::NS("example.fr"));
- rrns_->addRdata(rdata::generic::NS("example.de"));
+ rrns_->addRdata(rdata::generic::NS("example.fr."));
+ rrns_->addRdata(rdata::generic::NS("example.de."));
// Single NS record with 0 TTL
rr_single_->addRdata(rdata::generic::NS(ns_name_));