list func: update ca config format

Change-Id: I761f6c27d15a7909450a921785923ccbf9b6a597
diff --git a/tests/unit-tests/ca-config.t.cpp b/tests/unit-tests/ca-config.t.cpp
index 532aeeb..24b8536 100644
--- a/tests/unit-tests/ca-config.t.cpp
+++ b/tests/unit-tests/ca-config.t.cpp
@@ -18,8 +18,9 @@
  * See AUTHORS.md for complete list of ndncert authors and contributors.
  */
 
-#include "identity-management-fixture.hpp"
 #include "ca-config.hpp"
+
+#include "identity-management-fixture.hpp"
 #include <ndn-cxx/security/transform/base64-encode.hpp>
 #include <ndn-cxx/security/transform/buffer-source.hpp>
 #include <ndn-cxx/security/transform/stream-sink.hpp>
@@ -34,23 +35,45 @@
 {
   CaConfig config;
   config.load("tests/unit-tests/ca.conf.test");
-  auto itemA = config.m_caItems.front();
-  BOOST_CHECK_EQUAL(itemA.m_caName.toUri(), "/ndn/edu/ucla/cs/zhiyi");
-  BOOST_CHECK(!itemA.m_probe);
-  BOOST_CHECK_EQUAL(itemA.m_freshnessPeriod, time::seconds(720));
-  BOOST_CHECK_EQUAL(itemA.m_validityPeriod, time::days(360));
-  BOOST_CHECK_EQUAL(itemA.m_anchor.toUri(),
-                    "/ndn/edu/ucla/cs/zhiyi/KEY/%9A%E0%C6%C6%09%7C%92i/self/%FD%00%00%01Z%B0%2AJ%B4");
-  BOOST_CHECK_EQUAL(itemA.m_supportedChallenges.size(), 1);
 
-  auto itemB = config.m_caItems.back();
-  BOOST_CHECK_EQUAL(itemB.m_caName.toUri(), "/ndn/site1");
-  BOOST_CHECK(itemB.m_probe);
-  BOOST_CHECK_EQUAL(itemB.m_freshnessPeriod, time::seconds(720));
-  BOOST_CHECK_EQUAL(itemB.m_validityPeriod, time::days(360));
-  BOOST_CHECK_EQUAL(itemB.m_anchor.toUri(),
-                    "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
-  BOOST_CHECK_EQUAL(itemB.m_supportedChallenges.size(), 1);
+  int count = 0;
+  for (auto item : config.m_caItems) {
+    if (item.m_caName.toUri() == "/ndn") {
+      BOOST_CHECK_EQUAL(item.m_freshnessPeriod, time::seconds(720));
+      BOOST_CHECK_EQUAL(item.m_validityPeriod, time::days(360));
+      BOOST_CHECK_EQUAL(item.m_probe, "input email address");
+      BOOST_CHECK_EQUAL(item.m_caInfo, "ndn testbed ca");
+      BOOST_CHECK_EQUAL(item.m_targetedList,
+                        "Use your email address (edu preferred) as input");
+      BOOST_CHECK_EQUAL(item.m_relatedCaList.size(), 2);
+
+      // check related ca
+      auto relatedCaA = item.m_relatedCaList.front();
+      BOOST_CHECK_EQUAL(relatedCaA.m_caName.toUri(), "/ndn/edu/arizona");
+      auto relatedCaB = item.m_relatedCaList.back();
+      BOOST_CHECK_EQUAL(relatedCaB.m_caName.toUri(), "/ndn/edu/memphis");
+
+      BOOST_CHECK_EQUAL(count, 0);
+      count++;
+    }
+    else if (item.m_caName.toUri() == "/ndn/edu/ucla/cs/zhiyi") {
+      BOOST_CHECK_EQUAL(item.m_probe, "");
+      BOOST_CHECK_EQUAL(item.m_freshnessPeriod, time::seconds(720));
+      BOOST_CHECK_EQUAL(item.m_validityPeriod, time::days(360));
+      BOOST_CHECK_EQUAL(item.m_supportedChallenges.size(), 1);
+
+      BOOST_CHECK_EQUAL(count, 1);
+      count++;
+    }
+    else if (item.m_caName.toUri() == "/ndn/site1") {
+      BOOST_CHECK(item.m_probe != "");
+      BOOST_CHECK_EQUAL(item.m_freshnessPeriod, time::seconds(720));
+      BOOST_CHECK_EQUAL(item.m_validityPeriod, time::days(360));
+      BOOST_CHECK_EQUAL(item.m_supportedChallenges.size(), 1);
+
+      BOOST_CHECK_EQUAL(count, 2);
+    }
+  }
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestCaConfig
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 94d636d..fbd7358 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -18,8 +18,9 @@
  * See AUTHORS.md for complete list of ndncert authors and contributors.
  */
 
-#include "database-fixture.hpp"
 #include "ca-module.hpp"
+
+#include "database-fixture.hpp"
 #include "client-module.hpp"
 #include "challenge-module.hpp"
 #include <ndn-cxx/util/dummy-client-face.hpp>
@@ -37,7 +38,7 @@
 {
   util::DummyClientFace face(m_io, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test");
-  BOOST_CHECK_EQUAL(ca.getCaConf().m_caItems.front().m_caName.toUri(), "/ndn/edu/ucla/cs/zhiyi");
+  BOOST_CHECK_EQUAL(ca.getCaConf().m_caItems.front().m_caName.toUri(), "/ndn");
   BOOST_CHECK_EQUAL(ca.getCaConf().m_caItems.back().m_caName.toUri(), "/ndn/site1");
 
   auto identity = addIdentity(Name("/ndn/site2"));
@@ -47,8 +48,8 @@
   BOOST_CHECK_EQUAL(ca.getCaStorage()->getCertificate("111").getIdentity(), Name("/ndn/site2"));
 
   advanceClocks(time::milliseconds(20), 60);
-  BOOST_CHECK_EQUAL(ca.m_registeredPrefixIds.size(), 2);
-  BOOST_CHECK_EQUAL(ca.m_interestFilterIds.size(), 12);
+  BOOST_CHECK_EQUAL(ca.m_registeredPrefixIds.size(), 3);
+  BOOST_CHECK_EQUAL(ca.m_interestFilterIds.size(), 17);
 }
 
 BOOST_AUTO_TEST_CASE(HandleProbe)
@@ -62,7 +63,6 @@
   ca.setProbeHandler([&] (const std::string& probeInfo) {
       return probeInfo;
     });
-  ca.getCaConf().m_caItems.back().m_anchor = cert.getName();
 
   advanceClocks(time::milliseconds(20), 60);
 
@@ -91,7 +91,6 @@
 
   util::DummyClientFace face(m_io, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test");
-  ca.getCaConf().m_caItems.back().m_anchor = cert.getName();
 
   advanceClocks(time::milliseconds(20), 60);
 
@@ -125,7 +124,6 @@
   ca.setProbeHandler([&] (const std::string& probeInfo) {
       return probeInfo;
     });
-  ca.getCaConf().m_caItems.back().m_anchor = cert.getName();
   advanceClocks(time::milliseconds(20), 60);
 
   Name identityName("/ndn/site1");
diff --git a/tests/unit-tests/ca.conf.test b/tests/unit-tests/ca.conf.test
index 87db072..5809613 100644
--- a/tests/unit-tests/ca.conf.test
+++ b/tests/unit-tests/ca.conf.test
@@ -2,10 +2,29 @@
   "ca-list":
   [
     {
+        "ca-prefix": "/ndn",
+        "issuing-freshness": "720",
+        "validity-period": "360",
+        "ca-info": "ndn testbed ca",
+
+        "probe": "input email address",
+
+        "targeted-list": "Use your email address (edu preferred) as input",
+        "related-ca-list":
+        [
+          { "ca-prefix": "/ndn/edu/arizona" },
+          { "ca-prefix": "/ndn/edu/memphis" }
+        ],
+
+        "supported-challenges":
+        [
+            { "type": "PIN" }
+        ]
+    },
+    {
         "ca-prefix": "/ndn/edu/ucla/cs/zhiyi",
         "issuing-freshness": "720",
         "validity-period": "360",
-        "ca-anchor": "/ndn/edu/ucla/cs/zhiyi/KEY/%9A%E0%C6%C6%09%7C%92i/self/%FD%00%00%01Z%B0%2AJ%B4",
         "supported-challenges":
         [
             { "type": "PIN" }
@@ -13,10 +32,9 @@
     },
     {
         "ca-prefix": "/ndn/site1",
-        "probe": "true",
+        "probe": "input email address",
         "issuing-freshness": "720",
         "validity-period": "360",
-        "ca-anchor": "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5",
         "supported-challenges":
         [
             { "type": "PIN" }