"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test-syncres_cc9.cc" between
pdns-recursor-4.5.1.tar.bz2 and pdns-recursor-4.5.2.tar.bz2

About: PowerDNS - a separate release of the PowerDNS Recursor (without the authoritative nameserver).

test-syncres_cc9.cc  (pdns-recursor-4.5.1.tar.bz2):test-syncres_cc9.cc  (pdns-recursor-4.5.2.tar.bz2)
skipping to change at line 1219 skipping to change at line 1219
const ComboAddress who; const ComboAddress who;
vector<DNSRecord> cached; vector<DNSRecord> cached;
BOOST_CHECK_GT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::SOA ), true, &cached, who), 0); BOOST_CHECK_GT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::SOA ), true, &cached, who), 0);
cached.clear(); cached.clear();
BOOST_CHECK_LT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::NS) , false, &cached, who), 0); BOOST_CHECK_LT(g_recCache->get(now, DNSName("powerdns.com."), QType(QType::NS) , false, &cached, who), 0);
BOOST_CHECK_LT(g_recCache->get(now, DNSName("spoofed.ns."), QType(QType::A), f alse, &cached, who), 0); BOOST_CHECK_LT(g_recCache->get(now, DNSName("spoofed.ns."), QType(QType::A), f alse, &cached, who), 0);
BOOST_CHECK_LT(g_recCache->get(now, DNSName("spoofed.ns."), QType(QType::AAAA) , false, &cached, who), 0); BOOST_CHECK_LT(g_recCache->get(now, DNSName("spoofed.ns."), QType(QType::AAAA) , false, &cached, who), 0);
} }
BOOST_AUTO_TEST_CASE(test_dnssec_validation_referral_on_ds_query_insecure)
{
/*
The server at ds-ignorant.com sends a referral to the child zone
on a ds-ignorant.com DS query. ds-ignorant.com is unsigned,
signed.ds-ignorant.com is somehow signed, but no TA.
*/
std::unique_ptr<SyncRes> sr;
initSR(sr, true);
setDNSSECValidation(sr, DNSSECMode::ValidateAll);
primeHints();
const DNSName target("signed.ds-ignorant.com.");
testkeysset_t keys;
auto luaconfsCopy = g_luaconfs.getCopy();
luaconfsCopy.dsAnchors.clear();
generateKeyMaterial(g_rootdnsname, DNSSECKeeper::ECDSA256, DNSSECKeeper::DIGES
T_SHA256, keys, luaconfsCopy.dsAnchors);
generateKeyMaterial(DNSName("signed.ds-ignorant.com."), DNSSECKeeper::ECDSA256
, DNSSECKeeper::DIGEST_SHA256, keys);
g_luaconfs.setState(luaconfsCopy);
size_t queriesCount = 0;
sr->setAsyncCallback([target, &queriesCount, keys](const ComboAddress& ip, con
st DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, stru
ct timeval* now, boost::optional<Netmask>& srcmask, boost::optional<const Resolv
eContext&> context, LWResult* res, bool* chained) {
queriesCount++;
if (domain.isPartOf(DNSName("signed.ds-ignorant.com.")) && ip == ComboAddres
s("192.0.2.1:53")) {
setLWResult(res, 0, false, false, true);
addRecordToLW(res, "signed.ds-ignorant.com.", QType::NS, "ns.signed.ds-ign
orant.com.", DNSResourceRecord::AUTHORITY, 3600);
addRecordToLW(res, "ns.signed.ds-ignorant.com.", QType::A, "192.0.2.2", DN
SResourceRecord::ADDITIONAL, 3600);
return LWResult::Result::Success;
}
else if (type == QType::DNSKEY || (type == QType::DS && domain != target)) {
DNSName auth(domain);
auth.chopOff();
return genericDSAndDNSKEYHandler(res, domain, auth, type, keys, false);
}
else {
if (domain.isPartOf(DNSName("ds-ignorant.com.")) && isRootServer(ip)) {
setLWResult(res, 0, false, false, true);
addRecordToLW(res, "ds-ignorant.com.", QType::NS, "ns.ds-ignorant.com.",
DNSResourceRecord::AUTHORITY, 3600);
/* no DS, insecure */
addNSECRecordToLW(DNSName("ds-ignorant.com."), DNSName("ds-ignorant1.com
."), {QType::NS}, 600, res->d_records);
addRRSIG(keys, res->d_records, DNSName("."), 300);
addRecordToLW(res, "ns.ds-ignorant.com.", QType::A, "192.0.2.1", DNSReso
urceRecord::ADDITIONAL, 3600);
return LWResult::Result::Success;
}
else if (domain == target) {
if (type == QType::A) {
setLWResult(res, 0, true, false, true);
addRecordToLW(res, target, QType::A, "192.0.2.200");
addRRSIG(keys, res->d_records, domain, 300);
return LWResult::Result::Success;
}
else if (type == QType::DS) {
setLWResult(res, 0, true, false, true);
addRecordToLW(res, domain, QType::SOA, "signed.ds-ignorant.com. admin\
\.signed.ds-ignorant.com. 2017032301 10800 3600 604800 3600", DNSResourceRecord:
:AUTHORITY, 3600);
addRRSIG(keys, res->d_records, domain, 300);
addNSECRecordToLW(domain, DNSName("z.signed.ds-ignorant.com."), {QType
::A, QType::SOA, QType::NSEC}, 600, res->d_records);
addRRSIG(keys, res->d_records, domain, 300);
return LWResult::Result::Success;
}
}
}
return LWResult::Result::Timeout;
});
vector<DNSRecord> ret;
int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_CHECK_EQUAL(sr->getValidationState(), vState::Insecure);
BOOST_REQUIRE_EQUAL(ret.size(), 2U);
BOOST_CHECK(ret.at(0).d_type == QType::A);
BOOST_CHECK(ret.at(1).d_type == QType::RRSIG);
BOOST_CHECK_EQUAL(queriesCount, 7U);
ret.clear();
res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_CHECK_EQUAL(sr->getValidationState(), vState::Insecure);
BOOST_CHECK_EQUAL(ret.size(), 2U);
BOOST_CHECK(ret.at(0).d_type == QType::A);
BOOST_CHECK(ret.at(1).d_type == QType::RRSIG);
BOOST_CHECK_EQUAL(queriesCount, 7U);
}
BOOST_AUTO_TEST_CASE(test_dnssec_validation_referral_on_ds_query_secure)
{
/*
The server at ds-ignorant.com sends a referral to the child zone
on a ds-ignorant.com DS query. ds-ignorant.com is signed,
signed.ds-ignorant.com as well.
*/
std::unique_ptr<SyncRes> sr;
initSR(sr, true);
setDNSSECValidation(sr, DNSSECMode::ValidateAll);
primeHints();
const DNSName target("signed.ds-ignorant.com.");
testkeysset_t keys;
auto luaconfsCopy = g_luaconfs.getCopy();
luaconfsCopy.dsAnchors.clear();
generateKeyMaterial(g_rootdnsname, DNSSECKeeper::ECDSA256, DNSSECKeeper::DIGES
T_SHA256, keys, luaconfsCopy.dsAnchors);
generateKeyMaterial(DNSName("ds-ignorant.com."), DNSSECKeeper::ECDSA256, DNSSE
CKeeper::DIGEST_SHA256, keys);
generateKeyMaterial(DNSName("signed.ds-ignorant.com."), DNSSECKeeper::ECDSA256
, DNSSECKeeper::DIGEST_SHA256, keys);
g_luaconfs.setState(luaconfsCopy);
size_t queriesCount = 0;
sr->setAsyncCallback([target, &queriesCount, keys](const ComboAddress& ip, con
st DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, stru
ct timeval* now, boost::optional<Netmask>& srcmask, boost::optional<const Resolv
eContext&> context, LWResult* res, bool* chained) {
queriesCount++;
if (domain.isPartOf(DNSName("signed.ds-ignorant.com.")) && ip == ComboAddres
s("192.0.2.1:53")) {
setLWResult(res, 0, false, false, true);
addRecordToLW(res, "signed.ds-ignorant.com.", QType::NS, "ns.signed.ds-ign
orant.com.", DNSResourceRecord::AUTHORITY, 3600);
addRecordToLW(res, "ns.signed.ds-ignorant.com.", QType::A, "192.0.2.2", DN
SResourceRecord::ADDITIONAL, 3600);
return LWResult::Result::Success;
}
else if (type == QType::DNSKEY || (type == QType::DS && domain != target)) {
DNSName auth(domain);
auth.chopOff();
return genericDSAndDNSKEYHandler(res, domain, auth, type, keys, false);
}
else {
if (domain.isPartOf(DNSName("ds-ignorant.com.")) && isRootServer(ip)) {
setLWResult(res, 0, false, false, true);
addRecordToLW(res, "ds-ignorant.com.", QType::NS, "ns.ds-ignorant.com.",
DNSResourceRecord::AUTHORITY, 3600);
addDS(DNSName("ds-ignorant.com."), 300, res->d_records, keys);
addRRSIG(keys, res->d_records, DNSName("."), 300);
addRecordToLW(res, "ns.ds-ignorant.com.", QType::A, "192.0.2.1", DNSReso
urceRecord::ADDITIONAL, 3600);
return LWResult::Result::Success;
}
else if (domain == target) {
if (type == QType::A) {
setLWResult(res, 0, true, false, true);
addRecordToLW(res, target, QType::A, "192.0.2.200");
addRRSIG(keys, res->d_records, domain, 300);
return LWResult::Result::Success;
}
else if (type == QType::DS) {
setLWResult(res, 0, true, false, true);
addRecordToLW(res, domain, QType::SOA, "signed.ds-ignorant.com. admin\
\.signed.ds-ignorant.com. 2017032301 10800 3600 604800 3600", DNSResourceRecord:
:AUTHORITY, 3600);
addRRSIG(keys, res->d_records, domain, 300);
addNSECRecordToLW(domain, DNSName("z.signed.ds-ignorant.com."), {QType
::A, QType::SOA, QType::NSEC}, 600, res->d_records);
addRRSIG(keys, res->d_records, domain, 300);
return LWResult::Result::Success;
}
}
}
return LWResult::Result::Timeout;
});
vector<DNSRecord> ret;
int res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_CHECK_EQUAL(sr->getValidationState(), vState::BogusMissingNegativeIndica
tion);
BOOST_REQUIRE_EQUAL(ret.size(), 2U);
BOOST_CHECK(ret.at(0).d_type == QType::A);
BOOST_CHECK(ret.at(1).d_type == QType::RRSIG);
BOOST_CHECK_EQUAL(queriesCount, 7U);
ret.clear();
res = sr->beginResolve(target, QType(QType::A), QClass::IN, ret);
BOOST_CHECK_EQUAL(res, RCode::NoError);
BOOST_CHECK_EQUAL(sr->getValidationState(), vState::BogusMissingNegativeIndica
tion);
BOOST_CHECK_EQUAL(ret.size(), 2U);
BOOST_CHECK(ret.at(0).d_type == QType::A);
BOOST_CHECK(ret.at(1).d_type == QType::RRSIG);
BOOST_CHECK_EQUAL(queriesCount, 7U);
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
 End of changes. 1 change blocks. 
0 lines changed or deleted 206 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)