mgmt: merge ManagerBase with NfdManagerBase
Refs: #4528
Change-Id: I2ecb4af68927157a9eafc269399855cff192bb54
diff --git a/daemon/mgmt/cs-manager.cpp b/daemon/mgmt/cs-manager.cpp
index 60099d2..50c3001 100644
--- a/daemon/mgmt/cs-manager.cpp
+++ b/daemon/mgmt/cs-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -24,17 +24,20 @@
*/
#include "cs-manager.hpp"
+#include "fw/forwarder-counters.hpp"
+#include "table/cs.hpp"
+
#include <ndn-cxx/mgmt/nfd/cs-info.hpp>
namespace nfd {
constexpr size_t CsManager::ERASE_LIMIT;
-CsManager::CsManager(Cs& cs, const ForwarderCounters& fwCnt,
+CsManager::CsManager(Cs& cs, const ForwarderCounters& fwCounters,
Dispatcher& dispatcher, CommandAuthenticator& authenticator)
- : NfdManagerBase(dispatcher, authenticator, "cs")
+ : ManagerBase("cs", dispatcher, authenticator)
, m_cs(cs)
- , m_fwCnt(fwCnt)
+ , m_fwCounters(fwCounters)
{
registerCommandHandler<ndn::nfd::CsConfigCommand>("config",
bind(&CsManager::changeConfig, this, _4, _5));
@@ -106,8 +109,8 @@
info.setEnableAdmit(m_cs.shouldAdmit());
info.setEnableServe(m_cs.shouldServe());
info.setNEntries(m_cs.size());
- info.setNHits(m_fwCnt.nCsHits);
- info.setNMisses(m_fwCnt.nCsMisses);
+ info.setNHits(m_fwCounters.nCsHits);
+ info.setNMisses(m_fwCounters.nCsMisses);
context.append(info.wireEncode());
context.end();
diff --git a/daemon/mgmt/cs-manager.hpp b/daemon/mgmt/cs-manager.hpp
index e1d2bbd..83db017 100644
--- a/daemon/mgmt/cs-manager.hpp
+++ b/daemon/mgmt/cs-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,19 +26,24 @@
#ifndef NFD_DAEMON_MGMT_CS_MANAGER_HPP
#define NFD_DAEMON_MGMT_CS_MANAGER_HPP
-#include "nfd-manager-base.hpp"
-#include "table/cs.hpp"
-#include "fw/forwarder-counters.hpp"
+#include "manager-base.hpp"
namespace nfd {
-/** \brief Implement the CS Management of NFD Management Protocol.
- * \sa https://redmine.named-data.net/projects/nfd/wiki/CsMgmt
+namespace cs {
+class Cs;
+} // namespace cs
+
+class ForwarderCounters;
+
+/**
+ * \brief Implements the CS Management of NFD Management Protocol.
+ * \sa https://redmine.named-data.net/projects/nfd/wiki/CsMgmt
*/
-class CsManager : public NfdManagerBase
+class CsManager : public ManagerBase
{
public:
- CsManager(Cs& cs, const ForwarderCounters& fwCnt,
+ CsManager(cs::Cs& cs, const ForwarderCounters& fwCounters,
Dispatcher& dispatcher, CommandAuthenticator& authenticator);
private:
@@ -64,8 +69,8 @@
static constexpr size_t ERASE_LIMIT = 256;
private:
- Cs& m_cs;
- const ForwarderCounters& m_fwCnt;
+ cs::Cs& m_cs;
+ const ForwarderCounters& m_fwCounters;
};
} // namespace nfd
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index 2299927..b7b22f2 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -41,9 +41,8 @@
NFD_LOG_INIT(FaceManager);
FaceManager::FaceManager(FaceSystem& faceSystem,
- Dispatcher& dispatcher,
- CommandAuthenticator& authenticator)
- : NfdManagerBase(dispatcher, authenticator, "faces")
+ Dispatcher& dispatcher, CommandAuthenticator& authenticator)
+ : ManagerBase("faces", dispatcher, authenticator)
, m_faceSystem(faceSystem)
, m_faceTable(faceSystem.getFaceTable())
{
diff --git a/daemon/mgmt/face-manager.hpp b/daemon/mgmt/face-manager.hpp
index 778e824..620ab99 100644
--- a/daemon/mgmt/face-manager.hpp
+++ b/daemon/mgmt/face-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,21 +26,20 @@
#ifndef NFD_DAEMON_MGMT_FACE_MANAGER_HPP
#define NFD_DAEMON_MGMT_FACE_MANAGER_HPP
-#include "nfd-manager-base.hpp"
+#include "manager-base.hpp"
#include "face/face-system.hpp"
namespace nfd {
/**
- * @brief implement the Face Management of NFD Management Protocol.
+ * @brief Implements the Face Management of NFD Management Protocol.
* @sa https://redmine.named-data.net/projects/nfd/wiki/FaceMgmt
*/
-class FaceManager : public NfdManagerBase
+class FaceManager : public ManagerBase
{
public:
FaceManager(FaceSystem& faceSystem,
- Dispatcher& dispatcher,
- CommandAuthenticator& authenticator);
+ Dispatcher& dispatcher, CommandAuthenticator& authenticator);
private: // ControlCommand
void
diff --git a/daemon/mgmt/fib-manager.cpp b/daemon/mgmt/fib-manager.cpp
index b73698d..8fef3a3 100644
--- a/daemon/mgmt/fib-manager.cpp
+++ b/daemon/mgmt/fib-manager.cpp
@@ -27,6 +27,7 @@
#include "core/logger.hpp"
#include "fw/face-table.hpp"
+#include "table/fib.hpp"
#include <ndn-cxx/lp/tags.hpp>
#include <ndn-cxx/mgmt/nfd/fib-entry.hpp>
@@ -37,11 +38,9 @@
NFD_LOG_INIT(FibManager);
-FibManager::FibManager(Fib& fib,
- const FaceTable& faceTable,
- Dispatcher& dispatcher,
- CommandAuthenticator& authenticator)
- : NfdManagerBase(dispatcher, authenticator, "fib")
+FibManager::FibManager(Fib& fib, const FaceTable& faceTable,
+ Dispatcher& dispatcher, CommandAuthenticator& authenticator)
+ : ManagerBase("fib", dispatcher, authenticator)
, m_fib(fib)
, m_faceTable(faceTable)
{
diff --git a/daemon/mgmt/fib-manager.hpp b/daemon/mgmt/fib-manager.hpp
index c5455e9..073fe43 100644
--- a/daemon/mgmt/fib-manager.hpp
+++ b/daemon/mgmt/fib-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,25 +26,25 @@
#ifndef NFD_DAEMON_MGMT_FIB_MANAGER_HPP
#define NFD_DAEMON_MGMT_FIB_MANAGER_HPP
-#include "nfd-manager-base.hpp"
-#include "fw/forwarder.hpp"
-#include "table/fib.hpp"
+#include "manager-base.hpp"
namespace nfd {
+namespace fib {
+class Fib;
+} // namespace fib
+
class FaceTable;
/**
- * @brief implement the FIB Management of NFD Management Protocol.
+ * @brief Implements the FIB Management of NFD Management Protocol.
* @sa https://redmine.named-data.net/projects/nfd/wiki/FibMgmt
*/
-class FibManager : public NfdManagerBase
+class FibManager : public ManagerBase
{
public:
- FibManager(Fib& fib,
- const FaceTable& faceTable,
- Dispatcher& dispatcher,
- CommandAuthenticator& authenticator);
+ FibManager(fib::Fib& fib, const FaceTable& faceTable,
+ Dispatcher& dispatcher, CommandAuthenticator& authenticator);
private:
void
@@ -66,7 +66,7 @@
setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters);
private:
- Fib& m_fib;
+ fib::Fib& m_fib;
const FaceTable& m_faceTable;
};
diff --git a/daemon/mgmt/forwarder-status-manager.hpp b/daemon/mgmt/forwarder-status-manager.hpp
index 343d7d4..39c52f3 100644
--- a/daemon/mgmt/forwarder-status-manager.hpp
+++ b/daemon/mgmt/forwarder-status-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,7 +26,8 @@
#ifndef NFD_DAEMON_MGMT_FORWARDER_STATUS_MANAGER_HPP
#define NFD_DAEMON_MGMT_FORWARDER_STATUS_MANAGER_HPP
-#include "core/manager-base.hpp"
+#include "manager-base.hpp"
+
#include <ndn-cxx/mgmt/nfd/forwarder-status.hpp>
namespace nfd {
@@ -34,8 +35,8 @@
class Forwarder;
/**
- * @brief implement the Forwarder Status of NFD Management Protocol.
- * @sa http://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
+ * @brief Implements the Forwarder Status of NFD Management Protocol.
+ * @sa https://redmine.named-data.net/projects/nfd/wiki/ForwarderStatus
*/
class ForwarderStatusManager : noncopyable
{
@@ -53,7 +54,7 @@
ndn::mgmt::StatusDatasetContext& context);
private:
- Forwarder& m_forwarder;
+ Forwarder& m_forwarder;
Dispatcher& m_dispatcher;
time::system_clock::TimePoint m_startTimestamp;
};
diff --git a/core/manager-base.cpp b/daemon/mgmt/manager-base.cpp
similarity index 79%
rename from core/manager-base.cpp
rename to daemon/mgmt/manager-base.cpp
index 737c1c6..496b439 100644
--- a/core/manager-base.cpp
+++ b/daemon/mgmt/manager-base.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,12 +27,17 @@
namespace nfd {
-using ndn::mgmt::ValidateParameters;
-using ndn::mgmt::Authorization;
+ManagerBase::ManagerBase(const std::string& module, Dispatcher& dispatcher)
+ : m_module(module)
+ , m_dispatcher(dispatcher)
+{
+}
-ManagerBase::ManagerBase(Dispatcher& dispatcher, const std::string& module)
- : m_dispatcher(dispatcher)
- , m_module(module)
+ManagerBase::ManagerBase(const std::string& module, Dispatcher& dispatcher,
+ CommandAuthenticator& authenticator)
+ : m_module(module)
+ , m_dispatcher(dispatcher)
+ , m_authenticator(&authenticator)
{
}
@@ -73,8 +78,16 @@
}
}
+ndn::mgmt::Authorization
+ManagerBase::makeAuthorization(const std::string& verb)
+{
+ BOOST_ASSERT(m_authenticator != nullptr);
+ return m_authenticator->makeAuthorization(m_module, verb);
+}
+
bool
-ManagerBase::validateParameters(const nfd::ControlCommand& command, const ndn::mgmt::ControlParameters& parameters)
+ManagerBase::validateParameters(const ControlCommand& command,
+ const ndn::mgmt::ControlParameters& parameters)
{
BOOST_ASSERT(dynamic_cast<const ControlParameters*>(¶meters) != nullptr);
@@ -88,13 +101,14 @@
}
void
-ManagerBase::handleCommand(shared_ptr<nfd::ControlCommand> command,
+ManagerBase::handleCommand(shared_ptr<ControlCommand> command,
const ControlCommandHandler& handler,
const Name& prefix, const Interest& interest,
const ndn::mgmt::ControlParameters& params,
ndn::mgmt::CommandContinuation done)
{
BOOST_ASSERT(dynamic_cast<const ControlParameters*>(¶ms) != nullptr);
+
ControlParameters parameters = static_cast<const ControlParameters&>(params);
command->applyDefaultsToRequest(parameters);
handler(*command, prefix, interest, parameters, done);
diff --git a/core/manager-base.hpp b/daemon/mgmt/manager-base.hpp
similarity index 71%
rename from core/manager-base.hpp
rename to daemon/mgmt/manager-base.hpp
index a19ccb2..2c963b1 100644
--- a/core/manager-base.hpp
+++ b/daemon/mgmt/manager-base.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,26 +23,25 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NFD_CORE_MANAGER_BASE_HPP
-#define NFD_CORE_MANAGER_BASE_HPP
+#ifndef NFD_DAEMON_MGMT_MANAGER_BASE_HPP
+#define NFD_DAEMON_MGMT_MANAGER_BASE_HPP
-#include "common.hpp"
+#include "command-authenticator.hpp"
#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/mgmt/nfd/control-command.hpp>
-#include <ndn-cxx/mgmt/nfd/control-response.hpp>
#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
+#include <ndn-cxx/mgmt/nfd/control-response.hpp>
namespace nfd {
using ndn::mgmt::Dispatcher;
-
using ndn::nfd::ControlCommand;
-using ndn::nfd::ControlResponse;
using ndn::nfd::ControlParameters;
+using ndn::nfd::ControlResponse;
/**
- * @brief a collection of common functions shared by all NFD managers and RIB manager,
+ * @brief A collection of common functions shared by all NFD managers,
* such as communicating with the dispatcher and command validator.
*/
class ManagerBase : noncopyable
@@ -51,16 +50,9 @@
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
- {
- }
+ using std::runtime_error::runtime_error;
};
-public:
- ManagerBase(Dispatcher& dispatcher, const std::string& module);
-
virtual
~ManagerBase();
@@ -70,6 +62,15 @@
return m_module;
}
+protected:
+ /**
+ * @warning if you use this constructor, you MUST override makeAuthorization()
+ */
+ ManagerBase(const std::string& module, Dispatcher& dispatcher);
+
+ ManagerBase(const std::string& module, Dispatcher& dispatcher,
+ CommandAuthenticator& authenticator);
+
PUBLIC_WITH_TESTS_ELSE_PROTECTED: // registrations to the dispatcher
// difference from mgmt::ControlCommand: accepts nfd::ControlParameters
using ControlCommandHandler = std::function<void(const ControlCommand& command,
@@ -89,68 +90,63 @@
ndn::mgmt::PostNotification
registerNotificationStream(const std::string& verb);
-PUBLIC_WITH_TESTS_ELSE_PROTECTED:
+PUBLIC_WITH_TESTS_ELSE_PROTECTED: // helpers
/**
- * @brief extract a requester from a ControlCommand request
+ * @brief Extracts the requester from a ControlCommand request.
*
- * This is called after the signature is validated.
+ * This is called after the signature has been validated.
*
* @param interest a request for ControlCommand
- * @param accept callback of successful validation, take the requester string as a argument
+ * @param accept callback of successful validation, takes the requester string as a argument
*/
void
- extractRequester(const Interest& interest,
- ndn::mgmt::AcceptContinuation accept);
+ extractRequester(const Interest& interest, ndn::mgmt::AcceptContinuation accept);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
/**
- * @return an authorization function for specified management module and verb
+ * @brief Returns an authorization function for a specific management module and verb.
*/
virtual ndn::mgmt::Authorization
- makeAuthorization(const std::string& verb) = 0;
+ makeAuthorization(const std::string& verb);
/**
- * @brief validate the @p parameters for a given @p command
+ * @brief Validates the @p parameters for a given @p command.
*
* @param parameters the original ControlParameters
- *
* @return whether the original ControlParameters can be validated
*/
static bool
- validateParameters(const nfd::ControlCommand& command,
+ validateParameters(const ControlCommand& command,
const ndn::mgmt::ControlParameters& parameters);
- /** @brief Handle control command
+ /**
+ * @brief Handles a control command.
*/
static void
- handleCommand(shared_ptr<nfd::ControlCommand> command,
+ handleCommand(shared_ptr<ControlCommand> command,
const ControlCommandHandler& handler,
const Name& prefix, const Interest& interest,
const ndn::mgmt::ControlParameters& params,
ndn::mgmt::CommandContinuation done);
/**
- * @brief generate the relative prefix for a handler,
- * by appending the verb name to the module name.
+ * @brief Generates the relative prefix for a handler by appending the verb name to the module name.
*
* @param verb the verb name
- *
* @return the generated relative prefix
*/
PartialName
- makeRelPrefix(const std::string& verb);
+ makeRelPrefix(const std::string& verb)
+ {
+ return PartialName(m_module).append(verb);
+ }
private:
- Dispatcher& m_dispatcher;
std::string m_module;
+ Dispatcher& m_dispatcher;
+ CommandAuthenticator* m_authenticator = nullptr;
};
-inline PartialName
-ManagerBase::makeRelPrefix(const std::string& verb)
-{
- return PartialName(m_module).append(verb);
-}
-
template<typename Command>
inline void
ManagerBase::registerCommandHandler(const std::string& verb,
@@ -167,4 +163,4 @@
} // namespace nfd
-#endif // NFD_CORE_MANAGER_BASE_HPP
+#endif // NFD_DAEMON_MGMT_MANAGER_BASE_HPP
diff --git a/daemon/mgmt/nfd-manager-base.cpp b/daemon/mgmt/nfd-manager-base.cpp
deleted file mode 100644
index b417934..0000000
--- a/daemon/mgmt/nfd-manager-base.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD 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.
- *
- * NFD 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 a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "nfd-manager-base.hpp"
-
-namespace nfd {
-
-NfdManagerBase::NfdManagerBase(Dispatcher& dispatcher,
- CommandAuthenticator& authenticator,
- const std::string& module)
- : ManagerBase(dispatcher, module)
- , m_authenticator(authenticator)
-{
-}
-
-ndn::mgmt::Authorization
-NfdManagerBase::makeAuthorization(const std::string& verb)
-{
- return m_authenticator.makeAuthorization(this->getModule(), verb);
-}
-
-} // namespace nfd
diff --git a/daemon/mgmt/nfd-manager-base.hpp b/daemon/mgmt/nfd-manager-base.hpp
deleted file mode 100644
index 27c3392..0000000
--- a/daemon/mgmt/nfd-manager-base.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD 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.
- *
- * NFD 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 a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NFD_DAEMON_MGMT_NFD_MANAGER_BASE_HPP
-#define NFD_DAEMON_MGMT_NFD_MANAGER_BASE_HPP
-
-#include "core/manager-base.hpp"
-#include "command-authenticator.hpp"
-
-namespace nfd {
-
-using ndn::mgmt::Dispatcher;
-using ndn::nfd::ControlParameters;
-
-/**
- * @brief a collection of common functions shared by all NFD managers,
- * such as communicating with the dispatcher and command validator.
- */
-class NfdManagerBase : public ManagerBase
-{
-public:
- NfdManagerBase(Dispatcher& dispatcher,
- CommandAuthenticator& authenticator,
- const std::string& module);
-
-PUBLIC_WITH_TESTS_ELSE_PRIVATE: // command validation
- virtual ndn::mgmt::Authorization
- makeAuthorization(const std::string& verb) override;
-
-private:
- CommandAuthenticator& m_authenticator;
-};
-
-} // namespace nfd
-
-#endif // NFD_DAEMON_MGMT_NFD_MANAGER_BASE_HPP
diff --git a/daemon/mgmt/rib-manager.cpp b/daemon/mgmt/rib-manager.cpp
index 0a73db2..1532627 100644
--- a/daemon/mgmt/rib-manager.cpp
+++ b/daemon/mgmt/rib-manager.cpp
@@ -27,11 +27,9 @@
#include "core/fib-max-depth.hpp"
#include "core/logger.hpp"
+#include "rib/rib.hpp"
#include <ndn-cxx/lp/tags.hpp>
-#include <ndn-cxx/mgmt/nfd/control-command.hpp>
-#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
-#include <ndn-cxx/mgmt/nfd/control-response.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
#include <ndn-cxx/mgmt/nfd/rib-entry.hpp>
@@ -51,7 +49,7 @@
RibManager::RibManager(rib::Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
ndn::nfd::Controller& nfdController, Dispatcher& dispatcher,
ndn::util::Scheduler& scheduler)
- : ManagerBase(dispatcher, MGMT_MODULE_NAME)
+ : ManagerBase(MGMT_MODULE_NAME, dispatcher)
, m_rib(rib)
, m_keyChain(keyChain)
, m_nfdController(nfdController)
diff --git a/daemon/mgmt/rib-manager.hpp b/daemon/mgmt/rib-manager.hpp
index 876ed75..745cfa2 100644
--- a/daemon/mgmt/rib-manager.hpp
+++ b/daemon/mgmt/rib-manager.hpp
@@ -26,9 +26,9 @@
#ifndef NFD_DAEMON_MGMT_RIB_MANAGER_HPP
#define NFD_DAEMON_MGMT_RIB_MANAGER_HPP
+#include "manager-base.hpp"
#include "core/config-file.hpp"
-#include "core/manager-base.hpp"
-#include "rib/rib.hpp"
+#include "rib/route.hpp"
#include <ndn-cxx/mgmt/nfd/controller.hpp>
#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
@@ -38,19 +38,18 @@
namespace nfd {
+namespace rib {
+class Rib;
+class RibUpdate;
+} // namespace rib
+
/**
- * @brief Serve commands and datasets of NFD RIB management protocol.
+ * @brief Implements the RIB Management of NFD Management Protocol.
* @sa https://redmine.named-data.net/projects/nfd/wiki/RibMgmt
*/
class RibManager : public ManagerBase
{
public:
- class Error : public std::runtime_error
- {
- public:
- using std::runtime_error::runtime_error;
- };
-
RibManager(rib::Rib& rib, ndn::Face& face, ndn::KeyChain& keyChain,
ndn::nfd::Controller& nfdController, Dispatcher& dispatcher,
ndn::util::Scheduler& scheduler);
diff --git a/daemon/mgmt/strategy-choice-manager.cpp b/daemon/mgmt/strategy-choice-manager.cpp
index 8f7cef0..bebe1a0 100644
--- a/daemon/mgmt/strategy-choice-manager.cpp
+++ b/daemon/mgmt/strategy-choice-manager.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -37,7 +37,7 @@
StrategyChoiceManager::StrategyChoiceManager(StrategyChoice& strategyChoice,
Dispatcher& dispatcher,
CommandAuthenticator& authenticator)
- : NfdManagerBase(dispatcher, authenticator, "strategy-choice")
+ : ManagerBase("strategy-choice", dispatcher, authenticator)
, m_table(strategyChoice)
{
registerCommandHandler<ndn::nfd::StrategyChoiceSetCommand>("set",
diff --git a/daemon/mgmt/strategy-choice-manager.hpp b/daemon/mgmt/strategy-choice-manager.hpp
index 00d4dd9..370364b 100644
--- a/daemon/mgmt/strategy-choice-manager.hpp
+++ b/daemon/mgmt/strategy-choice-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,7 +26,7 @@
#ifndef NFD_DAEMON_MGMT_STRATEGY_CHOICE_MANAGER_HPP
#define NFD_DAEMON_MGMT_STRATEGY_CHOICE_MANAGER_HPP
-#include "nfd-manager-base.hpp"
+#include "manager-base.hpp"
namespace nfd {
@@ -35,15 +35,14 @@
} // namespace strategy_choice
/**
- * @brief implement the Strategy Choice Management of NFD Management Protocol.
- * @sa http://redmine.named-data.net/projects/nfd/wiki/StrategyChoice
+ * @brief Implements the Strategy Choice Management of NFD Management Protocol.
+ * @sa https://redmine.named-data.net/projects/nfd/wiki/StrategyChoice
*/
-class StrategyChoiceManager : public NfdManagerBase
+class StrategyChoiceManager : public ManagerBase
{
public:
StrategyChoiceManager(strategy_choice::StrategyChoice& table,
- Dispatcher& dispatcher,
- CommandAuthenticator& authenticator);
+ Dispatcher& dispatcher, CommandAuthenticator& authenticator);
private:
void
diff --git a/tests/daemon/mgmt/command-authenticator.t.cpp b/tests/daemon/mgmt/command-authenticator.t.cpp
index 5f55451..fc24ccd 100644
--- a/tests/daemon/mgmt/command-authenticator.t.cpp
+++ b/tests/daemon/mgmt/command-authenticator.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,8 +25,7 @@
#include "mgmt/command-authenticator.hpp"
-#include "tests/test-common.hpp"
-#include "tests/manager-common-fixture.hpp"
+#include "manager-common-fixture.hpp"
#include <boost/filesystem.hpp>
diff --git a/tests/daemon/mgmt/cs-manager.t.cpp b/tests/daemon/mgmt/cs-manager.t.cpp
index 1a485725..50c82b9 100644
--- a/tests/daemon/mgmt/cs-manager.t.cpp
+++ b/tests/daemon/mgmt/cs-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -25,14 +25,14 @@
#include "mgmt/cs-manager.hpp"
-#include "nfd-manager-common-fixture.hpp"
+#include "manager-common-fixture.hpp"
#include <ndn-cxx/mgmt/nfd/cs-info.hpp>
namespace nfd {
namespace tests {
-class CsManagerFixture : public NfdManagerCommonFixture
+class CsManagerFixture : public ManagerFixtureWithAuthenticator
{
public:
CsManagerFixture()
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.hpp b/tests/daemon/mgmt/face-manager-command-fixture.hpp
index b00b9cc..5864ad2 100644
--- a/tests/daemon/mgmt/face-manager-command-fixture.hpp
+++ b/tests/daemon/mgmt/face-manager-command-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,7 +29,7 @@
#include "mgmt/face-manager.hpp"
#include "fw/face-table.hpp"
-#include "tests/manager-common-fixture.hpp"
+#include "manager-common-fixture.hpp"
namespace nfd {
namespace tests {
@@ -50,7 +50,7 @@
public:
ndn::util::DummyClientFace face;
- ndn::mgmt::Dispatcher dispatcher;
+ Dispatcher dispatcher;
shared_ptr<CommandAuthenticator> authenticator;
FaceTable faceTable;
diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp
index 41c68c2..ac42dc9 100644
--- a/tests/daemon/mgmt/face-manager-create-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-create-face.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,7 +29,6 @@
#include "mgmt/face-manager.hpp"
#include "face/generic-link-service.hpp"
#include "face-manager-command-fixture.hpp"
-#include "nfd-manager-common-fixture.hpp"
namespace nfd {
namespace tests {
diff --git a/tests/daemon/mgmt/face-manager-update-face.t.cpp b/tests/daemon/mgmt/face-manager-update-face.t.cpp
index 15bf6dd..1be0647 100644
--- a/tests/daemon/mgmt/face-manager-update-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-update-face.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,7 +26,6 @@
#include "mgmt/face-manager.hpp"
#include "face/generic-link-service.hpp"
#include "face-manager-command-fixture.hpp"
-#include "nfd-manager-common-fixture.hpp"
#include <ndn-cxx/lp/tags.hpp>
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index cebbfd4..8a418e5 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -26,9 +26,9 @@
#include "mgmt/face-manager.hpp"
#include "face/protocol-factory.hpp"
-#include "nfd-manager-common-fixture.hpp"
-#include "../face/dummy-face.hpp"
-#include "../face/dummy-transport.hpp"
+#include "manager-common-fixture.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
+#include "tests/daemon/face/dummy-transport.hpp"
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/encoding/tlv-nfd.hpp>
@@ -42,7 +42,7 @@
namespace nfd {
namespace tests {
-class FaceManagerFixture : public NfdManagerCommonFixture
+class FaceManagerFixture : public ManagerFixtureWithAuthenticator
{
public:
FaceManagerFixture()
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index 5fd193d..1002e44 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -26,8 +26,8 @@
#include "mgmt/fib-manager.hpp"
#include "table/fib-nexthop.hpp"
-#include "nfd-manager-common-fixture.hpp"
-#include "../face/dummy-face.hpp"
+#include "manager-common-fixture.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
#include <ndn-cxx/lp/tags.hpp>
#include <ndn-cxx/mgmt/nfd/fib-entry.hpp>
@@ -35,7 +35,7 @@
namespace nfd {
namespace tests {
-class FibManagerFixture : public NfdManagerCommonFixture
+class FibManagerFixture : public ManagerFixtureWithAuthenticator
{
public:
FibManagerFixture()
diff --git a/tests/daemon/mgmt/forwarder-status-manager.t.cpp b/tests/daemon/mgmt/forwarder-status-manager.t.cpp
index 3df77ec..bb728f2 100644
--- a/tests/daemon/mgmt/forwarder-status-manager.t.cpp
+++ b/tests/daemon/mgmt/forwarder-status-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,24 +26,25 @@
#include "mgmt/forwarder-status-manager.hpp"
#include "core/version.hpp"
-#include "nfd-manager-common-fixture.hpp"
+#include "manager-common-fixture.hpp"
namespace nfd {
namespace tests {
-class ForwarderStatusManagerFixture : public NfdManagerCommonFixture
+class ForwarderStatusManagerFixture : public ManagerCommonFixture
{
protected:
ForwarderStatusManagerFixture()
- : manager(m_forwarder, m_dispatcher)
- , startTime(time::system_clock::now())
+ : m_manager(m_forwarder, m_dispatcher)
+ , m_startTime(time::system_clock::now())
{
setTopPrefix();
}
protected:
- ForwarderStatusManager manager;
- time::system_clock::TimePoint startTime;
+ Forwarder m_forwarder;
+ ForwarderStatusManager m_manager;
+ time::system_clock::TimePoint m_startTime;
};
BOOST_AUTO_TEST_SUITE(Mgmt)
@@ -78,11 +79,9 @@
BOOST_CHECK_EQUAL(m_forwarder.getCounters().nUnsatisfiedInterests, 1);
// request
- time::system_clock::TimePoint beforeRequest = time::system_clock::now();
- Interest request("/localhost/nfd/status/general");
- request.setMustBeFresh(true).setChildSelector(1);
- this->receiveInterest(request);
- time::system_clock::TimePoint afterRequest = time::system_clock::now();
+ auto beforeRequest = time::system_clock::now();
+ receiveInterest(Interest("/localhost/nfd/status/general").setCanBePrefix(true));
+ auto afterRequest = time::system_clock::now();
// verify
Block response = this->concatenateResponses(0, m_responses.size());
@@ -90,7 +89,7 @@
BOOST_REQUIRE_NO_THROW(status.wireDecode(response));
BOOST_CHECK_EQUAL(status.getNfdVersion(), NFD_VERSION_BUILD_STRING);
- BOOST_CHECK_EQUAL(time::toUnixTimestamp(status.getStartTimestamp()), time::toUnixTimestamp(startTime));
+ BOOST_CHECK_EQUAL(time::toUnixTimestamp(status.getStartTimestamp()), time::toUnixTimestamp(m_startTime));
BOOST_CHECK_GE(time::toUnixTimestamp(status.getCurrentTimestamp()), time::toUnixTimestamp(beforeRequest));
BOOST_CHECK_LE(time::toUnixTimestamp(status.getCurrentTimestamp()), time::toUnixTimestamp(afterRequest));
diff --git a/tests/core/manager-base.t.cpp b/tests/daemon/mgmt/manager-base.t.cpp
similarity index 86%
rename from tests/core/manager-base.t.cpp
rename to tests/daemon/mgmt/manager-base.t.cpp
index 947727c..3aeeb9e 100644
--- a/tests/core/manager-base.t.cpp
+++ b/tests/daemon/mgmt/manager-base.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,10 +23,10 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "core/manager-base.hpp"
-#include "tests/manager-common-fixture.hpp"
+#include "mgmt/manager-base.hpp"
-#include <ndn-cxx/mgmt/nfd/control-command.hpp>
+#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>
@@ -35,30 +35,35 @@
namespace nfd {
namespace tests {
-class TestCommandVoidParameters : public ndn::nfd::ControlCommand
+class TestCommandVoidParameters : public ControlCommand
{
public:
TestCommandVoidParameters()
- : ndn::nfd::ControlCommand("test-module", "test-void-parameters")
+ : ControlCommand("test-module", "test-void-parameters")
{
}
};
-class TestCommandRequireName : public ndn::nfd::ControlCommand
+class TestCommandRequireName : public ControlCommand
{
public:
TestCommandRequireName()
- : ndn::nfd::ControlCommand("test-module", "test-require-name")
+ : ControlCommand("test-module", "test-require-name")
{
m_requestValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
}
};
-class ManagerTester : public ManagerBase
+class DummyManager : public ManagerBase
{
public:
- using ManagerBase::ManagerBase;
+ explicit
+ DummyManager(Dispatcher& dispatcher)
+ : ManagerBase("test-module", dispatcher)
+ {
+ }
+private:
ndn::mgmt::Authorization
makeAuthorization(const std::string& verb) override
{
@@ -73,16 +78,11 @@
class ManagerBaseFixture : public ManagerCommonFixture
{
-public:
- ManagerBaseFixture()
- : m_manager(m_dispatcher, "test-module")
- {
- }
-
protected:
- ManagerTester m_manager;
+ DummyManager m_manager{m_dispatcher};
};
+BOOST_AUTO_TEST_SUITE(Mgmt)
BOOST_FIXTURE_TEST_SUITE(TestManagerBase, ManagerBaseFixture)
BOOST_AUTO_TEST_CASE(RegisterCommandHandler)
@@ -92,7 +92,7 @@
m_manager.registerCommandHandler<TestCommandVoidParameters>("test-void", handler);
m_manager.registerCommandHandler<TestCommandRequireName>("test-require-name", handler);
- setTopPrefix("/localhost/nfd");
+ setTopPrefix();
auto testRegisterCommandHandler = [&wasCommandHandlerCalled, this] (const Name& commandName) {
wasCommandHandlerCalled = false;
@@ -112,7 +112,7 @@
auto handler = bind([&] { isStatusDatasetCalled = true; });
m_manager.registerStatusDatasetHandler("test-status", handler);
- setTopPrefix("/localhost/nfd");
+ setTopPrefix();
receiveInterest(Interest("/localhost/nfd/test-module/test-status"));
BOOST_CHECK(isStatusDatasetCalled);
@@ -121,7 +121,7 @@
BOOST_AUTO_TEST_CASE(RegisterNotificationStream)
{
auto post = m_manager.registerNotificationStream("test-notification");
- setTopPrefix("/localhost/nfd");
+ setTopPrefix();
const uint8_t buf[] = {0x82, 0x01, 0x02};
post(Block(buf, sizeof(buf)));
@@ -166,6 +166,7 @@
}
BOOST_AUTO_TEST_SUITE_END() // TestManagerBase
+BOOST_AUTO_TEST_SUITE_END() // Mgmt
} // namespace tests
} // namespace nfd
diff --git a/tests/manager-common-fixture.cpp b/tests/daemon/mgmt/manager-common-fixture.cpp
similarity index 89%
rename from tests/manager-common-fixture.cpp
rename to tests/daemon/mgmt/manager-common-fixture.cpp
index 9511951..ee8d543 100644
--- a/tests/manager-common-fixture.cpp
+++ b/tests/daemon/mgmt/manager-common-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -24,6 +24,7 @@
*/
#include "manager-common-fixture.hpp"
+
#include <ndn-cxx/security/signing-helpers.hpp>
namespace nfd {
@@ -60,10 +61,10 @@
}
void
-ManagerCommonFixture::setTopPrefix(const Name& topPrefix)
+ManagerCommonFixture::setTopPrefix()
{
- m_dispatcher.addTopPrefix(topPrefix); // so that all filters are added
- advanceClocks(1_ms);
+ m_dispatcher.addTopPrefix("/localhost/nfd");
+ advanceClocks(1_ms); // so that all filters are added
}
void
@@ -167,7 +168,7 @@
}
std::ostream&
-operator<<(std::ostream& os, const ManagerCommonFixture::CheckResponseResult& result)
+operator<<(std::ostream& os, ManagerCommonFixture::CheckResponseResult result)
{
switch (result) {
case ManagerCommonFixture::CheckResponseResult::OK:
@@ -192,5 +193,29 @@
return os << static_cast<int>(result);
}
+void
+ManagerFixtureWithAuthenticator::setPrivilege(const std::string& privilege)
+{
+ saveIdentityCertificate(DEFAULT_COMMAND_SIGNER_IDENTITY, "ManagerCommonFixture.ndncert");
+
+ const std::string& config = R"CONFIG(
+ authorizations
+ {
+ authorize
+ {
+ certfile "ManagerCommonFixture.ndncert"
+ privileges
+ {
+ )CONFIG" + privilege + R"CONFIG(
+ }
+ }
+ }
+ )CONFIG";
+
+ ConfigFile cf;
+ m_authenticator->setConfigFile(cf);
+ cf.parse(config, false, "ManagerCommonFixture.authenticator.conf");
+}
+
} // namespace tests
} // namespace nfd
diff --git a/tests/manager-common-fixture.hpp b/tests/daemon/mgmt/manager-common-fixture.hpp
similarity index 75%
rename from tests/manager-common-fixture.hpp
rename to tests/daemon/mgmt/manager-common-fixture.hpp
index 186a5db..8725680 100644
--- a/tests/manager-common-fixture.hpp
+++ b/tests/daemon/mgmt/manager-common-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,21 +23,21 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NFD_TESTS_MANAGER_COMMON_FIXTURE_HPP
-#define NFD_TESTS_MANAGER_COMMON_FIXTURE_HPP
+#ifndef NFD_TESTS_DAEMON_MGMT_MANAGER_COMMON_FIXTURE_HPP
+#define NFD_TESTS_DAEMON_MGMT_MANAGER_COMMON_FIXTURE_HPP
-#include "tests/test-common.hpp"
+#include "mgmt/manager-base.hpp"
+#include "fw/forwarder.hpp"
+
#include "tests/identity-management-fixture.hpp"
-#include "core/manager-base.hpp"
-#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/security/command-interest-signer.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace nfd {
namespace tests {
-/** \brief a fixture that provides a CommandInterestSigner
+/** \brief A fixture that provides a CommandInterestSigner.
*/
class CommandInterestSignerFixture : public IdentityManagementTimeFixture
{
@@ -70,7 +70,7 @@
};
/**
- * @brief a collection of common functions shared by all manager's testing fixtures.
+ * @brief A collection of common functions shared by all manager's test fixtures.
*/
class ManagerCommonFixture : public CommandInterestSignerFixture
{
@@ -78,14 +78,12 @@
ManagerCommonFixture();
/**
- * @brief set topPrefix to the dispatcher.
+ * @brief Add `/localhost/nfd` as a top prefix to the dispatcher.
*
- * after setting @param topPrefix, call advanceClocks to ensure all added filters take effects.
- *
- * @param topPrefix top prefix for the dispatcher
+ * Afterwards, advanceClocks() is called to ensure all added filters take effect.
*/
void
- setTopPrefix(const Name& topPrefix);
+ setTopPrefix();
public: // test
/**
@@ -101,8 +99,7 @@
public: // verify
ControlResponse
- makeResponse(uint32_t code, const std::string& text,
- const ControlParameters& parameters);
+ makeResponse(uint32_t code, const std::string& text, const ControlParameters& parameters);
enum class CheckResponseResult
{
@@ -156,14 +153,52 @@
protected:
ndn::util::DummyClientFace m_face;
- ndn::mgmt::Dispatcher m_dispatcher;
- std::vector<Data>& m_responses; ///< a reference of m_face->sentData
+ Dispatcher m_dispatcher;
+ std::vector<Data>& m_responses; ///< a reference to m_face.sentData
};
std::ostream&
-operator<<(std::ostream& os, const ManagerCommonFixture::CheckResponseResult& result);
+operator<<(std::ostream& os, ManagerCommonFixture::CheckResponseResult result);
+
+class ManagerFixtureWithAuthenticator : public ManagerCommonFixture
+{
+public:
+ /** \brief grant m_identityName privilege to sign commands for the management module
+ */
+ void
+ setPrivilege(const std::string& privilege);
+
+protected:
+ Forwarder m_forwarder;
+ shared_ptr<CommandAuthenticator> m_authenticator = CommandAuthenticator::create();
+};
+
+class CommandSuccess
+{
+public:
+ static ControlResponse
+ getExpected()
+ {
+ return ControlResponse()
+ .setCode(200)
+ .setText("OK");
+ }
+};
+
+template<int CODE>
+class CommandFailure
+{
+public:
+ static ControlResponse
+ getExpected()
+ {
+ return ControlResponse()
+ .setCode(CODE);
+ // error description should not be checked
+ }
+};
} // namespace tests
} // namespace nfd
-#endif // NFD_TESTS_MANAGER_COMMON_FIXTURE_HPP
+#endif // NFD_TESTS_DAEMON_MGMT_MANAGER_COMMON_FIXTURE_HPP
diff --git a/tests/daemon/mgmt/nfd-manager-common-fixture.cpp b/tests/daemon/mgmt/nfd-manager-common-fixture.cpp
deleted file mode 100644
index f39e983..0000000
--- a/tests/daemon/mgmt/nfd-manager-common-fixture.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD 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.
- *
- * NFD 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 a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "nfd-manager-common-fixture.hpp"
-
-namespace nfd {
-namespace tests {
-
-NfdManagerCommonFixture::NfdManagerCommonFixture()
- : m_authenticator(CommandAuthenticator::create())
-{
-}
-
-void
-NfdManagerCommonFixture::setTopPrefix()
-{
- this->ManagerCommonFixture::setTopPrefix("/localhost/nfd");
-}
-
-void
-NfdManagerCommonFixture::setPrivilege(const std::string& privilege)
-{
- this->saveIdentityCertificate(DEFAULT_COMMAND_SIGNER_IDENTITY, "ManagerCommonFixture.ndncert");
-
- const std::string& config = R"CONFIG(
- authorizations
- {
- authorize
- {
- certfile "ManagerCommonFixture.ndncert"
- privileges
- {
- )CONFIG" + privilege + R"CONFIG(
- }
- }
- }
- )CONFIG";
-
- ConfigFile cf;
- m_authenticator->setConfigFile(cf);
- cf.parse(config, false, "ManagerCommonFixture.authenticator.conf");
-}
-
-} // namespace tests
-} // namespace nfd
diff --git a/tests/daemon/mgmt/nfd-manager-common-fixture.hpp b/tests/daemon/mgmt/nfd-manager-common-fixture.hpp
deleted file mode 100644
index fb2dbc2..0000000
--- a/tests/daemon/mgmt/nfd-manager-common-fixture.hpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California,
- * Arizona Board of Regents,
- * Colorado State University,
- * University Pierre & Marie Curie, Sorbonne University,
- * Washington University in St. Louis,
- * Beijing Institute of Technology,
- * The University of Memphis.
- *
- * This file is part of NFD (Named Data Networking Forwarding Daemon).
- * See AUTHORS.md for complete list of NFD authors and contributors.
- *
- * NFD 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.
- *
- * NFD 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 a copy of the GNU General Public License along with
- * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef NFD_TESTS_DAEMON_MGMT_NFD_MANAGER_COMMON_FIXTURE_HPP
-#define NFD_TESTS_DAEMON_MGMT_NFD_MANAGER_COMMON_FIXTURE_HPP
-
-#include "tests/manager-common-fixture.hpp"
-#include "fw/forwarder.hpp"
-#include "mgmt/command-authenticator.hpp"
-
-namespace nfd {
-namespace tests {
-
-/** \brief base fixture for testing an NFD Manager
- */
-class NfdManagerCommonFixture : public ManagerCommonFixture
-{
-public:
- NfdManagerCommonFixture();
-
- /** \brief add /localhost/nfd as a top prefix to the dispatcher
- */
- void
- setTopPrefix();
-
- /** \brief grant m_identityName privilege to sign commands for the management module
- */
- void
- setPrivilege(const std::string& privilege);
-
-protected:
- Forwarder m_forwarder;
- shared_ptr<CommandAuthenticator> m_authenticator;
-};
-
-class CommandSuccess
-{
-public:
- static ControlResponse
- getExpected()
- {
- return ControlResponse()
- .setCode(200)
- .setText("OK");
- }
-};
-
-template<int CODE>
-class CommandFailure
-{
-public:
- static ControlResponse
- getExpected()
- {
- return ControlResponse()
- .setCode(CODE);
- // error description should not be checked
- }
-};
-
-} // namespace tests
-} // namespace nfd
-
-#endif // NFD_TESTS_DAEMON_MGMT_NFD_MANAGER_COMMON_FIXTURE_HPP
diff --git a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
index 06e3d5e..452d758 100644
--- a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
+++ b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
@@ -165,7 +165,7 @@
ndn::util::DummyClientFace m_face;
ndn::util::Scheduler m_scheduler;
ndn::nfd::Controller m_nfdController;
- ndn::mgmt::Dispatcher m_dispatcher;
+ Dispatcher m_dispatcher;
rib::FibUpdater m_fibUpdater;
ndn::security::SigningInfo m_trustedSigner;
diff --git a/tests/daemon/mgmt/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
index 46da6a1..c3c5dd6 100644
--- a/tests/daemon/mgmt/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.cpp
@@ -27,7 +27,7 @@
#include "core/fib-max-depth.hpp"
#include "rib/fib-updater.hpp"
-#include "tests/manager-common-fixture.hpp"
+#include "manager-common-fixture.hpp"
#include <ndn-cxx/lp/tags.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
@@ -93,10 +93,10 @@
advanceClocks(1_ms);
auto replyFibAddCommand = [this] (const Interest& interest) {
- nfd::ControlParameters params(interest.getName().get(-5).blockFromValue());
+ ControlParameters params(interest.getName().get(-5).blockFromValue());
BOOST_CHECK(params.getName() == "/localhost/nfd/rib" || params.getName() == "/localhop/nfd/rib");
params.setFaceId(1).setCost(0);
- nfd::ControlResponse resp;
+ ControlResponse resp;
resp.setCode(200).setBody(params.wireEncode());
shared_ptr<Data> data = make_shared<Data>(interest.getName());
diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
index 817966e..6b7e390 100644
--- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp
+++ b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -26,15 +26,15 @@
#include "mgmt/strategy-choice-manager.hpp"
#include "table/strategy-choice.hpp"
-#include "nfd-manager-common-fixture.hpp"
-#include "../fw/dummy-strategy.hpp"
+#include "manager-common-fixture.hpp"
+#include "tests/daemon/fw/dummy-strategy.hpp"
#include <ndn-cxx/mgmt/nfd/strategy-choice.hpp>
namespace nfd {
namespace tests {
-class StrategyChoiceManagerFixture : public NfdManagerCommonFixture
+class StrategyChoiceManagerFixture : public ManagerFixtureWithAuthenticator
{
public:
StrategyChoiceManagerFixture()