rib: error out if both localhop_security and auto_prefix_propagate are enabled

Refs: #4989
Change-Id: Ib742880736a8f5c25e2531d2669a8b993f9f1cd6
diff --git a/tests/daemon/rib/service.t.cpp b/tests/daemon/rib/service.t.cpp
index 80b0c38..4832afd 100644
--- a/tests/daemon/rib/service.t.cpp
+++ b/tests/daemon/rib/service.t.cpp
@@ -29,37 +29,93 @@
 #include "tests/test-common.hpp"
 #include "tests/daemon/rib-io-fixture.hpp"
 
+#include <boost/property_tree/info_parser.hpp>
+#include <sstream>
+
 namespace nfd {
 namespace rib {
 namespace tests {
 
 using namespace nfd::tests;
 
-BOOST_FIXTURE_TEST_SUITE(TestService, RibIoFixture)
+class RibServiceFixture : public RibIoFixture
+{
+protected:
+  static ConfigSection
+  makeSection(const std::string& text, bool wantUnixSocketPath = true)
+  {
+    std::istringstream is(text);
+    ConfigSection section;
+    boost::property_tree::read_info(is, section);
+    if (wantUnixSocketPath)
+      section.put("face_system.unix.path", "/dev/null");
+    return section;
+  }
+
+protected:
+  ndn::KeyChain m_ribKeyChain;
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestService, RibServiceFixture)
 
 BOOST_AUTO_TEST_CASE(Basic)
 {
-  ConfigSection section;
-  section.put("face_system.unix.path", "/var/run/nfd.sock");
-
-  ndn::KeyChain ribKeyChain;
+  auto section = makeSection("");
 
   BOOST_CHECK_THROW(Service::get(), std::logic_error);
-  BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
+  BOOST_CHECK_THROW(Service(section, m_ribKeyChain), std::logic_error);
 
   runOnRibIoService([&] {
     {
       BOOST_CHECK_THROW(Service::get(), std::logic_error);
-      Service ribService(section, ribKeyChain);
+      Service ribService(section, m_ribKeyChain);
       BOOST_CHECK_EQUAL(&ribService, &Service::get());
     }
     BOOST_CHECK_THROW(Service::get(), std::logic_error);
-    Service ribService(section, ribKeyChain);
-    BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
+    Service ribService(section, m_ribKeyChain);
+    BOOST_CHECK_THROW(Service(section, m_ribKeyChain), std::logic_error);
   });
+  poll();
 }
 
-BOOST_AUTO_TEST_SUITE_END() // TestRibService
+BOOST_AUTO_TEST_SUITE(ProcessConfig)
+
+BOOST_AUTO_TEST_CASE(LocalhopAndPropagate)
+{
+  const std::string CONFIG = R"CONFIG(
+    rib
+    {
+      localhost_security
+      {
+        trust-anchor
+        {
+          type any
+        }
+      }
+      localhop_security
+      {
+        trust-anchor
+        {
+          type any
+        }
+      }
+      auto_prefix_propagate
+    }
+  )CONFIG";
+
+  runOnRibIoService([&] {
+    BOOST_CHECK_EXCEPTION(Service(makeSection(CONFIG), m_ribKeyChain), ConfigFile::Error,
+                          [] (const auto& e) {
+                            return e.what() == "localhop_security and auto_prefix_propagate "
+                                               "cannot be enabled at the same time"s;
+                          });
+  });
+  poll();
+}
+
+BOOST_AUTO_TEST_SUITE_END() // ProcessConfig
+
+BOOST_AUTO_TEST_SUITE_END() // TestService
 
 } // namespace tests
 } // namespace rib