tests: sign command Interests with CommandInterestSigner

Previously used ndn::v2::KeyChain::sign creates signed Interests, not
command Interests.

refs #4089

Change-Id: I7b13926d676ff81041f036eaec1978d82e8e1dfd
diff --git a/tests/core/manager-base.t.cpp b/tests/core/manager-base.t.cpp
index db3a8ec..7a7cd12 100644
--- a/tests/core/manager-base.t.cpp
+++ b/tests/core/manager-base.t.cpp
@@ -118,7 +118,7 @@
   m_manager.registerStatusDatasetHandler("test-status", handler);
   setTopPrefix("/localhost/nfd");
 
-  receiveInterest(makeInterest("/localhost/nfd/test-module/test-status"));
+  receiveInterest(Interest("/localhost/nfd/test-module/test-status"));
   BOOST_CHECK(isStatusDatasetCalled);
 }
 
@@ -140,15 +140,12 @@
   std::string requesterName;
   auto testAccept = [&] (const std::string& requester) { requesterName = requester; };
 
-  auto unsignedCommand = makeInterest("/test/interest/unsigned");
-  auto signedCommand = makeControlCommandRequest("/test/interest/signed", ControlParameters());
-
-  m_manager.extractRequester(*unsignedCommand, testAccept);
+  m_manager.extractRequester(Interest("/test/interest/unsigned"), testAccept);
   BOOST_CHECK(requesterName.empty());
 
   requesterName = "";
-  m_manager.extractRequester(*signedCommand, testAccept);
-  auto keyLocator = m_keyChain.getPib().getIdentity(m_identityName).getDefaultKey().getName();
+  m_manager.extractRequester(makeControlCommandRequest("/test/interest/signed", ControlParameters()), testAccept);
+  auto keyLocator = m_keyChain.getPib().getIdentity(DEFAULT_COMMAND_SIGNER_IDENTITY).getDefaultKey().getName();
   BOOST_CHECK_EQUAL(requesterName, keyLocator.toUri());
 }
 
diff --git a/tests/daemon/mgmt/command-authenticator.t.cpp b/tests/daemon/mgmt/command-authenticator.t.cpp
index 7d2ed6e..498f44f 100644
--- a/tests/daemon/mgmt/command-authenticator.t.cpp
+++ b/tests/daemon/mgmt/command-authenticator.t.cpp
@@ -24,16 +24,15 @@
  */
 
 #include "mgmt/command-authenticator.hpp"
