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/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