drop repeating record type generate*Rrset in rrset-factory
Change-Id: I64f18cb5f08febbbeccaa66b10b7a46a06a4bc76
diff --git a/src/daemon/rrset-factory.cpp b/src/daemon/rrset-factory.cpp
index f82e831..4351fcd 100644
--- a/src/daemon/rrset-factory.cpp
+++ b/src/daemon/rrset-factory.cpp
@@ -117,7 +117,6 @@
Rrset
RrsetFactory::generateNsRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl,
const ndn::DelegationList& delegations)
@@ -129,7 +128,7 @@
if (ttl == DEFAULT_RR_TTL)
ttl = m_zone.getTtl();
- std::pair<Rrset, Name> rrsetAndName = generateBaseRrset(label, type, version, ttl);
+ std::pair<Rrset, Name> rrsetAndName = generateBaseRrset(label, label::NS_RR_TYPE, version, ttl);
const Name& name = rrsetAndName.second;
Rrset& rrset = rrsetAndName.first;
@@ -145,7 +144,6 @@
Rrset
RrsetFactory::generateTxtRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl,
const std::vector<std::string>& strings)
@@ -159,7 +157,7 @@
Name name;
Rrset rrset;
- std::tie(rrset, name) = generateBaseRrset(label, type, version, ttl);
+ std::tie(rrset, name) = generateBaseRrset(label, label::TXT_RR_TYPE, version, ttl);
std::vector<Block> rrs;
for (const auto& item : strings) {
@@ -180,7 +178,6 @@
Rrset
RrsetFactory::generateCertRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl,
const ndn::security::v2::Certificate& cert)
@@ -194,7 +191,7 @@
Name name;
Rrset rrset;
- std::tie(rrset, name) = generateBaseRrset(label, type, version, ttl);
+ std::tie(rrset, name) = generateBaseRrset(label, label::APPCERT_RR_TYPE, version, ttl);
Data data(name);
data.setContent(cert.wireEncode());
@@ -208,7 +205,6 @@
Rrset
RrsetFactory::generateAuthRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl)
{
@@ -221,7 +217,7 @@
Name name;
Rrset rrset;
- std::tie(rrset, name) = generateBaseRrset(label, type, version, ttl);
+ std::tie(rrset, name) = generateBaseRrset(label, label::NS_RR_TYPE, version, ttl);
Data data(name);
diff --git a/src/daemon/rrset-factory.hpp b/src/daemon/rrset-factory.hpp
index 89f5b98..59b3b09 100644
--- a/src/daemon/rrset-factory.hpp
+++ b/src/daemon/rrset-factory.hpp
@@ -61,27 +61,23 @@
Rrset
generateNsRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl,
const ndn::DelegationList& delegations);
Rrset
generateTxtRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl,
const std::vector<std::string>& contents);
Rrset
generateAuthRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl);
Rrset
generateCertRrset(const Name& label,
- const name::Component& type,
const uint64_t version,
time::seconds ttl,
const ndn::security::v2::Certificate& cert);
diff --git a/src/mgmt/management-tool.cpp b/src/mgmt/management-tool.cpp
index b0bd7b4..d4d64e1 100644
--- a/src/mgmt/management-tool.cpp
+++ b/src/mgmt/management-tool.cpp
@@ -284,7 +284,7 @@
continue;
}
- Rrset authRr = zoneRrFactory.generateAuthRrset(prefix, label::NS_RR_TYPE,
+ Rrset authRr = zoneRrFactory.generateAuthRrset(prefix,
VERSION_USE_UNIX_TIMESTAMP, authTtl);
NDNS_LOG_INFO("Adding NDNS_AUTH " << authRr);
m_dbMgr.insert(authRr);
diff --git a/tests/unit/daemon/rrset-factory.cpp b/tests/unit/daemon/rrset-factory.cpp
index 5e71a47..625679e 100644
--- a/tests/unit/daemon/rrset-factory.cpp
+++ b/tests/unit/daemon/rrset-factory.cpp
@@ -106,7 +106,7 @@
// rf without checkZoneKey: throw.
ndn::DelegationList delegations;
- BOOST_CHECK_THROW(rf.generateNsRrset(label, type, version, ttl, delegations),
+ BOOST_CHECK_THROW(rf.generateNsRrset(label, version, ttl, delegations),
ndns::RrsetFactory::Error);
rf.checkZoneKey();
@@ -115,7 +115,7 @@
delegations.insert(i, name);
}
- Rrset rrset = rf.generateNsRrset(label, type, version, ttl, delegations);
+ Rrset rrset = rf.generateNsRrset(label, version, ttl, delegations);
BOOST_CHECK_EQUAL(rrset.getId(), 0);
BOOST_REQUIRE(rrset.getZone() != nullptr);
@@ -150,17 +150,17 @@
RrsetFactory rf(TEST_DATABASE2, m_zoneName, m_keyChain, m_certName);
// rf without checkZoneKey: throw.
- BOOST_CHECK_THROW(rf.generateTxtRrset(label, type, version, ttl, txts),
+ BOOST_CHECK_THROW(rf.generateTxtRrset(label, version, ttl, txts),
ndns::RrsetFactory::Error);
rf.checkZoneKey();
- BOOST_CHECK_NO_THROW(rf.generateTxtRrset(label, type, version, ttl, txts));
+ BOOST_CHECK_NO_THROW(rf.generateTxtRrset(label, version, ttl, txts));
rf.checkZoneKey();
for (int i = 1; i <= 4; i++) {
txts.push_back(std::to_string(i));
}
- Rrset rrset = rf.generateTxtRrset(label, type, version, ttl, txts);
+ Rrset rrset = rf.generateTxtRrset(label, version, ttl, txts);
BOOST_CHECK_EQUAL(rrset.getId(), 0);
BOOST_CHECK_EQUAL(*rrset.getZone(), zone);
diff --git a/tests/unit/database-test-data.cpp b/tests/unit/database-test-data.cpp
index 93815ec..ea55948 100644
--- a/tests/unit/database-test-data.cpp
+++ b/tests/unit/database-test-data.cpp
@@ -96,7 +96,7 @@
const name::Component version = name::Component::fromVersion(100 + 1000 * certificateIndex);
name::Component qType(label::NDNS_ITERATIVE_QUERY);
NdnsContentType contentType = NDNS_RESP;
- if (type == label::CERT_RR_TYPE) {
+ if (type == label::APPCERT_RR_TYPE) {
contentType = NDNS_KEY;
}
else if (type == label::NS_RR_TYPE) {
@@ -139,18 +139,18 @@
if (type == label::NS_RR_TYPE) {
ndn::DelegationList ds;
ds.insert(1, "xx");
- rrset = rf.generateNsRrset(label, type, version.toVersion(), ttl, ds);
+ rrset = rf.generateNsRrset(label, version.toVersion(), ttl, ds);
if (contentType != NDNS_AUTH) {
// do not add AUTH packet to link
m_links.push_back(Link(rrset.getData()));
}
}
else if (type == label::TXT_RR_TYPE) {
- rrset = rf.generateTxtRrset(label, type, version.toVersion(), ttl,
+ rrset = rf.generateTxtRrset(label, version.toVersion(), ttl,
std::vector<std::string>());
}
- else if (type == label::CERT_RR_TYPE) {
- rrset = rf.generateCertRrset(label, type, version.toVersion(), ttl,
+ else if (type == label::APPCERT_RR_TYPE) {
+ rrset = rf.generateCertRrset(label, version.toVersion(), ttl,
m_cert);
}
diff --git a/tests/unit/mgmt/management-tool.cpp b/tests/unit/mgmt/management-tool.cpp
index 7c9e726..72e079d 100644
--- a/tests/unit/mgmt/management-tool.cpp
+++ b/tests/unit/mgmt/management-tool.cpp
@@ -559,13 +559,13 @@
RrsetFactory rf(TEST_DATABASE, zoneName, m_keyChain, DEFAULT_CERT);
rf.checkZoneKey();
- Rrset rrset1 = rf.generateNsRrset("/l1", label::NS_RR_TYPE, 7654, ttl2, DelegationList());
+ Rrset rrset1 = rf.generateNsRrset("/l1", 7654, ttl2, DelegationList());
BOOST_CHECK_NO_THROW(m_tool.addRrset(rrset1));
Rrset rrset2 = findRrSet(zone, "/l1", label::NS_RR_TYPE);
BOOST_CHECK_EQUAL(rrset1, rrset2);
- Rrset rrset3 = rf.generateNsRrset("/l1/l2/l3", label::NS_RR_TYPE, 7654, ttl2, DelegationList());
+ Rrset rrset3 = rf.generateNsRrset("/l1/l2/l3", 7654, ttl2, DelegationList());
BOOST_CHECK_THROW(m_tool.addRrset(rrset3), ndns::ManagementTool::Error);
}
@@ -592,7 +592,7 @@
Name labelName("/l1/l2/l3");
- Rrset rrset1 = rf.generateNsRrset(labelName, label::NS_RR_TYPE, 7654, ttl, DelegationList());
+ Rrset rrset1 = rf.generateNsRrset(labelName, 7654, ttl, DelegationList());
//add NS NDNS_AUTH and check user-defined ttl
BOOST_CHECK_NO_THROW(m_tool.addMultiLevelLabelRrset(rrset1, rf, ttl));
@@ -603,7 +603,7 @@
checkRrset("/l1/l2", label::NS_RR_TYPE, ndns::NDNS_AUTH);
// insert a same-name rrset with TXT type
- Rrset txtRr = rf.generateTxtRrset("/l1/l2/l3", label::TXT_RR_TYPE, 7654, ttl, std::vector<std::string>());
+ Rrset txtRr = rf.generateTxtRrset("/l1/l2/l3", 7654, ttl, std::vector<std::string>());
BOOST_CHECK_NO_THROW(m_tool.addMultiLevelLabelRrset(txtRr, rf, ttl));
checkRrset("/l1", label::NS_RR_TYPE, ndns::NDNS_AUTH);
@@ -613,28 +613,28 @@
checkRrset("/l1/l2/l3", label::NS_RR_TYPE, ndns::NDNS_LINK);
// insert a shorter NS, when there are longer NS or TXT
- Rrset shorterNs = rf.generateNsRrset("/l1/l2", label::NS_RR_TYPE, 7654, ttl, DelegationList());
+ Rrset shorterNs = rf.generateNsRrset("/l1/l2", 7654, ttl, DelegationList());
BOOST_CHECK_THROW(m_tool.addMultiLevelLabelRrset(shorterNs, rf, ttl),
ndns::ManagementTool::Error);
// insert a longer NS, when there is already a shorter NS
- Rrset longerNs = rf.generateNsRrset("/l1/l2/l3/l4", label::NS_RR_TYPE, 7654, ttl, DelegationList());
+ Rrset longerNs = rf.generateNsRrset("/l1/l2/l3/l4", 7654, ttl, DelegationList());
BOOST_CHECK_THROW(m_tool.addMultiLevelLabelRrset(longerNs, rf, ttl),
ndns::ManagementTool::Error);
// insert a smaller TXT, when there are longer NS and TXT
- Rrset shorterTxt = rf.generateTxtRrset("/l1/l2", label::TXT_RR_TYPE, 7654, ttl, std::vector<std::string>());
+ Rrset shorterTxt = rf.generateTxtRrset("/l1/l2", 7654, ttl, std::vector<std::string>());
BOOST_CHECK_NO_THROW(m_tool.addMultiLevelLabelRrset(shorterTxt, rf, ttl));
// insert a smaller NS, when there is long TXT
- Rrset longTxt = rf.generateTxtRrset("/k1/k2/k3", label::TXT_RR_TYPE, 7654, ttl, std::vector<std::string>());
- Rrset smallerNs = rf.generateNsRrset("/k1/k2", label::NS_RR_TYPE, 7654, ttl, DelegationList());
+ Rrset longTxt = rf.generateTxtRrset("/k1/k2/k3", 7654, ttl, std::vector<std::string>());
+ Rrset smallerNs = rf.generateNsRrset("/k1/k2", 7654, ttl, DelegationList());
BOOST_CHECK_NO_THROW(m_tool.addMultiLevelLabelRrset(longTxt, rf, ttl));
BOOST_CHECK_THROW(m_tool.addMultiLevelLabelRrset(smallerNs, rf, ttl),
ndns::ManagementTool::Error);
// inserting a longer TXT, when there is shoter TXT
- Rrset longerTxt = rf.generateTxtRrset("/k1/k2/k3/k4", label::TXT_RR_TYPE, 7654, ttl, std::vector<std::string>());
+ Rrset longerTxt = rf.generateTxtRrset("/k1/k2/k3/k4", 7654, ttl, std::vector<std::string>());
BOOST_CHECK_NO_THROW(m_tool.addMultiLevelLabelRrset(longerTxt, rf, ttl));
}
@@ -735,21 +735,21 @@
RrsetFactory rf(TEST_DATABASE, zoneName, m_keyChain, DEFAULT_CERT);
rf.checkZoneKey();
- Rrset rrset1 = rf.generateTxtRrset(label, label::NS_RR_TYPE, version, ttl, {});
+ Rrset rrset1 = rf.generateTxtRrset(label, version, ttl, {});
m_tool.addRrset(rrset1);
// throw error when adding duplicated rrset with the same version
BOOST_CHECK_THROW(m_tool.addRrset(rrset1),
ndns::ManagementTool::Error);
version--;
- Rrset rrset2 = rf.generateTxtRrset(label, label::NS_RR_TYPE, version, ttl, {});
+ Rrset rrset2 = rf.generateTxtRrset(label, version, ttl, {});
// throw error when adding duplicated rrset with older version
BOOST_CHECK_THROW(m_tool.addRrset(rrset2),
ndns::ManagementTool::Error);
version++;
version++;
- Rrset rrset3 = rf.generateTxtRrset(label, label::NS_RR_TYPE, version, ttl, {});
+ Rrset rrset3 = rf.generateTxtRrset(label, version, ttl, {});
BOOST_CHECK_NO_THROW(m_tool.addRrset(rrset3));
Zone zone(zoneName);
@@ -757,7 +757,7 @@
Rrset rrset;
rrset.setZone(&zone);
rrset.setLabel(label);
- rrset.setType(label::NS_RR_TYPE);
+ rrset.setType(label::TXT_RR_TYPE);
m_dbMgr.find(rrset);
BOOST_CHECK_EQUAL(rrset.getVersion(), name::Component::fromVersion(version));
@@ -838,11 +838,11 @@
del.preference = 10;
del.name = Name("/get/link");
DelegationList ds = {del};
- Rrset rrset1 = rf.generateNsRrset("/label1", label::NS_RR_TYPE, 100, DEFAULT_RR_TTL, ds);
+ Rrset rrset1 = rf.generateNsRrset("/label1", 100, DEFAULT_RR_TTL, ds);
m_tool.addRrset(rrset1);
// Add NS with NDNS_AUTH
- Rrset rrset2 = rf.generateAuthRrset("/label2", label::NS_RR_TYPE, 100000, DEFAULT_RR_TTL);
+ Rrset rrset2 = rf.generateAuthRrset("/label2", 100000, DEFAULT_RR_TTL);
m_tool.addRrset(rrset2);
// Add TXT from file
@@ -863,7 +863,7 @@
m_tool.addRrsetFromFile("/ndns-test", output);
// Add TXT in normal way
- Rrset rrset3 = rf.generateTxtRrset("/label3", label::TXT_RR_TYPE, 3333, DEFAULT_RR_TTL, {"Hello", "World"});
+ Rrset rrset3 = rf.generateTxtRrset("/label3", 3333, DEFAULT_RR_TTL, {"Hello", "World"});
m_tool.addRrset(rrset3);
m_tool.listZone("/ndns-test", std::cout, true);
@@ -920,7 +920,7 @@
m_tool.createZone(zoneName, ROOT_ZONE, time::seconds(1), time::days(1), otherKsk, otherDsk);
RrsetFactory rf(TEST_DATABASE, zoneName, m_keyChain, DEFAULT_CERT);
rf.checkZoneKey();
- Rrset rrset1 = rf.generateTxtRrset("/label", label::TXT_RR_TYPE, 100, DEFAULT_RR_TTL, {"Value1", "Value2"});
+ Rrset rrset1 = rf.generateTxtRrset("/label", 100, DEFAULT_RR_TTL, {"Value1", "Value2"});
m_tool.addRrset(rrset1);
@@ -947,12 +947,12 @@
RrsetFactory rf(TEST_DATABASE, zoneName, m_keyChain, DEFAULT_CERT);
rf.checkZoneKey();
- Rrset rrset1 = rf.generateTxtRrset("/label", label::NS_RR_TYPE, 100, DEFAULT_RR_TTL, {});
+ Rrset rrset1 = rf.generateTxtRrset("/label", 100, DEFAULT_RR_TTL, {});
BOOST_CHECK_NO_THROW(m_tool.addRrset(rrset1));
Zone zone(zoneName);
- BOOST_CHECK_NO_THROW(findRrSet(zone, "/label", label::NS_RR_TYPE));
+ BOOST_CHECK_NO_THROW(findRrSet(zone, "/label", label::TXT_RR_TYPE));
BOOST_CHECK_NO_THROW(m_tool.removeRrSet(zoneName, "/label", label::NS_RR_TYPE));
diff --git a/tools/ndns-add-rr.cpp b/tools/ndns-add-rr.cpp
index 2ac2b9a..b6f105c 100644
--- a/tools/ndns-add-rr.cpp
+++ b/tools/ndns-add-rr.cpp
@@ -188,11 +188,11 @@
delegations.insert(priority, Name(data[1]));
}
- rrset = rrsetFactory.generateNsRrset(label, type,
+ rrset = rrsetFactory.generateNsRrset(label,
version, ttl, delegations);
}
else if (type == label::TXT_RR_TYPE) {
- rrset = rrsetFactory.generateTxtRrset(label, type,
+ rrset = rrsetFactory.generateTxtRrset(label,
version, ttl, content);
}