-#include <ndn-cxx/security/signing-helpers.hpp>
 #include <boost/filesystem.hpp>
 
 #include "tests/test-common.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/manager-common-fixture.hpp"
 
 namespace nfd {
 namespace tests {
 
-class CommandAuthenticatorFixture : public IdentityManagementTimeFixture
+class CommandAuthenticatorFixture : public CommandInterestSignerFixture
 {
 protected:
   CommandAuthenticatorFixture()
@@ -63,17 +62,17 @@
   authorize(const std::string& module, const Name& identity,
             const function<void(Interest&)>& modifyInterest = nullptr)
   {
-    auto interest = makeInterest(Name("/prefix").append(module).append("verb"));
-    m_keyChain.sign(*interest, signingByIdentity(identity));
+    Interest interest = this->makeControlCommandRequest(Name("/prefix/" + module + "/verb"),
+                        ControlParameters(), identity);
     if (modifyInterest != nullptr) {
-      modifyInterest(*interest);
+      modifyInterest(interest);
     }
 
     ndn::mgmt::Authorization authorization = authorizations.at(module);
 
     bool isAccepted = false;
     bool isRejected = false;
-    authorization(Name("/prefix"), *interest, nullptr,
+    authorization(Name("/prefix"), interest, nullptr,
       [this, &isAccepted, &isRejected] (const std::string& requester) {
         BOOST_REQUIRE_MESSAGE(!isAccepted && !isRejected,
                               "authorization function should invoke only one continuation");
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.hpp b/tests/daemon/mgmt/face-manager-command-fixture.hpp
index bf376f5..b00b9cc 100644
--- a/tests/daemon/mgmt/face-manager-command-fixture.hpp
+++ b/tests/daemon/mgmt/face-manager-command-fixture.hpp
@@ -29,10 +29,7 @@
 #include "mgmt/face-manager.hpp"
 #include "fw/face-table.hpp"
 
-#include "tests/identity-management-fixture.hpp"
-
-#include <ndn-cxx/mgmt/dispatcher.hpp>
-#include <ndn-cxx/util/dummy-client-face.hpp>
+#include "tests/manager-common-fixture.hpp"
 
 namespace nfd {
 namespace tests {
@@ -61,7 +58,7 @@
   FaceManager manager;
 };
 
-class FaceManagerCommandFixture : public IdentityManagementTimeFixture
+class FaceManagerCommandFixture : public CommandInterestSignerFixture
 {
 public:
   FaceManagerCommandFixture();
diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp
index 428e517..ac50913 100644
--- a/tests/daemon/mgmt/face-manager-create-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-create-face.t.cpp
@@ -228,15 +228,11 @@
   using FaceType = typename T::first;
   using CreateResult = typename T::second;
 
-  Name commandName("/localhost/nfd/faces");
-  commandName.append("create");
-  commandName.append(FaceType::getParameters().wireEncode());
-  auto command = makeInterest(commandName);
-  m_keyChain.sign(*command);
+  Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters());
 
   bool hasCallbackFired = false;
-  this->node1.face.onSendData.connect([this, command, &hasCallbackFired] (const Data& response) {
-    if (!command->getName().isPrefixOf(response.getName())) {
+  this->node1.face.onSendData.connect([this, req, &hasCallbackFired] (const Data& response) {
+    if (!req.getName().isPrefixOf(response.getName())) {
       return;
     }
 
@@ -284,7 +280,7 @@
     hasCallbackFired = true;
   });
 
-  this->node1.face.receive(*command);
+  this->node1.face.receive(req);
   this->advanceClocks(time::milliseconds(1), 5);
 
   BOOST_CHECK(hasCallbackFired);
@@ -296,14 +292,8 @@
 
   {
     // create face
-
-    Name commandName("/localhost/nfd/faces");
-    commandName.append("create");
-    commandName.append(FaceType::getParameters().wireEncode());
-    auto command = makeInterest(commandName);
-    m_keyChain.sign(*command);
-
-    this->node1.face.receive(*command);
+    Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters());
+    this->node1.face.receive(req);
     this->advanceClocks(time::milliseconds(1), 5);
   }
 
@@ -313,17 +303,12 @@
 
   {
     // re-create face
-
-    Name commandName("/localhost/nfd/faces");
-    commandName.append("create");
-    commandName.append(FaceType::getParameters().wireEncode());
-    auto command = makeInterest(commandName);
-    m_keyChain.sign(*command);
+    Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters());
 
     bool hasCallbackFired = false;
     this->node1.face.onSendData.connect(
-      [this, command, &hasCallbackFired, foundFace] (const Data& response) {
-        if (!command->getName().isPrefixOf(response.getName())) {
+      [this, req, &hasCallbackFired, foundFace] (const Data& response) {
+        if (!req.getName().isPrefixOf(response.getName())) {
           return;
         }
 
@@ -338,7 +323,7 @@
         hasCallbackFired = true;
       });
 
-    this->node1.face.receive(*command);
+    this->node1.face.receive(req);
     this->advanceClocks(time::milliseconds(1), 5);
 
     BOOST_CHECK(hasCallbackFired);
diff --git a/tests/daemon/mgmt/face-manager-update-face.t.cpp b/tests/daemon/mgmt/face-manager-update-face.t.cpp
index 6757622..e81e3be 100644
--- a/tests/daemon/mgmt/face-manager-update-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-update-face.t.cpp
@@ -68,18 +68,15 @@
   createFace(const ControlParameters& createParams,
              bool isForOnDemandFace = false)
   {
-    Name commandName("/localhost/nfd/faces/create");
-    commandName.append(createParams.wireEncode());
-    auto command = makeInterest(commandName);
-    m_keyChain.sign(*command);
+    Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", createParams);
 
     // if this creation if for on-demand face then create it on node2
     FaceManagerCommandNode& target = isForOnDemandFace ? this->node2 : this->node1;
 
     bool hasCallbackFired = false;
     signal::ScopedConnection connection = target.face.onSendData.connect(
-      [&, command, isForOnDemandFace, this] (const Data& response) {
-        if (!command->getName().isPrefixOf(response.getName())) {
+      [&, req, isForOnDemandFace, this] (const Data& response) {
+        if (!req.getName().isPrefixOf(response.getName())) {
           return;
         }
 
@@ -101,7 +98,7 @@
         }
       });
 
-    target.face.receive(*command);
+    target.face.receive(req);
     this->advanceClocks(time::milliseconds(1), 5);
 
     if (isForOnDemandFace) {
@@ -117,19 +114,16 @@
              bool isSelfUpdating,
              const function<void(const ControlResponse& resp)>& checkResp)
   {
-    Name commandName("/localhost/nfd/faces/update");
-    commandName.append(requestParams.wireEncode());
-    auto command = makeInterest(commandName);
+    Interest req = makeControlCommandRequest("/localhost/nfd/faces/update", requestParams);
     if (isSelfUpdating) {
       // Attach IncomingFaceIdTag to interest
-      command->setTag(make_shared<lp::IncomingFaceIdTag>(faceId));
+      req.setTag(make_shared<lp::IncomingFaceIdTag>(faceId));
     }
-    m_keyChain.sign(*command);
 
     bool hasCallbackFired = false;
     signal::ScopedConnection connection = this->node1.face.onSendData.connect(
-      [this, command, &hasCallbackFired, &checkResp] (const Data& response) {
-        if (!command->getName().isPrefixOf(response.getName())) {
+      [this, req, &hasCallbackFired, &checkResp] (const Data& response) {
+        if (!req.getName().isPrefixOf(response.getName())) {
           return;
         }
 
@@ -139,7 +133,7 @@
         hasCallbackFired = true;
       });
 
-    this->node1.face.receive(*command);
+    this->node1.face.receive(req);
     this->advanceClocks(time::milliseconds(1), 5);
 
     BOOST_CHECK(hasCallbackFired);
@@ -156,15 +150,12 @@
     ControlParameters params;
     params.setFaceId(faceId);
 
-    Name commandName("/localhost/nfd/faces/destroy");
-    commandName.append(params.wireEncode());
-    auto command = makeInterest(commandName);
-    m_keyChain.sign(*command);
+    Interest req = makeControlCommandRequest("/localhost/nfd/faces/destroy", params);
 
     bool hasCallbackFired = false;
     signal::ScopedConnection connection = this->node1.face.onSendData.connect(
-      [this, command, &hasCallbackFired] (const Data& response) {
-        if (!command->getName().isPrefixOf(response.getName())) {
+      [this, req, &hasCallbackFired] (const Data& response) {
+        if (!req.getName().isPrefixOf(response.getName())) {
           return;
         }
 
@@ -175,7 +166,7 @@
         hasCallbackFired = true;
       });
 
-    this->node1.face.receive(*command);
+    this->node1.face.receive(req);
     this->advanceClocks(time::milliseconds(1), 5);
 
     BOOST_CHECK(hasCallbackFired);
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index 41dcb90..52e2a11 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -125,14 +125,13 @@
   auto addedFace = addFace(REMOVE_LAST_NOTIFICATION | SET_SCOPE_LOCAL); // clear notification for creation
 
   auto parameters = ControlParameters().setFaceId(addedFace->getId());
-  auto command = makeControlCommandRequest("/localhost/nfd/faces/destroy", parameters);
-
-  receiveInterest(command);
+  auto req = makeControlCommandRequest("/localhost/nfd/faces/destroy", parameters);
+  receiveInterest(req);
 
   BOOST_REQUIRE_EQUAL(m_responses.size(), 2); // one response and one notification
   // notification is already tested, so ignore it
 
-  BOOST_CHECK_EQUAL(checkResponse(1, command->getName(), makeResponse(200, "OK", parameters)),
+  BOOST_CHECK_EQUAL(checkResponse(1, req.getName(), makeResponse(200, "OK", parameters)),
                     CheckResponseResult::OK);
 
   BOOST_CHECK_EQUAL(addedFace->getId(), face::INVALID_FACEID);
@@ -141,13 +140,11 @@
 BOOST_AUTO_TEST_CASE(NonExisting)
 {
   auto parameters = ControlParameters().setFaceId(65535);
-  auto command = makeControlCommandRequest("/localhost/nfd/faces/destroy", parameters);
-
-  receiveInterest(command);
+  auto req = makeControlCommandRequest("/localhost/nfd/faces/destroy", parameters);
+  receiveInterest(req);
 
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
-
-  BOOST_CHECK_EQUAL(checkResponse(0, command->getName(), makeResponse(200, "OK", parameters)),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), makeResponse(200, "OK", parameters)),
                     CheckResponseResult::OK);
 }
 
@@ -162,7 +159,7 @@
     addFace(REMOVE_LAST_NOTIFICATION | SET_URI_TEST | RANDOMIZE_COUNTERS);
   }
 
-  receiveInterest(makeInterest("/localhost/nfd/faces/list"));
+  receiveInterest(Interest("/localhost/nfd/faces/list"));
 
   Block content;
   BOOST_CHECK_NO_THROW(content = concatenateResponses());
@@ -202,10 +199,10 @@
   auto invalidQueryName =
     Name("/localhost/nfd/faces/query").append(ndn::makeStringBlock(tlv::Content, "invalid"));
 
-  receiveInterest(makeInterest(querySchemeName)); // face1 and face2 expected
-  receiveInterest(makeInterest(queryIdName)); // face1 expected
-  receiveInterest(makeInterest(queryScopeName)); // face1 and face3 expected
-  receiveInterest(makeInterest(invalidQueryName)); // nack expected
+  receiveInterest(Interest(querySchemeName)); // face1 and face2 expected
+  receiveInterest(Interest(queryIdName)); // face1 expected
+  receiveInterest(Interest(queryScopeName)); // face1 and face3 expected
+  receiveInterest(Interest(invalidQueryName)); // nack expected
 
   BOOST_REQUIRE_EQUAL(m_responses.size(), 4);
 
@@ -311,7 +308,7 @@
     addedChannels[channel->getUri().toString()] = channel;
   }
 
-  receiveInterest(makeInterest("/localhost/nfd/faces/channels"));
+  receiveInterest(Interest("/localhost/nfd/faces/channels"));
 
   Block content;
   BOOST_CHECK_NO_THROW(content = concatenateResponses());
diff --git a/tests/daemon/mgmt/fib-manager.t.cpp b/tests/daemon/mgmt/fib-manager.t.cpp
index 6fc59d1..7c86e28 100644
--- a/tests/daemon/mgmt/fib-manager.t.cpp
+++ b/tests/daemon/mgmt/fib-manager.t.cpp
@@ -158,13 +158,13 @@
 
 BOOST_AUTO_TEST_CASE(UnknownFaceId)
 {
-  auto command = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop",
-                                           makeParameters("hello", face::FACEID_NULL, 101));
-  receiveInterest(command);
+  auto req = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop",
+                                       makeParameters("hello", face::FACEID_NULL, 101));
+  receiveInterest(req);
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
 
   // check response
-  BOOST_CHECK_EQUAL(checkResponse(0, command->getName(), ControlResponse(410, "Face not found")),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), ControlResponse(410, "Face not found")),
                     CheckResponseResult::OK);
 
   // double check that the next hop was not added
@@ -181,14 +181,12 @@
   Name expectedName;
   ControlResponse expectedResponse;
   auto testAddNextHop = [&] (ControlParameters parameters, const FaceId& faceId) {
-    auto command = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", parameters,
-                   [&faceId] (shared_ptr<Interest> interest) {
-                     interest->setTag(make_shared<lp::IncomingFaceIdTag>(faceId));
-                   });
+    auto req = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", parameters);
+    req.setTag(make_shared<lp::IncomingFaceIdTag>(faceId));
     m_responses.clear();
-    expectedName = command->getName();
+    expectedName = req.getName();
     expectedResponse = makeResponse(200, "Success", parameters.setFaceId(faceId));
-    receiveInterest(command);
+    receiveInterest(req);
   };
 
   testAddNextHop(ControlParameters().setName("/hello").setCost(100).setFaceId(0), face1);
@@ -208,11 +206,11 @@
   BOOST_REQUIRE_NE(addedFaceId, face::INVALID_FACEID);
 
   auto parameters = makeParameters("hello", addedFaceId, 101);
-  auto command = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", parameters);
+  auto req = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", parameters);
+  receiveInterest(req);
 
-  receiveInterest(command);
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
-  BOOST_CHECK_EQUAL(checkResponse(0, command->getName(), makeResponse(200, "Success", parameters)),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), makeResponse(200, "Success", parameters)),
                     CheckResponseResult::OK);
   BOOST_CHECK_EQUAL(checkNextHop("/hello", 1, addedFaceId, 101), CheckNextHopResult::OK);
 }
@@ -224,11 +222,11 @@
 
   auto originalParameters = ControlParameters().setName("/hello").setFaceId(addedFaceId);
   auto parameters = makeParameters("/hello", addedFaceId, 0);
-  auto command = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", originalParameters);
+  auto req = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", originalParameters);
+  receiveInterest(req);
 
-  receiveInterest(command);
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
-  BOOST_CHECK_EQUAL(checkResponse(0, command->getName(), makeResponse(200, "Success", parameters)),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), makeResponse(200, "Success", parameters)),
                     CheckResponseResult::OK);
   BOOST_CHECK_EQUAL(checkNextHop("/hello", 1, addedFaceId, 0), CheckNextHopResult::OK);
 }
@@ -242,10 +240,10 @@
   ControlResponse expectedResponse;
   auto testAddNextHop = [&] (const ControlParameters& parameters) {
     m_responses.clear();
-    auto command = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", parameters);
-    expectedName = command->getName();
+    auto req = makeControlCommandRequest("/localhost/nfd/fib/add-nexthop", parameters);
+    expectedName = req.getName();
     expectedResponse = makeResponse(200, "Success", parameters);
-    receiveInterest(command);
+    receiveInterest(req);
   };
 
   // add initial, succeeds
@@ -273,10 +271,10 @@
   ControlResponse expectedResponse;
   auto testRemoveNextHop = [&] (const ControlParameters& parameters) {
     m_responses.clear();
-    auto command = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters);
-    expectedName = command->getName();
+    auto req = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters);
+    expectedName = req.getName();
     expectedResponse = makeResponse(200, "Success", parameters);
-    receiveInterest(command);
+    receiveInterest(req);
   };
 
   FaceId face1 = addFace();
@@ -313,12 +311,12 @@
   BOOST_REQUIRE_NE(addedFaceId, face::INVALID_FACEID);
 
   auto parameters = makeParameters("hello", addedFaceId);
-  auto command = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters);
-  auto response = makeResponse(200, "Success", parameters);
-
-  receiveInterest(command);
+  auto req = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters);
+  receiveInterest(req);
   BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
-  BOOST_CHECK_EQUAL(checkResponse(0, command->getName(), response), CheckResponseResult::OK);
+
+  auto expectedResponse = makeResponse(200, "Success", parameters);
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expectedResponse), CheckResponseResult::OK);
 }
 
 BOOST_AUTO_TEST_CASE(ImplicitFaceId)
