update
Change-Id: I57f0ec460e07dae51dd6b25f14772096807a20b4
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 5b01efc..9af6f28 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -188,7 +188,7 @@
namespace requester {
void
-RequesterCaCache::load(const std::string& fileName)
+ProfileStorage::load(const std::string& fileName)
{
JsonSection configJson;
try {
@@ -204,7 +204,7 @@
}
void
-RequesterCaCache::load(const JsonSection& configSection)
+ProfileStorage::load(const JsonSection& configSection)
{
m_caItems.clear();
auto caList = configSection.get_child("ca-list");
@@ -219,7 +219,7 @@
}
void
-RequesterCaCache::save(const std::string& fileName) const
+ProfileStorage::save(const std::string& fileName) const
{
JsonSection configJson;
for (const auto& caItem : m_caItems) {
@@ -234,13 +234,13 @@
}
void
-RequesterCaCache::removeCaProfile(const Name& caName)
+ProfileStorage::removeCaProfile(const Name& caName)
{
m_caItems.remove_if([&](const CaProfile& item) { return item.m_caPrefix == caName; });
}
void
-RequesterCaCache::addCaProfile(const CaProfile& profile)
+ProfileStorage::addCaProfile(const CaProfile& profile)
{
for (auto& item : m_caItems) {
if (item.m_caPrefix == profile.m_caPrefix) {
diff --git a/src/configuration.hpp b/src/configuration.hpp
index 3671e20..ec8ccb1 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -150,7 +150,7 @@
* For Client configuration format, please refer to:
* https://github.com/named-data/ndncert/wiki/Client-Configuration-Sample
*/
-class RequesterCaCache
+class ProfileStorage
{
public:
/**
diff --git a/src/requester.hpp b/src/requester.hpp
index fddd35b..b37f90a 100644
--- a/src/requester.hpp
+++ b/src/requester.hpp
@@ -52,7 +52,7 @@
* @brief Decodes the CA profile from the replied CA profile Data packet.
*
* Will first verify the signature of the packet using the key provided inside the profile.
- * The application should be cautious whether to add CaProfile into the RequesterCaCache.
+ * The application should be cautious whether to add CaProfile into the ProfileStorage.
*
* @param reply The Data packet replied from CA profile fetching Interest.
* @return the CaProfile if decoding is successful
@@ -66,7 +66,7 @@
*
* Will first verify the signature of the packet using the key provided inside the profile and
* verify the certificate's digest matches the one obtained from the original CA.
- * The application should be cautious whether to add CaProfile into the RequesterCaCache.
+ * The application should be cautious whether to add CaProfile into the ProfileStorage.
*
* @param reply The Data packet replied from CA profile fetching Interest.
* @param caCertFullName The full name obtained from original CA's probe response.
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index f3540fd..c3086f4 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -89,60 +89,60 @@
BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/config-ca-6"), std::runtime_error);
}
-BOOST_AUTO_TEST_CASE(RequesterCaCacheFile)
+BOOST_AUTO_TEST_CASE(ProfileStorageConfigFile)
{
- requester::RequesterCaCache config;
- config.load("tests/unit-tests/config-files/config-client-1");
- BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
+ requester::ProfileStorage profileStorage;
+ profileStorage.load("tests/unit-tests/config-files/config-client-1");
+ BOOST_CHECK_EQUAL(profileStorage.m_caItems.size(), 2);
- auto& config1 = config.m_caItems.front();
- BOOST_CHECK_EQUAL(config1.m_caPrefix, "/ndn/edu/ucla");
- BOOST_CHECK_EQUAL(config1.m_caInfo, "ndn testbed ca");
- BOOST_CHECK_EQUAL(config1.m_maxValidityPeriod, time::seconds(864000));
- BOOST_CHECK_EQUAL(*config1.m_maxSuffixLength, 3);
- BOOST_CHECK_EQUAL(config1.m_probeParameterKeys.size(), 1);
- BOOST_CHECK_EQUAL(config1.m_probeParameterKeys.front(), "email");
- BOOST_CHECK_EQUAL(config1.m_cert->getName(),
+ auto& profile1 = profileStorage.m_caItems.front();
+ BOOST_CHECK_EQUAL(profile1.m_caPrefix, "/ndn/edu/ucla");
+ BOOST_CHECK_EQUAL(profile1.m_caInfo, "ndn testbed ca");
+ BOOST_CHECK_EQUAL(profile1.m_maxValidityPeriod, time::seconds(864000));
+ BOOST_CHECK_EQUAL(*profile1.m_maxSuffixLength, 3);
+ BOOST_CHECK_EQUAL(profile1.m_probeParameterKeys.size(), 1);
+ BOOST_CHECK_EQUAL(profile1.m_probeParameterKeys.front(), "email");
+ BOOST_CHECK_EQUAL(profile1.m_cert->getName(),
"/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
- auto& config2 = config.m_caItems.back();
- BOOST_CHECK_EQUAL(config2.m_caPrefix, "/ndn/edu/ucla/zhiyi");
- BOOST_CHECK_EQUAL(config2.m_caInfo, "");
- BOOST_CHECK_EQUAL(config2.m_maxValidityPeriod, time::seconds(86400));
- BOOST_CHECK(!config2.m_maxSuffixLength);
- BOOST_CHECK_EQUAL(config2.m_probeParameterKeys.size(), 0);
- BOOST_CHECK_EQUAL(config2.m_cert->getName(),
+ auto& profile2 = profileStorage.m_caItems.back();
+ BOOST_CHECK_EQUAL(profile2.m_caPrefix, "/ndn/edu/ucla/zhiyi");
+ BOOST_CHECK_EQUAL(profile2.m_caInfo, "");
+ BOOST_CHECK_EQUAL(profile2.m_maxValidityPeriod, time::seconds(86400));
+ BOOST_CHECK(!profile2.m_maxSuffixLength);
+ BOOST_CHECK_EQUAL(profile2.m_probeParameterKeys.size(), 0);
+ BOOST_CHECK_EQUAL(profile2.m_cert->getName(),
"/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
}
-BOOST_AUTO_TEST_CASE(RequesterCaCacheFileWithErrors)
+BOOST_AUTO_TEST_CASE(ProfileStorageWithErrors)
{
- requester::RequesterCaCache config;
+ requester::ProfileStorage profileStorage;
// nonexistent file
- BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/Nonexist"), std::runtime_error);
+ BOOST_CHECK_THROW(profileStorage.load("tests/unit-tests/config-files/Nonexist"), std::runtime_error);
// missing certificate
- BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/config-client-2"), std::runtime_error);
+ BOOST_CHECK_THROW(profileStorage.load("tests/unit-tests/config-files/config-client-2"), std::runtime_error);
// missing ca prefix
- BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/config-client-3"), std::runtime_error);
+ BOOST_CHECK_THROW(profileStorage.load("tests/unit-tests/config-files/config-client-3"), std::runtime_error);
}
-BOOST_AUTO_TEST_CASE(RequesterCaCacheFileAddAndremoveCaProfile)
+BOOST_AUTO_TEST_CASE(ProfileStorageAddAndRemoveProfile)
{
- requester::RequesterCaCache config;
- config.load("tests/unit-tests/config-files/config-client-1");
+ requester::ProfileStorage profileStorage;
+ profileStorage.load("tests/unit-tests/config-files/config-client-1");
CaProfile item;
item.m_caPrefix = Name("/test");
item.m_caInfo = "test";
- config.m_caItems.push_back(item);
- BOOST_CHECK_EQUAL(config.m_caItems.size(), 3);
- auto lastItem = config.m_caItems.back();
+ profileStorage.m_caItems.push_back(item);
+ BOOST_CHECK_EQUAL(profileStorage.m_caItems.size(), 3);
+ auto lastItem = profileStorage.m_caItems.back();
BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/test");
- config.removeCaProfile(Name("/test"));
- BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
- lastItem = config.m_caItems.back();
+ profileStorage.removeCaProfile(Name("/test"));
+ BOOST_CHECK_EQUAL(profileStorage.m_caItems.size(), 2);
+ lastItem = profileStorage.m_caItems.back();
BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/ndn/edu/ucla/zhiyi");
}
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index 18520c8..224ea51 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -289,9 +289,9 @@
static void
selectCaProfile(std::string configFilePath)
{
- RequesterCaCache caCache;
+ ProfileStorage profileStorage;
try {
- caCache.load(configFilePath);
+ profileStorage.load(configFilePath);
}
catch (const std::exception& e) {
std::cerr << "Cannot load the configuration file: " << e.what() << std::endl;
@@ -300,7 +300,7 @@
size_t count = 0;
std::cerr << "***************************************\n"
<< "Step " << nStep++ << ": CA SELECTION" << std::endl;
- for (auto item : caCache.m_caItems) {
+ for (auto item : profileStorage.m_caItems) {
std::cerr << "> Index: " << count++ << std::endl
<< ">> CA prefix:" << item.m_caPrefix << std::endl
<< ">> Introduction: " << item.m_caInfo << std::endl;
@@ -341,7 +341,7 @@
std::cerr << "Your input is not an existing index. Exit" << std::endl;
return;
}
- auto itemIterator = caCache.m_caItems.cbegin();
+ auto itemIterator = profileStorage.m_caItems.cbegin();
std::advance(itemIterator, caIndex);
auto targetCaItem = *itemIterator;
runProbe(targetCaItem);