merge ca config and client config, remove old format of probe

Change-Id: I73500f532f166851d82c1bf1cc008c7ffc241ef3
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 2721811..4caed86 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -37,7 +37,7 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest = MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
@@ -63,10 +63,10 @@
       BOOST_CHECK(security::verifySignature(response, cert));
       auto contentBlock = response.getContent();
       contentBlock.parse();
-      auto caItem = INFO::decodeClientConfigFromContent(contentBlock);
+      auto caItem = INFO::decodeDataContentToCaProfile(contentBlock);
       BOOST_CHECK_EQUAL(caItem.m_caPrefix, "/ndn");
-      BOOST_CHECK_EQUAL(caItem.m_probe, "");
-      BOOST_CHECK_EQUAL(caItem.m_anchor.wireEncode(), cert.wireEncode());
+      BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.size(), 0);
+      BOOST_CHECK_EQUAL(caItem.m_cert->wireEncode(), cert.wireEncode());
       BOOST_CHECK_EQUAL(caItem.m_caInfo, "ndn testbed ca");
     }
   });
@@ -85,14 +85,14 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   // generate NEW Interest
   ClientModule client(m_keyChain);
-  ClientCaItem item;
+  CaConfigItem item;
   item.m_caPrefix = Name("/ndn");
-  item.m_anchor = cert;
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
   auto newInterest = client.generateNewInterest(time::system_clock::now(),
                                                 time::system_clock::now() + time::days(1), Name("/ndn/alice"));