@@ -332,13 +330,11 @@
   ControlResponse expectedResponse;
   auto testWithImplicitFaceId = [&] (ControlParameters parameters, FaceId face) {
     m_responses.clear();
-    auto command = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters,
-                   [face] (shared_ptr<Interest> interest) {
-                     interest->setTag(make_shared<lp::IncomingFaceIdTag>(face));
-                   });
-    expectedName = command->getName();
+    auto req = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters);
+    req.setTag(make_shared<lp::IncomingFaceIdTag>(face));
+    expectedName = req.getName();
     expectedResponse = makeResponse(200, "Success", parameters.setFaceId(face));
-    receiveInterest(command);
+    receiveInterest(req);
   };
 
   fib::Entry* entry = m_fib.insert("/hello").first;
@@ -367,10 +363,10 @@
   ControlResponse expectedResponse;
   auto testRemoveNextHop = [&] (ControlParameters parameters) {
     m_responses.clear();
-    auto command = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters);
-    expectedName = command->getName();
+    auto req = makeControlCommandRequest("/localhost/nfd/fib/remove-nexthop", parameters);
+    expectedName = req.getName();
     expectedResponse = makeResponse(200, "Success", parameters);
-    receiveInterest(command);
+    receiveInterest(req);
   };
 
   m_fib.insert("/hello").first->addNextHop(*m_faceTable.get(face1), 101);
