mgmt: adapt to API changes in ndn-cxx ControlCommand and Dispatcher
Change-Id: I7515353444366d0a36fe962deeae70ef567334ac
diff --git a/tests/daemon/mgmt/manager-base.t.cpp b/tests/daemon/mgmt/manager-base.t.cpp
index cf24989..2fcdd62 100644
--- a/tests/daemon/mgmt/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-2023, Regents of the University of California,
+ * Copyright (c) 2014-2025, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -29,25 +29,22 @@
namespace nfd::tests {
-class TestCommandVoidParameters : public ControlCommand
+class TestCommandVoidParameters : public ndn::nfd::ControlCommand<TestCommandVoidParameters>
{
-public:
- TestCommandVoidParameters()
- : ControlCommand("test-module", "test-void-parameters")
- {
- }
+ NDN_CXX_CONTROL_COMMAND(TestCommandVoidParameters, "test-module", "test-void-parameters");
};
-class TestCommandRequireName : public ControlCommand
+const TestCommandVoidParameters::RequestFormat TestCommandVoidParameters::s_requestFormat;
+
+class TestCommandRequireName : public ndn::nfd::ControlCommand<TestCommandRequireName>
{
-public:
- TestCommandRequireName()
- : ControlCommand("test-module", "test-require-name")
- {
- m_requestValidator.required(ndn::nfd::CONTROL_PARAMETER_NAME);
- }
+ NDN_CXX_CONTROL_COMMAND(TestCommandRequireName, "test-module", "test-require-name");
};
+const TestCommandRequireName::RequestFormat TestCommandRequireName::s_requestFormat =
+ RequestFormat()
+ .required(ndn::nfd::CONTROL_PARAMETER_NAME);
+
class DummyManager final : public ManagerBase
{
public:
@@ -59,12 +56,12 @@
private:
ndn::mgmt::Authorization
- makeAuthorization(const std::string& verb) final
+ makeAuthorization(const std::string&) final
{
return [] (const Name& prefix, const Interest& interest,
- const ndn::mgmt::ControlParameters* params,
- ndn::mgmt::AcceptContinuation accept,
- ndn::mgmt::RejectContinuation reject) {
+ const ndn::mgmt::ControlParametersBase* params,
+ const ndn::mgmt::AcceptContinuation& accept,
+ const ndn::mgmt::RejectContinuation& reject) {
accept("requester");
};
}
@@ -98,6 +95,10 @@
testRegisterCommandHandler("/localhost/nfd/test-module/test-require-name");
BOOST_CHECK(!wasHandlerCalled);
+
+ testRegisterCommandHandler(Name("/localhost/nfd/test-module/test-require-name")
+ .append(ControlParameters().setName("test-name").wireEncode()));
+ BOOST_CHECK(wasHandlerCalled);
}
BOOST_AUTO_TEST_CASE(RegisterStatusDataset)
@@ -149,19 +150,6 @@
.getDefaultKey().getDefaultCertificate().getName().toUri());
}
-BOOST_AUTO_TEST_CASE(ValidateParameters)
-{
- ControlParameters params;
- TestCommandVoidParameters commandVoidParams;
- TestCommandRequireName commandRequireName;
-
- BOOST_CHECK_EQUAL(ManagerBase::validateParameters(commandVoidParams, params), true); // succeeds
- BOOST_CHECK_EQUAL(ManagerBase::validateParameters(commandRequireName, params), false); // fails
-
- params.setName("test-name");
- BOOST_CHECK_EQUAL(ManagerBase::validateParameters(commandRequireName, params), true); // succeeds
-}
-
BOOST_AUTO_TEST_CASE(MakeRelPrefix)
{
auto generatedRelPrefix = m_manager.makeRelPrefix("test-verb");
diff --git a/tests/daemon/mgmt/manager-common-fixture.hpp b/tests/daemon/mgmt/manager-common-fixture.hpp
index 954cef2..c8f5498 100644
--- a/tests/daemon/mgmt/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-2023, Regents of the University of California,
+ * Copyright (c) 2014-2025, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -112,7 +112,7 @@
* @brief Check a specified response data with the expected ControlResponse.
*
* @param idx the index of the specified Data in m_responses
- * @param expectedDataName the expected name of this Data
+ * @param expectedName the expected name of this Data
* @param expectedResponse the expected ControlResponse
* @param expectedContentType the expected content type of this Data, use -1 to skip this check
*
@@ -157,7 +157,8 @@
class ManagerFixtureWithAuthenticator : public ManagerCommonFixture
{
public:
- /** \brief Grant m_identityName privilege to sign commands for the management module.
+ /**
+ * \brief Grant m_identityName privilege to sign commands for the management module.
*/
void
setPrivilege(const std::string& privilege);