tests: minor code cleanups

Change-Id: I9759ba4b7eb467d4d1df4b379efad91bc4f5cc3a
diff --git a/tests/daemon/mgmt/command-authenticator.t.cpp b/tests/daemon/mgmt/command-authenticator.t.cpp
index 051d7c9..3c2d59d 100644
--- a/tests/daemon/mgmt/command-authenticator.t.cpp
+++ b/tests/daemon/mgmt/command-authenticator.t.cpp
@@ -27,22 +27,15 @@
 
 #include "manager-common-fixture.hpp"
 
-#include <boost/filesystem.hpp>
-
 namespace nfd::tests {
 
-class CommandAuthenticatorFixture : public CommandInterestSignerFixture
+class CommandAuthenticatorFixture : public InterestSignerFixture
 {
 protected:
-  CommandAuthenticatorFixture()
-    : authenticator(CommandAuthenticator::create())
-  {
-  }
-
   void
   makeModules(std::initializer_list<std::string> modules)
   {
-    for (const std::string& module : modules) {
+    for (const auto& module : modules) {
       authorizations.emplace(module, authenticator->makeAuthorization(module, "verb"));
     }
   }
@@ -50,10 +43,9 @@
   void
   loadConfig(const std::string& config)
   {
-    auto configPath = boost::filesystem::current_path() / "command-authenticator-test.conf";
     ConfigFile cf;
     authenticator->setConfigFile(cf);
-    cf.parse(config, false, configPath.c_str());
+    cf.parse(config, false, "command-authenticator-test.conf");
   }
 
   bool
@@ -66,7 +58,7 @@
       modifyInterest(interest);
     }
 
-    ndn::mgmt::Authorization authorization = authorizations.at(module);
+    const auto& authorization = authorizations.at(module);
 
     bool isAccepted = false;
     bool isRejected = false;
@@ -91,7 +83,7 @@
   }
 
 protected:
-  shared_ptr<CommandAuthenticator> authenticator;
+  shared_ptr<CommandAuthenticator> authenticator = CommandAuthenticator::create();
   std::unordered_map<std::string, ndn::mgmt::Authorization> authorizations;
   std::string lastRequester;
   ndn::mgmt::RejectReply lastRejectReply;
@@ -110,7 +102,7 @@
   BOOST_REQUIRE(saveIdentityCert(id2, "2.ndncert", true));
 
   makeModules({"module0", "module1", "module2", "module3", "module4", "module5", "module6", "module7"});
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       authorize
@@ -199,7 +191,7 @@
   BOOST_REQUIRE(saveIdentityCert(id1, "1.ndncert", true));
 
   makeModules({"module0", "module1"});
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       authorize
@@ -238,12 +230,11 @@
 {
 protected:
   IdentityAuthorizedFixture()
-    : id1("/localhost/CommandAuthenticator/1")
   {
     BOOST_REQUIRE(saveIdentityCert(id1, "1.ndncert", true));
 
     makeModules({"module1"});
-    const std::string& config = R"CONFIG(
+    const std::string config = R"CONFIG(
       authorizations
       {
         authorize
@@ -266,10 +257,10 @@
   }
 
 protected:
-  Name id1;
+  const Name id1{"/localhost/CommandAuthenticator/1"};
 };
 
-BOOST_FIXTURE_TEST_SUITE(Rejects, IdentityAuthorizedFixture)
+BOOST_FIXTURE_TEST_SUITE(Reject, IdentityAuthorizedFixture)
 
 BOOST_AUTO_TEST_CASE(BadKeyLocator_NameTooShort)
 {
@@ -281,7 +272,7 @@
   BOOST_CHECK(lastRejectReply == ndn::mgmt::RejectReply::SILENT);
 }
 
-BOOST_AUTO_TEST_CASE(BadKeyLocator_BadSigInfo)
+BOOST_AUTO_TEST_CASE(BadSigInfo)
 {
   BOOST_CHECK_EQUAL(authorize1(
     [] (Interest& interest) {
@@ -291,7 +282,7 @@
   BOOST_CHECK(lastRejectReply == ndn::mgmt::RejectReply::SILENT);
 }
 
-BOOST_AUTO_TEST_CASE(BadKeyLocator_MissingKeyLocator)
+BOOST_AUTO_TEST_CASE(MissingKeyLocator)
 {
   BOOST_CHECK_EQUAL(authorize1(
     [] (Interest& interest) {
@@ -302,7 +293,7 @@
   BOOST_CHECK(lastRejectReply == ndn::mgmt::RejectReply::SILENT);
 }
 
-BOOST_AUTO_TEST_CASE(BadKeyLocator_BadKeyLocatorType)
+BOOST_AUTO_TEST_CASE(BadKeyLocatorType)
 {
   BOOST_CHECK_EQUAL(authorize1(
     [] (Interest& interest) {
@@ -364,13 +355,13 @@
   BOOST_CHECK(lastRejectReply == ndn::mgmt::RejectReply::STATUS403);
 }
 
-BOOST_AUTO_TEST_SUITE_END() // Rejects
+BOOST_AUTO_TEST_SUITE_END() // Reject
 
 BOOST_AUTO_TEST_SUITE(BadConfig)
 
 BOOST_AUTO_TEST_CASE(EmptyAuthorizationsSection)
 {
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
     }
@@ -381,7 +372,7 @@
 
 BOOST_AUTO_TEST_CASE(UnrecognizedKey)
 {
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       unrecognized_key
@@ -395,7 +386,7 @@
 
 BOOST_AUTO_TEST_CASE(CertfileMissing)
 {
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       authorize
@@ -412,7 +403,7 @@
 
 BOOST_AUTO_TEST_CASE(CertUnreadable)
 {
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       authorize
@@ -430,7 +421,7 @@
 
 BOOST_AUTO_TEST_CASE(PrivilegesMissing)
 {
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       authorize
@@ -445,7 +436,7 @@
 
 BOOST_AUTO_TEST_CASE(UnregisteredModule)
 {
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       authorize
diff --git a/tests/daemon/mgmt/cs-manager.t.cpp b/tests/daemon/mgmt/cs-manager.t.cpp
index 4f7b51b..fa9b6c5 100644
--- a/tests/daemon/mgmt/cs-manager.t.cpp
+++ b/tests/daemon/mgmt/cs-manager.t.cpp
@@ -63,7 +63,7 @@
   m_cs.enableServe(true);
 
   // send empty cs/config command
-  auto req = makeControlCommandRequest(cmdPrefix, ControlParameters());
+  auto req = makeControlCommandRequest(cmdPrefix);
   receiveInterest(req);
 
   // response shall reflect current config
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.hpp b/tests/daemon/mgmt/face-manager-command-fixture.hpp
index de28f3b..ad354f3 100644
--- a/tests/daemon/mgmt/face-manager-command-fixture.hpp
+++ b/tests/daemon/mgmt/face-manager-command-fixture.hpp
@@ -57,12 +57,12 @@
   FaceManager manager;
 };
 
-class FaceManagerCommandFixture : public CommandInterestSignerFixture
+class FaceManagerCommandFixture : public InterestSignerFixture
 {
 public:
   FaceManagerCommandFixture();
 
-  ~FaceManagerCommandFixture();
+  ~FaceManagerCommandFixture() override;
 
 public:
   FaceManagerCommandNode node1; // used to test FaceManager
diff --git a/tests/daemon/mgmt/manager-base.t.cpp b/tests/daemon/mgmt/manager-base.t.cpp
index dba2dd8..ce74b1c 100644
--- a/tests/daemon/mgmt/manager-base.t.cpp
+++ b/tests/daemon/mgmt/manager-base.t.cpp
@@ -27,11 +27,6 @@
 
 #include "manager-common-fixture.hpp"
 
-#include <ndn-cxx/security/key-chain.hpp>
-#include <ndn-cxx/security/pib/identity.hpp>
-#include <ndn-cxx/security/pib/key.hpp>
-#include <ndn-cxx/security/pib/pib.hpp>
-
 namespace nfd::tests {
 
 class TestCommandVoidParameters : public ControlCommand
@@ -86,35 +81,35 @@
 
 BOOST_AUTO_TEST_CASE(RegisterCommandHandler)
 {
-  bool wasCommandHandlerCalled = false;
-  auto handler = [&] (auto&&...) { wasCommandHandlerCalled = true; };
+  bool wasHandlerCalled = false;
+  auto handler = [&] (auto&&...) { wasHandlerCalled = true; };
 
   m_manager.registerCommandHandler<TestCommandVoidParameters>("test-void", handler);
   m_manager.registerCommandHandler<TestCommandRequireName>("test-require-name", handler);
   setTopPrefix();
 
-  auto testRegisterCommandHandler = [&wasCommandHandlerCalled, this] (const Name& commandName) {
-    wasCommandHandlerCalled = false;
-    receiveInterest(makeControlCommandRequest(commandName, ControlParameters()));
+  auto testRegisterCommandHandler = [&] (const Name& commandName) {
+    wasHandlerCalled = false;
+    receiveInterest(makeControlCommandRequest(commandName));
   };
 
   testRegisterCommandHandler("/localhost/nfd/test-module/test-void");
-  BOOST_CHECK(wasCommandHandlerCalled);
+  BOOST_CHECK(wasHandlerCalled);
 
   testRegisterCommandHandler("/localhost/nfd/test-module/test-require-name");
-  BOOST_CHECK(!wasCommandHandlerCalled);
+  BOOST_CHECK(!wasHandlerCalled);
 }
 
 BOOST_AUTO_TEST_CASE(RegisterStatusDataset)
 {
-  bool isStatusDatasetCalled = false;
-  auto handler = [&] (auto&&...) { isStatusDatasetCalled = true; };
+  bool wasHandlerCalled = false;
+  auto handler = [&] (auto&&...) { wasHandlerCalled = true; };
 
   m_manager.registerStatusDatasetHandler("test-status", handler);
   setTopPrefix();
 
   receiveInterest(*makeInterest("/localhost/nfd/test-module/test-status", true));
-  BOOST_CHECK(isStatusDatasetCalled);
+  BOOST_CHECK(wasHandlerCalled);
 }
 
 BOOST_AUTO_TEST_CASE(RegisterNotificationStream)
@@ -136,13 +131,13 @@
   auto testAccept = [&] (const std::string& requester) { requesterName = requester; };
 
   m_manager.extractRequester(Interest("/test/interest/unsigned"), testAccept);
-  BOOST_CHECK(requesterName.empty());
+  BOOST_CHECK_EQUAL(requesterName, "");
 
-  requesterName = "";
-  m_manager.extractRequester(makeControlCommandRequest("/test/interest/signed", ControlParameters()), testAccept);
+  requesterName.clear();
+  m_manager.extractRequester(makeControlCommandRequest("/test/interest/signed"), testAccept);
   BOOST_CHECK_EQUAL(requesterName,
-    m_keyChain.getPib().getIdentity(DEFAULT_COMMAND_SIGNER_IDENTITY)
-      .getDefaultKey().getDefaultCertificate().getName().toUri());
+                    m_keyChain.getPib().getIdentity(DEFAULT_COMMAND_SIGNER_IDENTITY)
+                    .getDefaultKey().getDefaultCertificate().getName().toUri());
 }
 
 BOOST_AUTO_TEST_CASE(ValidateParameters)
diff --git a/tests/daemon/mgmt/manager-common-fixture.cpp b/tests/daemon/mgmt/manager-common-fixture.cpp
index 8be600c..b427a3e 100644
--- a/tests/daemon/mgmt/manager-common-fixture.cpp
+++ b/tests/daemon/mgmt/manager-common-fixture.cpp
@@ -27,34 +27,26 @@
 
 namespace nfd::tests {
 
-CommandInterestSignerFixture::CommandInterestSignerFixture()
-  : m_signer(m_keyChain)
+InterestSignerFixture::InterestSignerFixture()
 {
   BOOST_REQUIRE(m_keyChain.createIdentity(DEFAULT_COMMAND_SIGNER_IDENTITY));
 }
 
 Interest
-CommandInterestSignerFixture::makeCommandInterest(const Name& name, const Name& identity)
+InterestSignerFixture::makeCommandInterest(const Name& name, const Name& identity)
 {
   return m_signer.makeCommandInterest(name, ndn::security::signingByIdentity(identity));
 }
 
 Interest
-CommandInterestSignerFixture::makeControlCommandRequest(Name commandName,
-                                                        const ControlParameters& params,
-                                                        const Name& identity)
+InterestSignerFixture::makeControlCommandRequest(Name commandName,
+                                                 const ControlParameters& params,
+                                                 const Name& identity)
 {
   commandName.append(tlv::GenericNameComponent, params.wireEncode());
   return this->makeCommandInterest(commandName, identity);
 }
 
-ManagerCommonFixture::ManagerCommonFixture()
-  : m_face(g_io, m_keyChain, {true, true})
-  , m_dispatcher(m_face, m_keyChain, ndn::security::SigningInfo())
-  , m_responses(m_face.sentData)
-{
-}
-
 void
 ManagerCommonFixture::setTopPrefix()
 {
@@ -192,7 +184,7 @@
 {
   saveIdentityCert(DEFAULT_COMMAND_SIGNER_IDENTITY, "ManagerCommonFixture.ndncert");
 
-  const std::string& config = R"CONFIG(
+  const std::string config = R"CONFIG(
     authorizations
     {
       authorize
diff --git a/tests/daemon/mgmt/manager-common-fixture.hpp b/tests/daemon/mgmt/manager-common-fixture.hpp
index 79923a0..2ae3b85 100644
--- a/tests/daemon/mgmt/manager-common-fixture.hpp
+++ b/tests/daemon/mgmt/manager-common-fixture.hpp
@@ -38,12 +38,13 @@
 
 namespace nfd::tests {
 
-/** \brief A fixture that wraps an InterestSigner.
+/**
+ * \brief A fixture that wraps an InterestSigner.
  */
-class CommandInterestSignerFixture : public GlobalIoTimeFixture, public KeyChainFixture
+class InterestSignerFixture : public GlobalIoTimeFixture, public KeyChainFixture
 {
 protected:
-  CommandInterestSignerFixture();
+  InterestSignerFixture();
 
   /** \brief sign a command Interest
    *  \param name command name include prefix and parameters
@@ -60,24 +61,23 @@
    *  \return a command Interest
    */
   Interest
-  makeControlCommandRequest(Name commandName, const ControlParameters& params,
+  makeControlCommandRequest(Name commandName,
+                            const ControlParameters& params = {},
                             const Name& identity = DEFAULT_COMMAND_SIGNER_IDENTITY);
 
 protected:
-  static inline const Name DEFAULT_COMMAND_SIGNER_IDENTITY{"/CommandInterestSignerFixture-identity"};
+  static inline const Name DEFAULT_COMMAND_SIGNER_IDENTITY{"/InterestSignerFixture-identity"};
 
 private:
-  ndn::security::InterestSigner m_signer;
+  ndn::security::InterestSigner m_signer{m_keyChain};
 };
 
 /**
  * @brief A collection of common functions shared by all manager's test fixtures.
  */
-class ManagerCommonFixture : public CommandInterestSignerFixture
+class ManagerCommonFixture : public InterestSignerFixture
 {
 public: // initialize
-  ManagerCommonFixture();
-
   /**
    * @brief Add `/localhost/nfd` as a top prefix to the dispatcher.
    *
@@ -99,11 +99,10 @@
   receiveInterest(const Interest& interest);
 
 public: // verify
-  ControlResponse
+  static ControlResponse
   makeResponse(uint32_t code, const std::string& text, const ControlParameters& parameters);
 
-  enum class CheckResponseResult
-  {
+  enum class CheckResponseResult {
     OK,
     OUT_OF_BOUNDARY,
     WRONG_NAME,
@@ -153,9 +152,9 @@
   concatenateResponses(size_t startIndex = 0, size_t nResponses = 0);
 
 protected:
-  ndn::util::DummyClientFace m_face;
-  Dispatcher m_dispatcher;
-  std::vector<Data>& m_responses; ///< a reference to m_face.sentData
+  ndn::util::DummyClientFace m_face{g_io, m_keyChain, {true, true}};
+  Dispatcher m_dispatcher{m_face, m_keyChain};
+  std::vector<Data>& m_responses{m_face.sentData};
 };
 
 std::ostream&
diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
index 9a06393..78589a2 100644
--- a/tests/daemon/mgmt/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.cpp
@@ -135,12 +135,14 @@
     ndn::security::MakeCertificateOptions opts;
     opts.validity = derivedSelfSigned.getValidityPeriod();
     auto derivedCert = m_keyChain.makeCertificate(derivedSelfSigned,
-                       ndn::security::signingByIdentity(anchorIdentity), opts);
+                                                  ndn::security::signingByIdentity(anchorIdentity),
+                                                  opts);
     m_keyChain.setDefaultCertificate(derivedKey, derivedCert);
 
     if (m_status.isLocalhostConfigured) {
       m_manager.applyLocalhostConfig(getValidatorConfigSection(), "test");
     }
+
     if (m_status.isLocalhopConfigured) {
       m_manager.enableLocalhop(getLocalhopValidatorConfigSection(), "test");
     }
@@ -173,19 +175,20 @@
     auto replyFibAddCommand = [this] (const Interest& interest) {
       ControlParameters params(interest.getName().get(-5).blockFromValue());
       BOOST_CHECK(params.getName() == "/localhost/nfd/rib" || params.getName() == "/localhop/nfd/rib");
-      params.setFaceId(1).setCost(0);
+      params.setFaceId(1)
+            .setCost(0);
       ControlResponse resp;
+      resp.setCode(200)
+          .setBody(params.wireEncode());
 
-      resp.setCode(200).setBody(params.wireEncode());
-      shared_ptr<Data> data = make_shared<Data>(interest.getName());
+      auto data = make_shared<Data>(interest.getName());
       data->setContent(resp.wireEncode());
-
       m_keyChain.sign(*data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256));
 
       m_face.getIoService().post([this, data] { m_face.receive(*data); });
     };
 
-    Name commandPrefix("/localhost/nfd/fib/add-nexthop");
+    const Name commandPrefix("/localhost/nfd/fib/add-nexthop");
     for (const auto& command : m_face.sentInterests) {
       if (commandPrefix.isPrefixOf(command.getName())) {
         replyFibAddCommand(command);