@@ -402,7 +398,7 @@
     fibEntry->addNextHop(*m_faceTable.get(addFace()), std::numeric_limits<uint8_t>::max() - 2);
   }
 
-  receiveInterest(makeInterest("/localhost/nfd/fib/list"));
+  receiveInterest(Interest("/localhost/nfd/fib/list"));
 
   Block content = concatenateResponses();
   content.parse();
diff --git a/tests/daemon/mgmt/forwarder-status-manager.t.cpp b/tests/daemon/mgmt/forwarder-status-manager.t.cpp
index b9cade3..3b30b5c 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-2016,  Regents of the University of California,
+ * Copyright (c) 2014-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -70,9 +70,8 @@
 
   // request
   time::system_clock::TimePoint beforeRequest = time::system_clock::now();
-  auto request = makeInterest("ndn:/localhost/nfd/status/general");
-  request->setMustBeFresh(true);
-  request->setChildSelector(1);
+  Interest request("/localhost/nfd/status/general");
+  request.setMustBeFresh(true).setChildSelector(1);
   this->receiveInterest(request);
   time::system_clock::TimePoint afterRequest = time::system_clock::now();
 
diff --git a/tests/daemon/mgmt/nfd-manager-common-fixture.cpp b/tests/daemon/mgmt/nfd-manager-common-fixture.cpp
index 47a1655..f39e983 100644
--- a/tests/daemon/mgmt/nfd-manager-common-fixture.cpp
+++ b/tests/daemon/mgmt/nfd-manager-common-fixture.cpp
@@ -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-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -42,7 +42,7 @@
 void
 NfdManagerCommonFixture::setPrivilege(const std::string& privilege)
 {
-  this->saveIdentityCertificate(m_identityName, "ManagerCommonFixture.ndncert");
+  this->saveIdentityCertificate(DEFAULT_COMMAND_SIGNER_IDENTITY, "ManagerCommonFixture.ndncert");
 
   const std::string& config = R"CONFIG(
     authorizations
diff --git a/tests/daemon/mgmt/strategy-choice-manager.t.cpp b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
index 609fc5c..e0933e4 100644
--- a/tests/daemon/mgmt/strategy-choice-manager.t.cpp
+++ b/tests/daemon/mgmt/strategy-choice-manager.t.cpp
@@ -94,7 +94,7 @@
   expectedResp.setCode(200)
               .setText("OK")
               .setBody(expectedParams.wireEncode());
-  BOOST_CHECK_EQUAL(checkResponse(0, req->getName(), expectedResp),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expectedResp),
                     CheckResponseResult::OK);
 
   BOOST_CHECK_EQUAL(getInstanceName("/A"), strategyNameP);
