From: Aki Tuomi Date: Wed, 17 Jun 2015 07:25:43 +0000 (+0300) Subject: Use DNSNAme in remotebackend test suite X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~58^2~21^2~5^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ad87834f8acf2bada99834e3d0c6cd1dd63e5d0;p=thirdparty%2Fpdns.git Use DNSNAme in remotebackend test suite --- diff --git a/modules/remotebackend/test-remotebackend.cc b/modules/remotebackend/test-remotebackend.cc index 596135c31b..82236096d9 100644 --- a/modules/remotebackend/test-remotebackend.cc +++ b/modules/remotebackend/test-remotebackend.cc @@ -32,11 +32,11 @@ BOOST_AUTO_TEST_SUITE(test_remotebackend_so) BOOST_AUTO_TEST_CASE(test_method_lookup) { BOOST_TEST_MESSAGE("Testing lookup method"); DNSResourceRecord rr; - be->lookup(QType(QType::SOA), "unit.test"); + be->lookup(QType(QType::SOA), DNSName("unit.test")); // then try to get() BOOST_CHECK(be->get(rr)); // and this should be TRUE. // then we check rr contains what we expect - BOOST_CHECK_EQUAL(rr.qname, "unit.test"); + BOOST_CHECK_EQUAL(rr.qname.toString(), "unit.test."); BOOST_CHECK_MESSAGE(rr.qtype == QType::SOA, "returned qtype was not SOA"); BOOST_CHECK_EQUAL(rr.content, "ns.unit.test hostmaster.unit.test 1 2 3 4 5 6"); BOOST_CHECK_EQUAL(rr.ttl, 300); @@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(test_method_lookup) { BOOST_AUTO_TEST_CASE(test_method_lookup_empty) { BOOST_TEST_MESSAGE("Testing lookup method with empty result"); DNSResourceRecord rr; - be->lookup(QType(QType::SOA), "empty.unit.test"); + be->lookup(QType(QType::SOA), DNSName("empty.unit.test")); // then try to get() BOOST_CHECK(!be->get(rr)); // and this should be FALSE } @@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(test_method_list) { DNSResourceRecord rr; BOOST_TEST_MESSAGE("Testing list method"); - be->list("unit.test", -1); + be->list(DNSName("unit.test"), -1); while(be->get(rr)) record_count++; BOOST_CHECK_EQUAL(record_count, 5); // number of records our test domain has @@ -70,13 +70,13 @@ BOOST_AUTO_TEST_CASE(test_method_setDomainMetadata) { std::vector meta; meta.push_back("VALUE"); BOOST_TEST_MESSAGE("Testing setDomainMetadata method"); - BOOST_CHECK(be->setDomainMetadata("unit.test","TEST", meta)); + BOOST_CHECK(be->setDomainMetadata(DNSName("unit.test"),"TEST", meta)); } BOOST_AUTO_TEST_CASE(test_method_getDomainMetadata) { std::vector meta; BOOST_TEST_MESSAGE("Testing getDomainMetadata method"); - be->getDomainMetadata("unit.test","TEST", meta); + be->getDomainMetadata(DNSName("unit.test"),"TEST", meta); BOOST_CHECK_EQUAL(meta.size(), 1); // in case we got more than one value, which would be unexpected // but not fatal @@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(test_method_getDomainMetadata) { BOOST_AUTO_TEST_CASE(test_method_getAllDomainMetadata) { std::map > meta; BOOST_TEST_MESSAGE("Testing getAllDomainMetadata method"); - be->getAllDomainMetadata("unit.test", meta); + be->getAllDomainMetadata(DNSName("unit.test"), meta); BOOST_CHECK_EQUAL(meta.size(), 1); // in case we got more than one value, which would be unexpected // but not fatal @@ -97,15 +97,15 @@ BOOST_AUTO_TEST_CASE(test_method_getAllDomainMetadata) { BOOST_AUTO_TEST_CASE(test_method_addDomainKey) { BOOST_TEST_MESSAGE("Testing addDomainKey method"); - BOOST_CHECK_EQUAL(be->addDomainKey("unit.test",k1), 1); - BOOST_CHECK_EQUAL(be->addDomainKey("unit.test",k2), 2); + BOOST_CHECK_EQUAL(be->addDomainKey(DNSName("unit.test"),k1), 1); + BOOST_CHECK_EQUAL(be->addDomainKey(DNSName("unit.test"),k2), 2); } BOOST_AUTO_TEST_CASE(test_method_getDomainKeys) { std::vector keys; BOOST_TEST_MESSAGE("Testing getDomainKeys method"); // we expect to get two keys - be->getDomainKeys("unit.test",0,keys); + be->getDomainKeys(DNSName("unit.test"),0,keys); BOOST_CHECK_EQUAL(keys.size(), 2); // in case we got more than 2 keys, which would be unexpected // but not fatal @@ -122,25 +122,26 @@ BOOST_AUTO_TEST_CASE(test_method_getDomainKeys) { BOOST_AUTO_TEST_CASE(test_method_deactivateDomainKey) { BOOST_TEST_MESSAGE("Testing deactivateDomainKey method"); - BOOST_CHECK(be->deactivateDomainKey("unit.test",1)); + BOOST_CHECK(be->deactivateDomainKey(DNSName("unit.test"),1)); } BOOST_AUTO_TEST_CASE(test_method_activateDomainKey) { BOOST_TEST_MESSAGE("Testing activateDomainKey method"); - BOOST_CHECK(be->activateDomainKey("unit.test",1)); + BOOST_CHECK(be->activateDomainKey(DNSName("unit.test"),1)); } BOOST_AUTO_TEST_CASE(test_method_removeDomainKey) { - BOOST_CHECK(be->removeDomainKey("unit.test",2)); - BOOST_CHECK(be->removeDomainKey("unit.test",1)); + BOOST_CHECK(be->removeDomainKey(DNSName("unit.test"),2)); + BOOST_CHECK(be->removeDomainKey(DNSName("unit.test"),1)); } BOOST_AUTO_TEST_CASE(test_method_getBeforeAndAfterNamesAbsolute) { - std::string unhashed,before,after; + DNSName unhashed; + std::string before,after; BOOST_TEST_MESSAGE("Testing getBeforeAndAfterNamesAbsolute method"); be->getBeforeAndAfterNamesAbsolute(-1, "middle.unit.test", unhashed, before, after); - BOOST_CHECK_EQUAL(unhashed, "middle"); + BOOST_CHECK_EQUAL(unhashed.toString(), "middle."); BOOST_CHECK_EQUAL(before, "begin"); BOOST_CHECK_EQUAL(after, "stop"); } @@ -148,21 +149,22 @@ BOOST_AUTO_TEST_CASE(test_method_getBeforeAndAfterNamesAbsolute) { BOOST_AUTO_TEST_CASE(test_method_setTSIGKey) { std::string algorithm, content; BOOST_TEST_MESSAGE("Testing setTSIGKey method"); - BOOST_CHECK_MESSAGE(be->setTSIGKey("unit.test","hmac-md5","kp4/24gyYsEzbuTVJRUMoqGFmN3LYgVDzJ/3oRSP7ys="), "did not return true"); + BOOST_CHECK_MESSAGE(be->setTSIGKey(DNSName("unit.test"),DNSName("hmac-md5"),"kp4/24gyYsEzbuTVJRUMoqGFmN3LYgVDzJ/3oRSP7ys="), "did not return true"); } BOOST_AUTO_TEST_CASE(test_method_getTSIGKey) { - std::string algorithm, content; + DNSName algorithm; + std::string content; BOOST_TEST_MESSAGE("Testing getTSIGKey method"); - be->getTSIGKey("unit.test",&algorithm,&content); - BOOST_CHECK_EQUAL(algorithm, "hmac-md5"); + be->getTSIGKey(DNSName("unit.test"),&algorithm,&content); + BOOST_CHECK_EQUAL(algorithm.toString(), "hmac-md5."); BOOST_CHECK_EQUAL(content, "kp4/24gyYsEzbuTVJRUMoqGFmN3LYgVDzJ/3oRSP7ys="); } BOOST_AUTO_TEST_CASE(test_method_deleteTSIGKey) { std::string algorithm, content; BOOST_TEST_MESSAGE("Testing deleteTSIGKey method"); - BOOST_CHECK_MESSAGE(be->deleteTSIGKey("unit.test"), "did not return true"); + BOOST_CHECK_MESSAGE(be->deleteTSIGKey(DNSName("unit.test")), "did not return true"); } BOOST_AUTO_TEST_CASE(test_method_getTSIGKeys) { @@ -171,8 +173,8 @@ BOOST_AUTO_TEST_CASE(test_method_getTSIGKeys) { be->getTSIGKeys(keys); BOOST_CHECK(keys.size() > 0); if (keys.size() > 0) { - BOOST_CHECK_EQUAL(keys[0].name, "test"); - BOOST_CHECK_EQUAL(keys[0].algorithm, "NULL"); + BOOST_CHECK_EQUAL(keys[0].name.toString(), "test."); + BOOST_CHECK_EQUAL(keys[0].algorithm.toString(), "NULL."); BOOST_CHECK_EQUAL(keys[0].key, "NULL"); } } @@ -186,8 +188,8 @@ BOOST_AUTO_TEST_CASE(test_method_setNotified) { BOOST_AUTO_TEST_CASE(test_method_getDomainInfo) { DomainInfo di; BOOST_TEST_MESSAGE("Testing getDomainInfo method"); - be->getDomainInfo("unit.test", di); - BOOST_CHECK_EQUAL(di.zone, "unit.test"); + be->getDomainInfo(DNSName("unit.test"), di); + BOOST_CHECK_EQUAL(di.zone.toString(), "unit.test."); BOOST_CHECK_EQUAL(di.serial, 2); BOOST_CHECK_EQUAL(di.notified_serial, 2); BOOST_CHECK_EQUAL(di.kind, DomainInfo::Native); @@ -196,8 +198,8 @@ BOOST_AUTO_TEST_CASE(test_method_getDomainInfo) { BOOST_AUTO_TEST_CASE(test_method_isMaster) { BOOST_TEST_MESSAGE("Testing isMaster method"); - BOOST_CHECK(be->isMaster("ns1.unit.test", "10.0.0.1")); - BOOST_CHECK(!be->isMaster("ns2.unit.test", "10.0.0.2")); + BOOST_CHECK(be->isMaster(DNSName("ns1.unit.test"), "10.0.0.1")); + BOOST_CHECK(!be->isMaster(DNSName("ns2.unit.test"), "10.0.0.2")); } BOOST_AUTO_TEST_CASE(test_method_superMasterBackend) { @@ -219,7 +221,7 @@ BOOST_AUTO_TEST_CASE(test_method_superMasterBackend) { rr.content = "ns2.example.com"; nsset.push_back(rr); - BOOST_CHECK(be->superMasterBackend("10.0.0.1", "example.com", nsset, NULL, NULL, &dbd)); + BOOST_CHECK(be->superMasterBackend("10.0.0.1", DNSName("example.com"), nsset, NULL, NULL, &dbd)); // let's see what we got BOOST_CHECK_EQUAL(dbd, be); @@ -227,13 +229,13 @@ BOOST_AUTO_TEST_CASE(test_method_superMasterBackend) { BOOST_AUTO_TEST_CASE(test_method_createSlaveDomain) { BOOST_TEST_MESSAGE("Testing createSlaveDomain method"); - BOOST_CHECK(be->createSlaveDomain("10.0.0.1", "pirate.unit.test", "", "")); + BOOST_CHECK(be->createSlaveDomain("10.0.0.1", DNSName("pirate.unit.test"), "", "")); } BOOST_AUTO_TEST_CASE(test_method_feedRecord) { DNSResourceRecord rr; BOOST_TEST_MESSAGE("Testing feedRecord method"); - be->startTransaction("example.com",2); + be->startTransaction(DNSName("example.com"),2); rr.qname = "example.com"; rr.qtype = QType::SOA; rr.qclass = QClass::IN; @@ -250,7 +252,7 @@ BOOST_AUTO_TEST_CASE(test_method_feedRecord) { } BOOST_AUTO_TEST_CASE(test_method_replaceRRSet) { - be->startTransaction("example.com",2); + be->startTransaction(DNSName("example.com"),2); DNSResourceRecord rr; std::vector rrset; BOOST_TEST_MESSAGE("Testing replaceRRSet method"); @@ -260,29 +262,29 @@ BOOST_AUTO_TEST_CASE(test_method_replaceRRSet) { rr.ttl = 300; rr.content = "1.1.1.1"; rrset.push_back(rr); - BOOST_CHECK(be->replaceRRSet(2, "replace.example.com", QType(QType::A), rrset)); + BOOST_CHECK(be->replaceRRSet(2, DNSName("replace.example.com"), QType(QType::A), rrset)); be->commitTransaction(); } BOOST_AUTO_TEST_CASE(test_method_feedEnts) { BOOST_TEST_MESSAGE("Testing feedEnts method"); - be->startTransaction("example.com",2); - map nonterm = boost::assign::map_list_of("_udp", true)("_sip._udp", true); + be->startTransaction(DNSName("example.com"),2); + map nonterm = boost::assign::map_list_of(DNSName("_udp"), true)(DNSName("_sip._udp"), true); BOOST_CHECK(be->feedEnts(2, nonterm)); be->commitTransaction(); } BOOST_AUTO_TEST_CASE(test_method_feedEnts3) { BOOST_TEST_MESSAGE("Testing feedEnts3 method"); - be->startTransaction("example.com",2); - map nonterm = boost::assign::map_list_of("_udp", true)("_sip._udp", true); - BOOST_CHECK(be->feedEnts3(2, "example.com", nonterm, 1, "\u00aa\u00bb\u00cc\u00dd", 0)); + be->startTransaction(DNSName("example.com"),2); + map nonterm = boost::assign::map_list_of(DNSName("_udp"), true)(DNSName("_sip._udp"), true); + BOOST_CHECK(be->feedEnts3(2, DNSName("example.com"), nonterm, 1, "\u00aa\u00bb\u00cc\u00dd", 0)); be->commitTransaction(); } BOOST_AUTO_TEST_CASE(test_method_abortTransaction) { BOOST_TEST_MESSAGE("Testing abortTransaction method"); - be->startTransaction("example.com",2); + be->startTransaction(DNSName("example.com"),2); BOOST_CHECK(be->abortTransaction()); } @@ -290,8 +292,8 @@ BOOST_AUTO_TEST_CASE(test_method_calculateSOASerial) { SOAData sd; time_t serial; - be->getSOA("unit.test",sd); - BOOST_CHECK(be->calculateSOASerial("unit.test",sd,serial)); + be->getSOA(DNSName("unit.test"),sd); + BOOST_CHECK(be->calculateSOASerial(DNSName("unit.test"),sd,serial)); BOOST_CHECK_EQUAL(serial, 2013060300); }