diff --git a/tests/unit-tests/ca-config.t.cpp b/tests/unit-tests/ca-config.t.cpp
deleted file mode 100644
index 2e054cb..0000000
--- a/tests/unit-tests/ca-config.t.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2017-2019, Regents of the University of California.
- *
- * This file is part of ndncert, a certificate management system based on NDN.
- *
- * ndncert is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received copies of the GNU General Public License along with
- * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndncert authors and contributors.
- */
-
-#include "ca-config.hpp"
-#include "protocol-detail/info.hpp"
-#include "test-common.hpp"
-
-namespace ndn {
-namespace ndncert {
-namespace tests {
-
-BOOST_FIXTURE_TEST_SUITE(TestCaConfig, IdentityManagementFixture)
-
-BOOST_AUTO_TEST_CASE(ReadConfigFile)
-{
-  CaConfig config;
-  config.load("tests/unit-tests/ca.conf.test");
-  BOOST_CHECK_EQUAL(config.m_caPrefix, "/ndn");
-  BOOST_CHECK_EQUAL(config.m_caInfo, "ndn testbed ca");
-  BOOST_CHECK_EQUAL(config.m_maxValidityPeriod, time::seconds(86400));
-  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.size(), 1);
-  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.front(), "full name");
-  BOOST_CHECK_EQUAL(config.m_supportedChallenges.size(), 1);
-  BOOST_CHECK_EQUAL(config.m_supportedChallenges.front(), "pin");
-}
-
-BOOST_AUTO_TEST_CASE(ReadNonexistConfigFile)
-{
-  CaConfig config;
-  BOOST_CHECK_THROW(config.load("tests/unit-tests/Nonexist"), std::runtime_error);
-}
-
-BOOST_AUTO_TEST_CASE(ReadConfigFileWithoutCaPrefix)
-{
-  CaConfig config;
-  BOOST_CHECK_THROW(config.load("tests/unit-tests/ca.conf.test2"), std::runtime_error);
-}
-
-BOOST_AUTO_TEST_CASE(ReadConfigFileWithChallengeNotSupported)
-{
-  CaConfig config;
-  BOOST_CHECK_THROW(config.load("tests/unit-tests/ca.conf.test3"), std::runtime_error);
-}
-
-BOOST_AUTO_TEST_CASE(InfoContentEncodingDecoding)
-{
-  CaConfig config;
-  config.load("tests/unit-tests/ca.conf.test");
-
-  const auto& identity = addIdentity("/test");
-  const auto& cert = identity.getDefaultKey().getDefaultCertificate();
-  auto encoded = INFO::encodeDataContent(config, cert);
-  auto decoded = INFO::decodeClientConfigFromContent(encoded);
-  BOOST_CHECK_EQUAL(config.m_caPrefix, decoded.m_caPrefix);
-  BOOST_CHECK_EQUAL(config.m_caInfo, decoded.m_caInfo);
-  BOOST_CHECK_EQUAL(config.m_maxValidityPeriod, decoded.m_maxValidityPeriod);
-  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.size(), decoded.m_probeParameterKeys.size());
-  BOOST_CHECK_EQUAL(config.m_probeParameterKeys.front(), decoded.m_probeParameterKeys.front());
-  BOOST_CHECK_EQUAL(cert.wireEncode(), decoded.m_anchor.wireEncode());
-}
-
-BOOST_AUTO_TEST_SUITE_END()  // TestCaConfig
-
-}  // namespace tests
-}  // namespace ndncert
-}  // namespace ndn
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 365cb90..599b6ce 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -35,8 +35,8 @@
 BOOST_AUTO_TEST_CASE(Initialization)
 {
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
-  BOOST_CHECK_EQUAL(ca.getCaConf().m_caPrefix, "/ndn");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
+  BOOST_CHECK_EQUAL(ca.getCaConf().m_caItem.m_caPrefix, "/ndn");
 
   auto identity = addIdentity(Name("/ndn/site2"));
   auto key = identity.getDefaultKey();
@@ -56,7 +56,7 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest("/ndn/CA/INFO");
@@ -68,10 +68,10 @@
     BOOST_CHECK(security::verifySignature(response, cert));
     auto contentBlock = response.getContent();
     contentBlock.parse();
-    auto caItem = INFO::decodeClientConfigFromContent(contentBlock);
+    auto caItem = INFO::decodeDataContentToCaProfile(contentBlock);
     BOOST_CHECK_EQUAL(caItem.m_caPrefix, "/ndn");
-    BOOST_CHECK_EQUAL(caItem.m_probe, "");
-    BOOST_CHECK_EQUAL(caItem.m_anchor.wireEncode(), cert.wireEncode());
+    BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.size(), 0);
+    BOOST_CHECK_EQUAL(caItem.m_cert->wireEncode(), cert.wireEncode());
     BOOST_CHECK_EQUAL(caItem.m_caInfo, "ndn testbed ca");
   });
   face.receive(interest);