@@ -114,7 +114,7 @@
   ControlResponse expectedResp;
   expectedResp.setCode(404)
               .setText("Strategy not registered");
-  BOOST_CHECK_EQUAL(checkResponse(0, req->getName(), expectedResp),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expectedResp),
                     CheckResponseResult::OK);
 
   BOOST_CHECK_EQUAL(hasEntry("/A"), false);
@@ -135,7 +135,7 @@
   expectedResp.setCode(200)
               .setText("OK")
               .setBody(expectedParams.wireEncode());
-  BOOST_CHECK_EQUAL(checkResponse(0, req->getName(), expectedResp),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expectedResp),
                     CheckResponseResult::OK);
 
   BOOST_CHECK_EQUAL(hasEntry("/A"), false);
@@ -153,7 +153,7 @@
   expectedResp.setCode(200)
               .setText("OK")
               .setBody(expectedParams.wireEncode());
-  BOOST_CHECK_EQUAL(checkResponse(0, req->getName(), expectedResp),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expectedResp),
                     CheckResponseResult::OK);
 
   BOOST_CHECK_EQUAL(hasEntry("/A"), false);
@@ -169,7 +169,7 @@
   ControlResponse expectedResp;
   expectedResp.setCode(400)
               .setText("failed in validating parameters");
