mgmt: use new signed Interest format in nfd::Controller

Refs: #4804
Change-Id: I26640f0a0c5f2bceac431f9c7c3698f3d31d31e3
diff --git a/ndn-cxx/mgmt/nfd/controller.cpp b/ndn-cxx/mgmt/nfd/controller.cpp
index 8d8f248..6f0f74c 100644
--- a/ndn-cxx/mgmt/nfd/controller.cpp
+++ b/ndn-cxx/mgmt/nfd/controller.cpp
@@ -58,9 +58,10 @@
                          const CommandFailCallback& onFailure,
                          const CommandOptions& options)
 {
-  Name requestName = command->getRequestName(options.getPrefix(), parameters);
-  Interest interest = m_signer.makeCommandInterest(requestName, options.getSigningInfo());
+  Interest interest;
+  interest.setName(command->getRequestName(options.getPrefix(), parameters));
   interest.setInterestLifetime(options.getTimeout());
+  m_signer.makeSignedInterest(interest, options.getSigningInfo());
 
   m_face.expressInterest(interest,
     [=] (const Interest&, const Data& data) {
@@ -171,7 +172,7 @@
   BOOST_ASSERT(onFailure);
 
   switch (static_cast<SegmentFetcher::ErrorCode>(code)) {
-    // It's intentional to cast as SegmentFetcher::ErrorCode, and to not have a 'default' clause.
+    // It's intentional to cast to SegmentFetcher::ErrorCode and to not have a 'default' clause.
     // This forces the switch statement to handle every defined SegmentFetcher::ErrorCode,
     // and breaks compilation if it does not.
     case SegmentFetcher::ErrorCode::INTEREST_TIMEOUT:
@@ -182,8 +183,8 @@
       onFailure(ERROR_SERVER, msg);
       break;
     case SegmentFetcher::ErrorCode::SEGMENT_VALIDATION_FAIL:
-      /// \todo When SegmentFetcher exposes validator error code, Controller::ERROR_VALIDATION
-      ///       should be replaced with a range that corresponds to validator error codes.
+      // TODO: When SegmentFetcher exposes validator error code, Controller::ERROR_VALIDATION
+      //       should be replaced with a range that corresponds to validator error codes.
       onFailure(ERROR_VALIDATION, msg);
       break;
     case SegmentFetcher::ErrorCode::NACK_ERROR:
diff --git a/tests/unit/mgmt/nfd/controller.t.cpp b/tests/unit/mgmt/nfd/controller.t.cpp
index 83deb23..d871c8b 100644
--- a/tests/unit/mgmt/nfd/controller.t.cpp
+++ b/tests/unit/mgmt/nfd/controller.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2021 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -81,17 +81,18 @@
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
   const Interest& requestInterest = face.sentInterests[0];
 
-  FaceCreateCommand command;
   BOOST_CHECK(Name("/localhost/nfd/faces/create").isPrefixOf(requestInterest.getName()));
-  // 9 components: ndn:/localhost/nfd/faces/create/<parameters>/<signed Interest x4>
-  BOOST_REQUIRE_EQUAL(requestInterest.getName().size(), 9);
-  ControlParameters request;
-  // 4th component: <parameters>
-  BOOST_REQUIRE_NO_THROW(request.wireDecode(requestInterest.getName().at(4).blockFromValue()));
-  BOOST_CHECK_NO_THROW(command.validateRequest(request));
-  BOOST_CHECK_EQUAL(request.getUri(), parameters.getUri());
+  BOOST_CHECK(requestInterest.isSigned());
+  BOOST_CHECK(requestInterest.isParametersDigestValid());
   BOOST_CHECK_EQUAL(requestInterest.getInterestLifetime(), CommandOptions::DEFAULT_TIMEOUT);
 
+  // 6 components: /localhost/nfd/faces/create/<parameters>/params-sha256=...
+  BOOST_REQUIRE_EQUAL(requestInterest.getName().size(), 6);
+  ControlParameters requestParams(requestInterest.getName()[4].blockFromValue());
+  FaceCreateCommand command;
+  BOOST_CHECK_NO_THROW(command.validateRequest(requestParams));
+  BOOST_CHECK_EQUAL(requestParams.getUri(), parameters.getUri());
+
   ControlParameters responseBody = makeFaceCreateResponse();
   ControlResponse responsePayload(201, "created");
   responsePayload.setBody(responseBody.wireEncode());
@@ -136,6 +137,8 @@
 
   FaceCreateCommand command;
   BOOST_CHECK(Name("/localhop/net/example/router1/nfd/rib/register").isPrefixOf(requestInterest.getName()));
+  BOOST_CHECK(requestInterest.isSigned());
+  BOOST_CHECK(requestInterest.isParametersDigestValid());
 }
 
 BOOST_AUTO_TEST_CASE(InvalidRequest)
@@ -144,8 +147,7 @@
   parameters.setName("ndn:/should-not-have-this-field");
   // Uri is missing
 
-  BOOST_CHECK_THROW(controller.start<FaceCreateCommand>(
-                      parameters, succeedCallback, commandFailCallback),
+  BOOST_CHECK_THROW(controller.start<FaceCreateCommand>(parameters, succeedCallback, commandFailCallback),
                     ControlCommand::ArgumentError);
 }