@@ -87,7 +87,7 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   ca.setNameAssignmentFunction([&](const std::vector<std::tuple<std::string, std::string>>) -> std::vector<std::string> {
     std::vector<std::string> result;
     result.push_back("example");
@@ -130,7 +130,7 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   Interest interest("/ndn/CA/PROBE");
@@ -168,13 +168,13 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   ClientModule client(m_keyChain);
-  ClientCaItem item;
+  CaConfigItem item;
   item.m_caPrefix = Name("/ndn");
-  item.m_anchor = cert;
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
 
   auto interest = client.generateNewInterest(time::system_clock::now(),
@@ -219,13 +219,13 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1");
   advanceClocks(time::milliseconds(20), 60);
 
   ClientModule client(m_keyChain);
-  ClientCaItem item;
+  CaConfigItem item;
   item.m_caPrefix = Name("/ndn");
-  item.m_anchor = cert;
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
   auto current_tp = time::system_clock::now();
   auto interest1 = client.generateNewInterest(current_tp, current_tp - time::hours(1),
@@ -255,13 +255,13 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   ClientModule client(m_keyChain);
-  ClientCaItem item;
+  CaConfigItem item;
   item.m_caPrefix = Name("/ndn");
-  item.m_anchor = cert;
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
 
   auto interest1 = client.generateNewInterest(time::system_clock::now(),
@@ -300,13 +300,13 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1");
   advanceClocks(time::milliseconds(20), 60);
 
   ClientModule client(m_keyChain);
-  ClientCaItem item;
+  CaConfigItem item;
   item.m_caPrefix = Name("/ndn");
-  item.m_anchor = cert;
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
   auto current_tp = time::system_clock::now();
   auto interest1 = client.generateNewInterest(current_tp, current_tp + time::days(1), Name("/ndn"));
@@ -330,14 +330,14 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, m_keyChain, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   // generate NEW Interest
   ClientModule client(m_keyChain);
-  ClientCaItem item;
+  CaConfigItem item;
   item.m_caPrefix = Name("/ndn");
-  item.m_anchor = cert;
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
   auto newInterest = client.generateNewInterest(time::system_clock::now(),
                                                 time::system_clock::now() + time::days(1), Name("/ndn/zhiyi"));
@@ -413,7 +413,7 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   //generate a certificate
@@ -432,9 +432,9 @@
   auto issuedCert = ca.issueCertificate(certRequest);
 
   ClientModule client(m_keyChain);
-  ClientCaItem item;
-  item.m_caName = Name("/ndn");
-  item.m_anchor = cert;
+  CaConfigItem item;
+  item.m_caPrefix = Name("/ndn");
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
 
   auto interest = client.generateRevokeInterest(issuedCert);
@@ -477,7 +477,7 @@
   auto cert = key.getDefaultCertificate();
 
   util::DummyClientFace face(io, {true, true});
-  CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
+  CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
   advanceClocks(time::milliseconds(20), 60);
 
   //generate a certificate
@@ -494,9 +494,9 @@
   m_keyChain.sign(clientCert, signingByKey(clientKey.getName()).setSignatureInfo(signatureInfo));
 
   ClientModule client(m_keyChain);
-  ClientCaItem item;
-  item.m_caName = Name("/ndn");
-  item.m_anchor = cert;
+  CaConfigItem item;
+  item.m_caPrefix = Name("/ndn");
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
 
   auto interest = client.generateRevokeInterest(clientCert);
diff --git a/tests/unit-tests/ca.conf.test2 b/tests/unit-tests/ca.conf.test2
deleted file mode 100644
index 22cd83c..0000000
--- a/tests/unit-tests/ca.conf.test2
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-  "ca-info": "ndn testbed ca",
-  "max-validity-period": "86400",
-  "supported-challenges":
-  [
-      { "challenge": "PIN" }
-  ]
-}
\ No newline at end of file
diff --git a/tests/unit-tests/ca.conf.test3 b/tests/unit-tests/ca.conf.test3
deleted file mode 100644
index b330134..0000000
--- a/tests/unit-tests/ca.conf.test3
+++ /dev/null
@@ -1,9 +0,0 @@
-{
-  "ca-prefix": "/ndn",
-  "ca-info": "ndn testbed ca",
-  "max-validity-period": "86400",
-  "supported-challenges":
-  [
-      { "challenge": "ABC" }
-  ]
-}
\ No newline at end of file
diff --git a/tests/unit-tests/client-config.t.cpp b/tests/unit-tests/client-config.t.cpp
deleted file mode 100644
index f23f502..0000000
--- a/tests/unit-tests/client-config.t.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2017-2019, Regents of the University of California.
- *
- * This file is part of ndncert, a certificate management system based on NDN.
- *
- * ndncert is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation, either
- * version 3 of the License, or (at your option) any later version.
- *
- * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received copies of the GNU General Public License along with
- * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndncert authors and contributors.
- */
-
-#include "client-config.hpp"
-#include "test-common.hpp"
-
-namespace ndn {
-namespace ndncert {
-namespace tests {
-
-BOOST_AUTO_TEST_SUITE(TestClientConfig)
-
-BOOST_AUTO_TEST_CASE(ReadConfigFile)
-{
-  ClientConfig config;
-  config.load("tests/unit-tests/client.conf.test");
-  BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
-
-  const auto& item = config.m_caItems.front();
-  BOOST_CHECK_EQUAL(item.m_caPrefix, "/ndn/edu/ucla");
-  BOOST_CHECK_EQUAL(item.m_caInfo, "UCLA's ceritificate authority, located in BH4805.");
-  BOOST_CHECK_EQUAL(item.m_probe, "email");
-  BOOST_CHECK_EQUAL(item.m_anchor.getName(),
-                    "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
-
-  BOOST_CHECK_EQUAL(config.m_localNdncertAnchor, "/usr/local/etc/ndncert/anchor.key");
-}
-
-BOOST_AUTO_TEST_CASE(ReadNonexistConfigFile)
-{
-  ClientConfig config;
-  BOOST_CHECK_THROW(config.load("tests/unit-tests/nonexist"), ClientConfig::Error);
-}
-
-BOOST_AUTO_TEST_CASE(ReadConfigFileWithInvalidCert)
-{
-  ClientConfig config;
-  BOOST_CHECK_THROW(config.load("tests/unit-tests/client.conf.test2"), ClientConfig::Error);
-}
-
-BOOST_AUTO_TEST_CASE(ReadConfigFileWithoutCaPrefix)
-{
-  ClientConfig config;
-  BOOST_CHECK_THROW(config.load("tests/unit-tests/client.conf.test3"), ClientConfig::Error);
-}
-
-BOOST_AUTO_TEST_CASE(AddAndRemoveCaItem)
-{
-  ClientConfig config;
-  config.load("tests/unit-tests/client.conf.test");
-
-  ClientCaItem item;
-  item.m_caPrefix = Name("/test");
-  item.m_caInfo = "test";
-  item.m_probe = "test";
-
-  config.m_caItems.push_back(item);
-  BOOST_CHECK_EQUAL(config.m_caItems.size(), 3);
-  auto lastItem = config.m_caItems.back();
-  BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/test");
-
-  config.removeCaItem(Name("/test"));
-  BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
-  lastItem = config.m_caItems.back();
-  BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/ndn/edu/ucla/zhiyi");
-}
-
-BOOST_AUTO_TEST_SUITE_END() // TestClientConfig
-
-} // namespace tests
-} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/client-module.t.cpp b/tests/unit-tests/client-module.t.cpp
index 159eaaf..e8dccaf 100644
--- a/tests/unit-tests/client-module.t.cpp
+++ b/tests/unit-tests/client-module.t.cpp
@@ -32,26 +32,32 @@
 BOOST_AUTO_TEST_CASE(ClientModuleInitialize)
 {
   ClientModule client(m_keyChain);
-  client.getClientConf().load("tests/unit-tests/client.conf.test");
+  client.getClientConf().load("tests/unit-tests/config-files/config-client-1");
   BOOST_CHECK_EQUAL(client.getClientConf().m_caItems.size(), 2);
 }
 
 BOOST_AUTO_TEST_CASE(Probe)
 {
   ClientModule client(m_keyChain);
-  client.getClientConf().load("tests/unit-tests/client.conf.test");
+  client.getClientConf().load("tests/unit-tests/config-files/config-client-1");
 
   auto identity = addIdentity(Name("/site"));
   auto key = identity.getDefaultKey();
   auto cert = key.getDefaultCertificate();
 
-  ClientCaItem item;
-  item.m_probe = "email:uid:name";
+  CaConfigItem item;
+  item.m_probeParameterKeys.push_back("email");
+  item.m_probeParameterKeys.push_back("uid");
+  item.m_probeParameterKeys.push_back("name");
   item.m_caPrefix = Name("/site");
-  item.m_anchor = cert;
+  item.m_cert = std::make_shared<security::v2::Certificate>(cert);
   client.getClientConf().m_caItems.push_back(item);
 
-  auto firstInterest = client.generateProbeInterest(item, "zhiyi@cs.ucla.edu:987654321:Zhiyi Zhang");
+  std::vector<std::tuple<std::string, std::string>> probeParams;
+  probeParams.push_back(std::make_tuple("email", "zhiyi@cs.ucla.edu"));
+  probeParams.push_back(std::make_tuple("uid", "987654321"));
+  probeParams.push_back(std::make_tuple("name", "Zhiyi Zhang"));
+  auto firstInterest = client.generateProbeInterest(item, std::move(probeParams));
   BOOST_CHECK(firstInterest->getName().at(-1).isParametersSha256Digest());
   // ignore the last name component (ParametersSha256Digest)
   BOOST_CHECK_EQUAL(firstInterest->getName().getPrefix(-1), "/site/CA/PROBE");
@@ -62,16 +68,16 @@
 // BOOST_AUTO_TEST_CASE(GenProbeRequestJson)
 // {
 //   ClientModule client(m_keyChain);
-//   client.getClientConf().load("tests/unit-tests/client.conf.test");
+//   client.getClientConf().load("tests/unit-tests/config-files/config-client-1");
 
 //   auto identity = addIdentity(Name("/site"));
 //   auto key = identity.getDefaultKey();
 //   auto cert = key.getDefaultCertificate();
 
-//   ClientCaItem item;
+//   CaConfigItem item;
 //   item.m_probe = "email:uid:name";
 //   item.m_caPrefix = Name("/site");
-//   item.m_anchor = cert;
+//   item.m_cert = std::make_shared<security::v2::Certificate>(cert);
 //   client.getClientConf().m_caItems.push_back(item);
 
 //   auto interestPacket = client.genProbeRequestJson(item, "yufeng@ucla.edu:123456789:Yufeng Zhang");
diff --git a/tests/unit-tests/client.conf.test2 b/tests/unit-tests/client.conf.test2
deleted file mode 100644
index f3d5630..0000000
--- a/tests/unit-tests/client.conf.test2
+++ /dev/null
@@ -1,18 +0,0 @@
-{
-  "ca-list":
-  [
-    {
-        "ca-prefix": "/ndn/edu/ucla",
-        "ca-info": "UCLA's ceritificate authority, located in BH4805.",
-        "probe": "email",
-        "certificate": "ANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
-    },
-    {
-        "ca-prefix": "/ndn/edu/ucla/zhiyi",
-        "ca-info": "Zhiyi's own ceritificate authority",
-        "probe": "email",
-        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
-    }
-  ],
-  "local-ndncert-anchor": "/usr/local/etc/ndncert/anchor.key"
-}
\ No newline at end of file
diff --git a/tests/unit-tests/client.conf.test3 b/tests/unit-tests/client.conf.test3
deleted file mode 100644
index 257850a..0000000
--- a/tests/unit-tests/client.conf.test3
+++ /dev/null
@@ -1,17 +0,0 @@
-{
-  "ca-list":
-  [
-    {
-        "ca-info": "UCLA's ceritificate authority, located in BH4805.",
-        "probe": "email",
-        "certificate": "ANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
-    },
-    {
-        "ca-prefix": "/ndn/edu/ucla/zhiyi",
-        "ca-info": "Zhiyi's own ceritificate authority",
-        "probe": "email",
-        "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
-    }
-  ],
-  "local-ndncert-anchor": "/usr/local/etc/ndncert/anchor.key"
-}
\ No newline at end of file
diff --git a/tests/unit-tests/ca.conf.test b/tests/unit-tests/config-files/config-ca-1
similarity index 74%
rename from tests/unit-tests/ca.conf.test
rename to tests/unit-tests/config-files/config-ca-1
index bf795fd..8ea5d38 100644
--- a/tests/unit-tests/ca.conf.test
+++ b/tests/unit-tests/config-files/config-ca-1
@@ -1,7 +1,8 @@
 {
   "ca-prefix": "/ndn",
-  "max-validity-period": "86400",
   "ca-info": "ndn testbed ca",
+  "max-validity-period": "864000",
+  "max-suffix-length": 3,
   "probe-parameters":
   [
       { "probe-parameter-key": "full name" }
@@ -9,6 +10,5 @@
   "supported-challenges":
   [
       { "challenge": "PIN" }
-  ],
-  "max-suffix-length": 3
+  ]
 }
\ No newline at end of file
diff --git a/tests/unit-tests/config-files/config-ca-2 b/tests/unit-tests/config-files/config-ca-2
new file mode 100644
index 0000000..9b7c2bd
--- /dev/null
+++ b/tests/unit-tests/config-files/config-ca-2
@@ -0,0 +1,9 @@
+{
+  "ca-prefix": "/ndn",
+  "ca-info": "missing max validity period, max suffix length, and probe",
+  "supported-challenges":
+  [
+      { "challenge": "pin" },
+      { "challenge": "email" }
+  ]
+}
\ No newline at end of file
diff --git a/tests/unit-tests/config-files/config-ca-3 b/tests/unit-tests/config-files/config-ca-3
new file mode 100644
index 0000000..7946ca0
--- /dev/null
+++ b/tests/unit-tests/config-files/config-ca-3
@@ -0,0 +1,10 @@
+{
+  "ca-prefix": "/ndn",
+  "ca-info": "missing challenge",
+  "max-validity-period": "86400",
+  "max-suffix-length": 3,
+  "probe-parameters":
+  [
+      { "probe-parameter-key": "full name" }
+  ]
+}
\ No newline at end of file
diff --git a/tests/unit-tests/ca.conf.test b/tests/unit-tests/config-files/config-ca-4
similarity index 61%
copy from tests/unit-tests/ca.conf.test
copy to tests/unit-tests/config-files/config-ca-4
index bf795fd..98d6c92 100644
--- a/tests/unit-tests/ca.conf.test
+++ b/tests/unit-tests/config-files/config-ca-4
@@ -1,14 +1,14 @@
 {
   "ca-prefix": "/ndn",
+  "ca-info": "unsupported challenge",
   "max-validity-period": "86400",
-  "ca-info": "ndn testbed ca",
+  "max-suffix-length": 3,
   "probe-parameters":
   [
       { "probe-parameter-key": "full name" }
   ],
   "supported-challenges":
   [
-      { "challenge": "PIN" }
-  ],
-  "max-suffix-length": 3
+      { "challenge": "something" }
+  ]
 }
\ No newline at end of file
diff --git a/tests/unit-tests/client.conf.test b/tests/unit-tests/config-files/config-client-1
similarity index 86%
rename from tests/unit-tests/client.conf.test
rename to tests/unit-tests/config-files/config-client-1
index 903c2bd..20daad1 100644
--- a/tests/unit-tests/client.conf.test
+++ b/tests/unit-tests/config-files/config-client-1
@@ -3,16 +3,18 @@
   [
     {
         "ca-prefix": "/ndn/edu/ucla",
-        "ca-info": "UCLA's ceritificate authority, located in BH4805.",
-        "probe": "email",
+        "ca-info": "ndn testbed ca",
+        "max-validity-period": "864000",
+        "max-suffix-length": 3,
+        "probe-parameters":
+        [
+          { "probe-parameter-key": "email" }
+        ],
         "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
     },
     {
         "ca-prefix": "/ndn/edu/ucla/zhiyi",
-        "ca-info": "Zhiyi's own ceritificate authority",
-        "probe": "email",
         "certificate": "Bv0CJAcsCANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
     }
-  ],
-  "local-ndncert-anchor": "/usr/local/etc/ndncert/anchor.key"
+  ]
 }
\ No newline at end of file
diff --git a/tests/unit-tests/config-files/config-client-2 b/tests/unit-tests/config-files/config-client-2
new file mode 100644
index 0000000..4eb3958
--- /dev/null
+++ b/tests/unit-tests/config-files/config-client-2
@@ -0,0 +1,13 @@
+{
+  "ca-list":
+  [
+    {
+        "ca-prefix": "/ndn/edu/ucla",
+        "ca-info": "missing certificate",
+        "probe-parameters":
+        [
+          { "probe-parameter-key": "email" }
+        ]
+    }
+  ]
+}
\ No newline at end of file
diff --git a/tests/unit-tests/config-files/config-client-3 b/tests/unit-tests/config-files/config-client-3
new file mode 100644
index 0000000..66ec4b6
--- /dev/null
+++ b/tests/unit-tests/config-files/config-client-3
@@ -0,0 +1,13 @@
+{
+  "ca-list":
+  [
+    {
+        "ca-info": "missing ca prefix",
+        "probe-parameters":
+        [
+          { "probe-parameter-key": "email" }
+        ],
+        "certificate": "ANuZG4IBXNpdGUxCANLRVkICBG8IvRjFf8XCARzZWxmCAn9AAABWcgU2aUUCRgBAhkEADbugBX9AU8wggFLMIIBAwYHKoZIzj0CATCB9wIBATAsBgcqhkjOPQEBAiEA/////wAAAAEAAAAAAAAAAAAAAAD///////////////8wWwQg/////wAAAAEAAAAAAAAAAAAAAAD///////////////wEIFrGNdiqOpPns+u9VXaYhrxlHQawzFOw9jvOPD4n0mBLAxUAxJ02CIbnBJNqZnjhE50mt4GffpAEQQRrF9Hy4SxCR/i85uVjpEDydwN9gS3rM6D0oTlF2JjClk/jQuL+Gn+bjufrSnwPnhYrzjNXazFezsu2QGg3v1H1AiEA/////wAAAAD//////////7zm+q2nF56E87nKwvxjJVECAQEDQgAES9Cb9iANUNYmwt5bjwNW1mZgjzIkDJb6FTCdiYWnkMMIVxh2YDllphoWDEAPS6kqJczzCuhnGYpZCp9tTaYKGxZMGwEDHB0HGwgDbmRuCAVzaXRlMQgDS0VZCAgRvCL0YxX/F/0A/Sb9AP4PMTk3MDAxMDFUMDAwMDAw/QD/DzIwMzcwMTE3VDIxMjg0NhdIMEYCIQDXkR1hF3GiP7yLXq+0JBJfi9QC+hhAu/1Bykx+MWz6RAIhANwelBTxxZr2C5bD15mjfhWudK4I1tOb4b/9xWCHyM7F"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
new file mode 100644
index 0000000..2c0ca02
--- /dev/null
+++ b/tests/unit-tests/configuration.t.cpp
@@ -0,0 +1,145 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2017-2019, Regents of the University of California.
+ *
+ * This file is part of ndncert, a certificate management system based on NDN.
+ *
+ * ndncert is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * ndncert is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License along with
+ * ndncert, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndncert authors and contributors.
+ */
+
+#include "configuration.hpp"
+#include "protocol-detail/info.hpp"
+#include "test-common.hpp"
+
+namespace ndn {
+namespace ndncert {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestConfig, IdentityManagementFixture)
+
+BOOST_AUTO_TEST_CASE(CAConfigFile)
+{
+  CaConfig config;
+  config.load("tests/unit-tests/config-files/config-ca-1");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_caPrefix, "/ndn");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_caInfo, "ndn testbed ca");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_maxValidityPeriod, time::seconds(864000));
+  BOOST_CHECK_EQUAL(*config.m_caItem.m_maxSuffixLength, 3);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_probeParameterKeys.size(), 1);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_probeParameterKeys.front(), "full name");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_supportedChallenges.size(), 1);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_supportedChallenges.front(), "pin");
+
+  config.load("tests/unit-tests/config-files/config-ca-2");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_caPrefix, "/ndn");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_caInfo, "missing max validity period, max suffix length, and probe");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_maxValidityPeriod, time::seconds(86400));
+  BOOST_CHECK(!config.m_caItem.m_maxSuffixLength);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_probeParameterKeys.size(), 0);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_supportedChallenges.size(), 0);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_supportedChallenges.front(), "pin");
+  BOOST_CHECK_EQUAL(config.m_caItem.m_supportedChallenges.back(), "email");
+}
+
+BOOST_AUTO_TEST_CASE(CAConfigFileWithErrors)
+{
+  CaConfig config;
+  // nonexistent file
+  BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/Nonexist"), std::runtime_error);
+  // missing challenge
+  BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/config-ca-3"), std::runtime_error);
+  // unsupported challenge
+  BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/config-ca-4"), std::runtime_error);
+}
+
+BOOST_AUTO_TEST_CASE(ClientConfigFile)
+{
+  ClientConfig config;
+  config.load("tests/unit-tests/config-files/config-client-1");
+  BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
+
+  auto& config1 = config.m_caItems.front();
+  BOOST_CHECK_EQUAL(config1.m_caPrefix, "/ndn");
+  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(),
+                    "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
+
+  auto& config2 = config.m_caItems.front();
+  BOOST_CHECK_EQUAL(config2.m_caPrefix, "/ndn");
+  BOOST_CHECK_EQUAL(config2.m_caInfo, "ndn testbed ca");
+  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(),
+                    "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
+}
+
+BOOST_AUTO_TEST_CASE(ClientConfigFileWithErrors)
+{
+  ClientConfig config;
+  // nonexistent file
+  BOOST_CHECK_THROW(config.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);
+  // missing ca prefix
+  BOOST_CHECK_THROW(config.load("tests/unit-tests/config-files/config-client-3"), std::runtime_error);
+}
+
+BOOST_AUTO_TEST_CASE(ClientConfigFileAddAndRemoveCaItem)
+{
+  ClientConfig config;
+  config.load("tests/unit-tests/config-files/config-client-1");
+
+  CaConfigItem 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();
+  BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/test");
+
+  config.removeCaItem(Name("/test"));
+  BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
+  lastItem = config.m_caItems.back();
+  BOOST_CHECK_EQUAL(lastItem.m_caPrefix, "/ndn/edu/ucla/zhiyi");
+}
+
+BOOST_AUTO_TEST_CASE(InfoEncodingDecoding)
+{
+  CaConfig config;
+  config.load("tests/unit-tests/config-files/config-ca-1");
+
+  const auto& identity = addIdentity("/test");
+  const auto& cert = identity.getDefaultKey().getDefaultCertificate();
+  auto encoded = INFO::encodeDataContent(config.m_caItem, cert);
+  auto decoded = INFO::decodeDataContentToCaProfile(encoded);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_caPrefix, decoded.m_caPrefix);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_caInfo, decoded.m_caInfo);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_maxValidityPeriod, decoded.m_maxValidityPeriod);
+  BOOST_CHECK_EQUAL(*config.m_caItem.m_maxSuffixLength, *decoded.m_maxSuffixLength);
+  BOOST_CHECK_EQUAL(config.m_caItem.m_probeParameterKeys.size(), decoded.m_probeParameterKeys.size());
+  BOOST_CHECK_EQUAL(config.m_caItem.m_probeParameterKeys.front(), decoded.m_probeParameterKeys.front());
+  BOOST_CHECK_EQUAL(cert.wireEncode(), decoded.m_cert->wireEncode());
+}
+
+BOOST_AUTO_TEST_SUITE_END()  // TestCaConfig
+
+}  // namespace tests
+}  // namespace ndncert
+}  // namespace ndn