-  BOOST_CHECK_EQUAL(checkResponse(0, req->getName(), expectedResp),
+  BOOST_CHECK_EQUAL(checkResponse(0, req.getName(), expectedResp),
                     CheckResponseResult::OK);
 
   BOOST_CHECK_EQUAL(hasEntry("/"), true);
@@ -192,7 +192,7 @@
     expected[name] = strategy;
   }
 
-  receiveInterest(makeInterest("/localhost/nfd/strategy-choice/list"));
+  receiveInterest(Interest("/localhost/nfd/strategy-choice/list"));
   Block dataset = concatenateResponses();
   dataset.parse();
   BOOST_CHECK_EQUAL(dataset.elements_size(), expected.size());
diff --git a/tests/manager-common-fixture.cpp b/tests/manager-common-fixture.cpp
index bc04045..bdda72e 100644
--- a/tests/manager-common-fixture.cpp
+++ b/tests/manager-common-fixture.cpp
@@ -29,13 +29,34 @@
 namespace nfd {
 namespace tests {
 
+const Name CommandInterestSignerFixture::DEFAULT_COMMAND_SIGNER_IDENTITY("/CommandInterestSignerFixture-identity");
+
+CommandInterestSignerFixture::CommandInterestSignerFixture()
+  : m_commandInterestSigner(m_keyChain)
+{
+  BOOST_REQUIRE(this->addIdentity(DEFAULT_COMMAND_SIGNER_IDENTITY));
+}
+
+Interest
+CommandInterestSignerFixture::makeCommandInterest(const Name& name, const Name& identity)
+{
+  return m_commandInterestSigner.makeCommandInterest(name, ndn::security::signingByIdentity(identity));
+}
+
+Interest
+CommandInterestSignerFixture::makeControlCommandRequest(Name commandName,
+                                                        const ControlParameters& params,
+                                                        const Name& identity)
+{
+  commandName.append(params.wireEncode());
+  return this->makeCommandInterest(commandName, identity);
+}
+
 ManagerCommonFixture::ManagerCommonFixture()
   : m_face(getGlobalIoService(), m_keyChain, {true, true})
   , m_dispatcher(m_face, m_keyChain, ndn::security::SigningInfo())
   , m_responses(m_face.sentData)
-  , m_identityName("/unit-test/ManagerCommonFixture/identity")
 {
-  BOOST_REQUIRE(this->addIdentity(m_identityName));
 }
 
 void
@@ -45,25 +66,10 @@
   advanceClocks(time::milliseconds(1));
 }
 
-shared_ptr<Interest>
-ManagerCommonFixture::makeControlCommandRequest(Name commandName,
-                                                const ControlParameters& parameters,
-                                                const InterestHandler& beforeSigning)
-{
-  shared_ptr<Interest> command = makeInterest(commandName.append(parameters.wireEncode()));
-
-  if (beforeSigning != nullptr) {
-    beforeSigning(command);
-  }
-
-  m_keyChain.sign(*command, ndn::security::signingByIdentity(m_identityName));
-  return command;
-}
-
 void
-ManagerCommonFixture::receiveInterest(shared_ptr<Interest> interest)
+ManagerCommonFixture::receiveInterest(const Interest& interest)
 {
-  m_face.receive(*interest);
+  m_face.receive(interest);
   advanceClocks(time::milliseconds(1));
 }
 
@@ -146,7 +152,7 @@
     Name prefix = name.getPrefix(-1);
     uint64_t segmentNo = name.at(-1).toSegment() + 1;
     // request for the next segment
-    receiveInterest(makeInterest(prefix.appendSegment(segmentNo)));
+    receiveInterest(Interest(prefix.appendSegment(segmentNo)));
   }
 
   size_t endIndex = startIndex + nResponses; // not included
@@ -166,41 +172,29 @@
 }
 
 std::ostream&
