Commit d520e3ac authored by Evan Hunt's avatar Evan Hunt
Browse files

Added a unit test for a CNAME wildcard


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1338 e5f2f494-b856-4b98-b285-d166d9295462
parent dd4a388c
......@@ -259,6 +259,67 @@ TEST_F(DataSrcTest, WildcardNodata) {
headerCheck(msg, Rcode::NOERROR(), true, true, true, 0, 2, 0);
}
TEST_F(DataSrcTest, WildcardCname) {
// Check that wildcard answers containing CNAMES are followed
// correctly
readAndProcessQuery(msg, "testdata/q_wild2_a");
headerCheck(msg, Rcode::NOERROR(), true, true, true, 4, 4, 6);
RRsetIterator rit = msg.beginSection(Section::ANSWER());
RRsetPtr rrset = *rit;
EXPECT_EQ(Name("www.wild2.example.com"), rrset->getName());
EXPECT_EQ(RRType::CNAME(), rrset->getType());
EXPECT_EQ(RRClass::IN(), rrset->getClass());
RdataIteratorPtr it = rrset->getRdataIterator();
it->first();
EXPECT_EQ("www.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
++rit;
++rit;
rrset = *rit;
EXPECT_EQ(Name("www.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
rit = msg.beginSection(Section::AUTHORITY());
rrset = *rit;
EXPECT_EQ(Name("example.com"), rrset->getName());
EXPECT_EQ(RRType::NS(), rrset->getType());
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
it->first();
EXPECT_EQ("dns01.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns02.example.com.", it->getCurrent().toText());
it->next();
EXPECT_EQ("dns03.example.com.", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
rit = msg.beginSection(Section::ADDITIONAL());
rrset = *rit;
EXPECT_EQ(Name("dns01.example.com"), rrset->getName());
EXPECT_EQ(RRType::A(), rrset->getType());
EXPECT_EQ(RRClass::IN(), rrset->getClass());
it = rrset->getRdataIterator();
it->first();
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
it->next();
EXPECT_TRUE(it->isLast());
}
TEST_F(DataSrcTest, AuthDelegation) {
readAndProcessQuery(msg, "testdata/q_sql1");
......
......@@ -57,6 +57,7 @@ const Name cnameint("cname-int.example.com");
const Name cnameext("cname-ext.example.com");
const Name dname("dname.example.com");
const Name wild("*.wild.example.com");
const Name wild2("*.wild2.example.com");
const Name subzone("subzone.example.com");
const Name loop1("loop1.example.com");
const Name loop2("loop2.example.com");
......@@ -80,6 +81,8 @@ RRsetPtr dns03_a;
RRsetPtr dns03_nsec;
RRsetPtr wild_a;
RRsetPtr wild_nsec;
RRsetPtr wild2_cname;
RRsetPtr wild2_nsec;
RRsetPtr dname_dname;
RRsetPtr dname_nsec;
RRsetPtr sql1_ns;
......@@ -295,7 +298,7 @@ TestDataSrc::init() {
wild_nsec = RRsetPtr(new RRset(wild, RRClass::IN(),
RRType::NSEC(), RRTTL(3600)));
wild_nsec->addRdata(generic::NSEC("www.example.com. A RRSIG NSEC"));
wild_nsec->addRdata(generic::NSEC("*.wild2.example.com. A RRSIG NSEC"));
rrsig = RRsetPtr(new RRset(wild, RRClass::IN(), RRType::RRSIG(),
RRTTL(3600)));
......@@ -303,6 +306,26 @@ TestDataSrc::init() {
rrsig->addRdata(generic::RRSIG("NSEC 5 3 7200 20100322084538 20100220084538 33495 example.com. OoGYslRj4xjZnBuzgOqsrvkDAHWycmQzbUxCRmgWnCbXiobJK7/ynONH3jm8G3vGlU0lwpHkhNs6cUK+6Nu8W49X3MT0Xksl/brroLcXYLi3vfxnYUNMMpXdeFl6WNNfoJRo90F/f/TWXAClRrDS29qiG3G1PEJZikIxZsZ0tyM="));
wild_nsec->addRRsig(rrsig);
// *.wild2.example.com HERE
wild2_cname = RRsetPtr(new RRset(wild2, RRClass::IN(), RRType::CNAME(),
RRTTL(3600)));
wild2_cname->addRdata(generic::CNAME("www.example.com"));
rrsig = RRsetPtr(new RRset(wild2, RRClass::IN(), RRType::RRSIG(),
RRTTL(3600)));
rrsig->addRdata(generic::RRSIG("CNAME 5 3 3600 20100410212307 20100311212307 33495 example.com. pGHtGdRBi4GKFSKszi6SsKvuBLDX8dFhZubU0tMojQ9SJuiFNF+WtxvdAYuUaoWP/9VLUaYmiw5u7JnzmR84DiXZPEs6DtD+UJdOZhaS7V7RTpE+tMOfVQBLpUnRWYtlTTmiBpFquzf3DdIxgUFhEPEuJJyp3LFRxJObCaq9 nvI="));
wild2_cname->addRRsig(rrsig);
wild2_nsec = RRsetPtr(new RRset(wild2, RRClass::IN(),
RRType::NSEC(), RRTTL(3600)));
wild2_nsec->addRdata(generic::NSEC("www.example.com. CNAME RRSIG NSEC"));
rrsig = RRsetPtr(new RRset(wild2, RRClass::IN(), RRType::RRSIG(),
RRTTL(3600)));
rrsig->addRdata(generic::RRSIG("NSEC 5 3 7200 20100410212307 20100311212307 33495 example.com. EuSzh6or8mbvwru2H7fyYeMpW6J8YZ528rabU38V/lMN0TdamghIuCneAvSNaZgwk2MSN1bWpZqB2kAipaM/ZI9/piLlTvVjjOQ8pjk0auwCEqT7Z7Qng3E92O9yVzO+WHT9QZn/fR6t60392In4IvcBGjZyjzQk8njIwbui xGA="));
wild2_nsec->addRRsig(rrsig);
// foo.example.com
foo_cname = RRsetPtr(new RRset(foo, RRClass::IN(), RRType::CNAME(),
RRTTL(3600)));
......@@ -324,7 +347,7 @@ TestDataSrc::init() {
// cname-int.example.com
cnameint_cname = RRsetPtr(new RRset(cnameint, RRClass::IN(),
RRType::CNAME(), RRTTL(3600)));
cnameint_cname->addRdata(generic::CNAME("www.example.com"));
cnameint_cname->addRdata(generic::CNAME("www.example.com."));
rrsig = RRsetPtr(new RRset(cnameint, RRClass::IN(), RRType::RRSIG(),
RRTTL(3600)));
......@@ -606,10 +629,21 @@ TestDataSrc::findRecords(const Name& name, const RRType& rdtype,
target.addRRset(wild_a);
} else if (rdtype == RRType::NSEC()) {
target.addRRset(wild_nsec);
flags |= REFERRAL;
} else {
flags |= TYPE_NOT_FOUND;
}
} else if (name == wild2) {
if (any) {
target.addRRset(wild2_cname);
target.addRRset(wild2_nsec);
} else if (rdtype == RRType::NSEC()) {
target.addRRset(wild2_nsec);
} else {
target.addRRset(wild2_cname);
if (rdtype != RRType::CNAME()) {
flags |= CNAME_FOUND;
}
}
} else if (name == www) {
if (any) {
target.addRRset(www_a);
......@@ -769,8 +803,10 @@ TestDataSrc::findPreviousName(const Name& qname,
target = subzone;
} else if (qname < wild) {
target = www;
} else {
} else if (qname < wild2) {
target = wild;
} else {
target = wild2;
}
} else {
if (qname >= sql1 || qname < www_sql1) {
......
# www.wild2.example.com/A (wildcard)
d8 ef 01 00 00 01 00 00 00 00 00 00 03 77 77 77
05 77 69 6c 64 32 07 65 78 61 6d 70 6c 65 03 63
6f 6d 00 00 01 00 01
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