rib: move config parsing to Service class

This commit also de-duplicates code in Service class constructors
and reduces usage of unique_ptrs.

refs #4650

Change-Id: Ibbf454841b76ffe4d569b51fef3b1d06f7d2fdfc
diff --git a/tests/rib/rib-manager.t.cpp b/tests/rib/rib-manager.t.cpp
index 77b1ed3..44b7b29 100644
--- a/tests/rib/rib-manager.t.cpp
+++ b/tests/rib/rib-manager.t.cpp
@@ -45,6 +45,14 @@
   bool isLocalhopConfigured;
 };
 
+static ConfigSection
+getValidatorConfigSection()
+{
+  ConfigSection section;
+  section.put("trust-anchor.type", "any");
+  return section;
+}
+
 class RibManagerFixture : public ManagerCommonFixture
 {
 public:
@@ -55,40 +63,19 @@
     , m_status(status)
     , m_nfdController(m_face, m_keyChain)
     , m_fibUpdater(m_rib, m_nfdController)
-    , m_prefixPropagator(m_nfdController, m_keyChain, m_rib)
-    , m_manager(m_rib, m_dispatcher, m_face, m_nfdController, m_prefixPropagator)
+    , m_manager(m_rib, m_face, m_nfdController, m_dispatcher)
   {
     m_rib.m_onSendBatchFromQueue = bind(&RibManagerFixture::onSendBatchFromQueue, this, _1);
 
-    const std::string prefix = "rib\n{\n";
-    const std::string suffix = "}";
-    const std::string localhostSection = "  localhost_security\n"
-    "  {\n"
-    "    trust-anchor\n"
-    "    {\n"
-    "      type any\n"
-    "    }\n"
-    "  }\n";
-    const std::string localhopSection = "  localhop_security\n"
-    "  {\n"
-    "    trust-anchor\n"
-    "    {\n"
-    "      type any\n"
-    "    }\n"
-    "  }\n";
-
-    std::string ribSection = "";
     if (m_status.isLocalhostConfigured) {
-      ribSection += localhostSection;
+      m_manager.applyLocalhostConfig(getValidatorConfigSection(), "test");
     }
     if (m_status.isLocalhopConfigured) {
-      ribSection += localhopSection;
+      m_manager.enableLocalhop(getValidatorConfigSection(), "test");
     }
-    const std::string CONFIG_STR = prefix + ribSection + suffix;
-
-    ConfigFile config;
-    m_manager.setConfigFile(config);
-    config.parse(CONFIG_STR, true, "test-rib");
+    else {
+      m_manager.disableLocalhop();
+    }
 
     registerWithNfd();
 
@@ -231,7 +218,6 @@
   ndn::nfd::Controller m_nfdController;
   Rib m_rib;
   FibUpdater m_fibUpdater;
-  AutoPrefixPropagator m_prefixPropagator;
   RibManager m_manager;
 };
 
diff --git a/tests/rib/rib-service.t.cpp b/tests/rib/service.t.cpp
similarity index 85%
rename from tests/rib/rib-service.t.cpp
rename to tests/rib/service.t.cpp
index 5bfe5b9..14ee649 100644
--- a/tests/rib/rib-service.t.cpp
+++ b/tests/rib/service.t.cpp
@@ -35,21 +35,23 @@
 
 BOOST_AUTO_TEST_CASE(Basic)
 {
+  ConfigSection section;
+  section.put("face_system.unix.path", "/var/run/nfd.sock");
+
   ndn::KeyChain ribKeyChain;
-  const std::string configFile;
 
   BOOST_CHECK_THROW(Service::get(), std::logic_error);
-  BOOST_CHECK_THROW(Service(configFile, ribKeyChain), std::logic_error);
+  BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
 
   runOnRibIoService([&] {
     {
       BOOST_CHECK_THROW(Service::get(), std::logic_error);
-      Service ribService(configFile, ribKeyChain);
+      Service ribService(section, ribKeyChain);
       BOOST_CHECK_EQUAL(&ribService, &Service::get());
     }
     BOOST_CHECK_THROW(Service::get(), std::logic_error);
-    Service ribService(configFile, ribKeyChain);
-    BOOST_CHECK_THROW(Service(configFile, ribKeyChain), std::logic_error);
+    Service ribService(section, ribKeyChain);
+    BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
   });
 }