-operator<<(std::ostream &os, const ManagerCommonFixture::CheckResponseResult& result)
+operator<<(std::ostream& os, const ManagerCommonFixture::CheckResponseResult& result)
 {
   switch (result) {
-  case ManagerCommonFixture::CheckResponseResult::OK:
-    os << "OK";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::OUT_OF_BOUNDARY:
-    os << "OUT_OF_BOUNDARY";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::WRONG_NAME:
-    os << "WRONG_NAME";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::WRONG_CONTENT_TYPE:
-    os << "WRONG_CONTENT_TYPE";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::INVALID_RESPONSE:
-    os << "INVALID_RESPONSE";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::WRONG_CODE:
-    os << "WRONG_CODE";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::WRONG_TEXT:
-    os << "WRONG_TEXT";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::WRONG_BODY_SIZE:
-    os << "WRONG_BODY_SIZE";
-    break;
-  case ManagerCommonFixture::CheckResponseResult::WRONG_BODY_VALUE:
-    os << "WRONG_BODY_VALUE";
-    break;
-  default:
-    break;
-  };
-
-  return os;
+    case ManagerCommonFixture::CheckResponseResult::OK:
+      return os << "OK";
+    case ManagerCommonFixture::CheckResponseResult::OUT_OF_BOUNDARY:
+      return os << "OUT_OF_BOUNDARY";
+    case ManagerCommonFixture::CheckResponseResult::WRONG_NAME:
+      return os << "WRONG_NAME";
+    case ManagerCommonFixture::CheckResponseResult::WRONG_CONTENT_TYPE:
+      return os << "WRONG_CONTENT_TYPE";
+    case ManagerCommonFixture::CheckResponseResult::INVALID_RESPONSE:
+      return os << "INVALID_RESPONSE";
+    case ManagerCommonFixture::CheckResponseResult::WRONG_CODE:
+      return os << "WRONG_CODE";
+    case ManagerCommonFixture::CheckResponseResult::WRONG_TEXT:
+      return os << "WRONG_TEXT";
+    case ManagerCommonFixture::CheckResponseResult::WRONG_BODY_SIZE:
+      return os << "WRONG_BODY_SIZE";
+    case ManagerCommonFixture::CheckResponseResult::WRONG_BODY_VALUE:
+      return os << "WRONG_BODY_VALUE";
+  }
+  return os << static_cast<int>(result);
 }
 
 } // namespace tests
diff --git a/tests/manager-common-fixture.hpp b/tests/manager-common-fixture.hpp
index b829476..186a5db 100644
--- a/tests/manager-common-fixture.hpp
+++ b/tests/manager-common-fixture.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-2017,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -31,15 +31,48 @@
 #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
+ */
+class CommandInterestSignerFixture : public IdentityManagementTimeFixture
+{
+protected:
+  CommandInterestSignerFixture();
+
+  /** \brief sign a command Interest
+   *  \param name command name include prefix and parameters
+   *  \param identity signing identity
+   *  \return a command Interest
+   */
+  Interest
+  makeCommandInterest(const Name& name, const Name& identity = DEFAULT_COMMAND_SIGNER_IDENTITY);
+
+  /** \brief create a ControlCommand request
+   *  \param commandName command name including prefix, such as "/localhost/nfd/fib/add-nexthop"
+   *  \param params command parameters
+   *  \param identity signing identity
+   *  \return a command Interest
+   */
+  Interest
+  makeControlCommandRequest(Name commandName, const ControlParameters& params,
+                            const Name& identity = DEFAULT_COMMAND_SIGNER_IDENTITY);
+
+protected:
+  static const Name DEFAULT_COMMAND_SIGNER_IDENTITY;
+
+private:
+  ndn::security::CommandInterestSigner m_commandInterestSigner;
+};
+
 /**
  * @brief a collection of common functions shared by all manager's testing fixtures.
  */
-class ManagerCommonFixture : public IdentityManagementTimeFixture
+class ManagerCommonFixture : public CommandInterestSignerFixture
 {
 public: // initialize
   ManagerCommonFixture();
@@ -55,26 +88,6 @@
   setTopPrefix(const Name& topPrefix);
 
 public: // test
-  typedef std::function<void(shared_ptr<Interest> interest)> InterestHandler;
-
-  /**
-   * @brief create a ControlCommand request
-   *
-   * step1: append the @param parameters to the @param commandName and make an Interest.
-   * step2: call @param beforeSinging to do something with the Interest.
-   * step3: sign the generated command
-   *
-   * @param commandName the command name
-   * @param parameters the ControlParameters
-   * @param beforeSigning a callback that can modify the Interest before it's signed
-   *
-   * @return the signed ControlCommand request
-   */
-  shared_ptr<Interest>
-  makeControlCommandRequest(Name commandName,
-                            const ControlParameters& parameters,
-                            const InterestHandler& beforeSigning = nullptr);
-
   /**
    * @brief cause management to receive an Interest
    *
@@ -84,7 +97,7 @@
    * @param interest the Interest to receive
    */
   void
-  receiveInterest(shared_ptr<Interest> interest);
+  receiveInterest(const Interest& interest);
 
 public: // verify
   ControlResponse
@@ -145,11 +158,10 @@
   ndn::util::DummyClientFace m_face;
   ndn::mgmt::Dispatcher m_dispatcher;
   std::vector<Data>& m_responses; ///< a reference of m_face->sentData
-  Name m_identityName; ///< the identity to sign requests
 };
 
 std::ostream&
-operator<<(std::ostream &os, const ManagerCommonFixture::CheckResponseResult& result);
+operator<<(std::ostream& os, const ManagerCommonFixture::CheckResponseResult& result);
 
 } // namespace tests
 } // namespace nfd
diff --git a/tests/rib/rib-manager.t.cpp b/tests/rib/rib-manager.t.cpp
index 42e8c93..7ef0194 100644
--- a/tests/rib/rib-manager.t.cpp
+++ b/tests/rib/rib-manager.t.cpp
@@ -338,10 +338,10 @@
   auto expectedLocalhopResponse = this->m_status.isLocalhopConfigured ? successResp : failureResp;
 
   BOOST_REQUIRE_EQUAL(this->m_responses.size(), nExpectedResponses);
-  BOOST_CHECK_EQUAL(this->checkResponse(0, commandHost->getName(), expectedLocalhostResponse),
+  BOOST_CHECK_EQUAL(this->checkResponse(0, commandHost.getName(), expectedLocalhostResponse),
                     ManagerCommonFixture::CheckResponseResult::OK);
   if (nExpectedResponses == 2) {
-    BOOST_CHECK_EQUAL(this->checkResponse(1, commandHop->getName(), expectedLocalhopResponse),
+    BOOST_CHECK_EQUAL(this->checkResponse(1, commandHop.getName(), expectedLocalhopResponse),
                       ManagerCommonFixture::CheckResponseResult::OK);
   }
 }
@@ -353,20 +353,18 @@
   auto paramsRegister    = makeRegisterParameters("/test-register-unregister", 9527);
   auto paramsUnregister  = makeUnregisterParameters("/test-register-unregister", 9527);
 
-  auto setInFaceId = [] (shared_ptr<Interest> commandInterest) {
-    commandInterest->setTag(make_shared<lp::IncomingFaceIdTag>(1234));
-  };
-
-  auto commandRegister   = makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister, setInFaceId);
-  auto commandUnregister = makeControlCommandRequest("/localhost/nfd/rib/unregister", paramsUnregister, setInFaceId);
+  auto commandRegister = makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister);
+  commandRegister.setTag(make_shared<lp::IncomingFaceIdTag>(1234));
+  auto commandUnregister = makeControlCommandRequest("/localhost/nfd/rib/unregister", paramsUnregister);
+  commandUnregister.setTag(make_shared<lp::IncomingFaceIdTag>(1234));
 
   receiveInterest(commandRegister);
   receiveInterest(commandUnregister);
 
   BOOST_REQUIRE_EQUAL(m_responses.size(), 2);
-  BOOST_CHECK_EQUAL(checkResponse(0, commandRegister->getName(), makeResponse(200, "Success", paramsRegister)),
+  BOOST_CHECK_EQUAL(checkResponse(0, commandRegister.getName(), makeResponse(200, "Success", paramsRegister)),
                     CheckResponseResult::OK);
-  BOOST_CHECK_EQUAL(checkResponse(1, commandUnregister->getName(), makeResponse(200, "Success", paramsUnregister)),
+  BOOST_CHECK_EQUAL(checkResponse(1, commandUnregister.getName(), makeResponse(200, "Success", paramsUnregister)),
                     CheckResponseResult::OK);
 
   BOOST_REQUIRE_EQUAL(m_commands.size(), 2);
@@ -382,11 +380,10 @@
   BOOST_CHECK_EQUAL(paramsUnregister.getFaceId(), 0);
 
   const uint64_t inFaceId = 9527;
-  auto setInFaceId = [&inFaceId] (shared_ptr<Interest> commandInterest) {
-    commandInterest->setTag(make_shared<lp::IncomingFaceIdTag>(inFaceId));
-  };
-  auto commandRegister   = makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister, setInFaceId);
-  auto commandUnregister = makeControlCommandRequest("/localhost/nfd/rib/unregister", paramsUnregister, setInFaceId);
+  auto commandRegister = makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister);
+  commandRegister.setTag(make_shared<lp::IncomingFaceIdTag>(inFaceId));
+  auto commandUnregister = makeControlCommandRequest("/localhost/nfd/rib/unregister", paramsUnregister);
+  commandUnregister.setTag(make_shared<lp::IncomingFaceIdTag>(inFaceId));
 
   receiveInterest(commandRegister);
   receiveInterest(commandUnregister);
@@ -395,9 +392,9 @@
   paramsUnregister.setFaceId(inFaceId);
 
   BOOST_REQUIRE_EQUAL(m_responses.size(), 2);
-  BOOST_CHECK_EQUAL(checkResponse(0, commandRegister->getName(), makeResponse(200, "Success", paramsRegister)),
+  BOOST_CHECK_EQUAL(checkResponse(0, commandRegister.getName(), makeResponse(200, "Success", paramsRegister)),
                     CheckResponseResult::OK);
-  BOOST_CHECK_EQUAL(checkResponse(1, commandUnregister->getName(), makeResponse(200, "Success", paramsUnregister)),
+  BOOST_CHECK_EQUAL(checkResponse(1, commandUnregister.getName(), makeResponse(200, "Success", paramsUnregister)),
                     CheckResponseResult::OK);
 
   BOOST_REQUIRE_EQUAL(m_commands.size(), 2);
@@ -450,7 +447,7 @@
     }
   }
 
-  receiveInterest(makeInterest("/localhost/nfd/rib/list"));
+  receiveInterest(Interest("/localhost/nfd/rib/list"));
 
   Block content = concatenateResponses();
   content.parse();