management: deprecate CommandOptions signing params

refs #2893

Change-Id: I07e53094cf598015456b666e1d0991b45452c900
diff --git a/src/management/nfd-command-options.cpp b/src/management/nfd-command-options.cpp
index 97a1be8..72326c9 100644
--- a/src/management/nfd-command-options.cpp
+++ b/src/management/nfd-command-options.cpp
@@ -108,8 +108,8 @@
   return *this;
 }
 
-CommandOptions&
-CommandOptions::setSigningCertificate(const Name& certificateName)
+static security::SigningInfo
+makeSigningInfoFromIdentityCertificate(const Name& certificateName)
 {
   // A valid IdentityCertificate has at least 4 name components,
   // as it follows `<...>/KEY/<...>/<key-id>/ID-CERT/<version>` naming model.
@@ -117,14 +117,21 @@
     throw std::invalid_argument("certificate is invalid");
   }
 
-  m_signingInfo = security::signingByCertificate(certificateName);
+  return security::signingByCertificate(certificateName);
+}
+
+CommandOptions&
+CommandOptions::setSigningCertificate(const Name& certificateName)
+{
+  m_signingInfo = makeSigningInfoFromIdentityCertificate(certificateName);
   return *this;
 }
 
 CommandOptions&
 CommandOptions::setSigningCertificate(const IdentityCertificate& certificate)
 {
-  return this->setSigningCertificate(certificate.getName());
+  m_signingInfo = makeSigningInfoFromIdentityCertificate(certificate.getName());
+  return *this;
 }
 
 #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
diff --git a/src/management/nfd-command-options.hpp b/src/management/nfd-command-options.hpp
index 7d43c1d..b88356f 100644
--- a/src/management/nfd-command-options.hpp
+++ b/src/management/nfd-command-options.hpp
@@ -110,30 +110,34 @@
   /** \deprecated use getSigningInfo and setSigningInfo
    *  \return selection of signing parameters
    */
+  DEPRECATED(
   SigningParamsKind
-  getSigningParamsKind() const;
+  getSigningParamsKind() const);
 
   /** \deprecated use getSigningInfo and setSigningInfo
    *  \return identity Name
    *  \pre getSigningParamsKind() == SIGNING_PARAMS_IDENTITY
    */
+  DEPRECATED(
   const Name&
-  getSigningIdentity() const;
+  getSigningIdentity() const);
 
   /** \deprecated use getSigningInfo and setSigningInfo
    *  \return certificate Name
    *  \pre getSigningParamsKind() == SIGNING_PARAMS_CERTIFICATE
    */
+  DEPRECATED(
   const Name&
-  getSigningCertificate() const;
+  getSigningCertificate() const);
 
   /** \deprecated use getSigningInfo and setSigningInfo
    *  \brief chooses to use default identity and certificate
    *  \post getSigningParamsKind() == SIGNING_PARAMS_DEFAULT
    *  \return self
    */
+  DEPRECATED(
   CommandOptions&
-  setSigningDefault();
+  setSigningDefault());
 
   /** \deprecated use getSigningInfo and setSigningInfo
    *  \brief chooses to use a specific identity and its default certificate
@@ -141,8 +145,9 @@
    *  \post getIdentityName() == identityName
    *  \return self
    */
+  DEPRECATED(
   CommandOptions&
-  setSigningIdentity(const Name& identityName);
+  setSigningIdentity(const Name& identityName));
 
   /** \deprecated use getSigningInfo and setSigningInfo
    *  \brief chooses to use a specific identity certificate
@@ -152,15 +157,17 @@
    *  \post getSigningCertificate() == certificateName
    *  \return self
    */
+  DEPRECATED(
   CommandOptions&
-  setSigningCertificate(const Name& certificateName);
+  setSigningCertificate(const Name& certificateName));
 
   /** \deprecated use getSigningInfo and setSigningInfo
    *  \brief chooses to use a specific identity certificate
    *  \details This is equivalent to .setIdentityCertificate(certificate.getName())
    */
+  DEPRECATED(
   CommandOptions&
-  setSigningCertificate(const IdentityCertificate& certificate);
+  setSigningCertificate(const IdentityCertificate& certificate));
 
 #endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
 
diff --git a/tests/unit-tests/management/nfd-command-options.t.cpp b/tests/unit-tests/management/nfd-command-options.t.cpp
index d67d865..4cccc95 100644
--- a/tests/unit-tests/management/nfd-command-options.t.cpp
+++ b/tests/unit-tests/management/nfd-command-options.t.cpp
@@ -22,10 +22,6 @@
 #include "management/nfd-command-options.hpp"
 #include "security/signing-helpers.hpp"
 
-#ifdef NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
-#include "security/identity-certificate.hpp"
-#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
-
 #include "boost-test.hpp"
 
 namespace ndn {
@@ -72,48 +68,6 @@
   BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerName(), "ndn:/tmp/identity");
 }
 
-#ifdef NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
-BOOST_AUTO_TEST_CASE(SigningParams)
-{
-  CommandOptions co;
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_DEFAULT);
-
-  co.setSigningIdentity("ndn:/tmp/identity");
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_IDENTITY);
-  BOOST_CHECK_EQUAL(co.getSigningIdentity(), Name("ndn:/tmp/identity"));
-
-  co.setSigningDefault(); // reset
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_DEFAULT);
-
-  co.setSigningIdentity(Name()); // empty Name is valid identity Name
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_IDENTITY);
-  BOOST_CHECK_EQUAL(co.getSigningIdentity(), Name());
-
-  co.setSigningDefault(); // reset
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_DEFAULT);
-
-  co.setSigningCertificate("ndn:/tmp/KEY/identity/dsk-1/ID-CERT/%FD%01");
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_CERTIFICATE);
-  BOOST_CHECK_EQUAL(co.getSigningCertificate(),
-                    Name("ndn:/tmp/KEY/identity/dsk-1/ID-CERT/%FD%01"));
-
-  co.setSigningDefault(); // reset
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_DEFAULT);
-
-  co.setSigningCertificate("ndn:/KEY/dsk-1/ID-CERT/%FD%01"); // minimal certificateName
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_CERTIFICATE);
-  BOOST_CHECK_EQUAL(co.getSigningCertificate(), Name("ndn:/KEY/dsk-1/ID-CERT/%FD%01"));
-
-  co.setSigningDefault(); // reset
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(), CommandOptions::SIGNING_PARAMS_DEFAULT);
-
-  BOOST_CHECK_THROW(co.setSigningCertificate(IdentityCertificate()), // invalid certificate
-                    std::invalid_argument);
-  BOOST_CHECK_EQUAL(co.getSigningParamsKind(),
-                    CommandOptions::SIGNING_PARAMS_DEFAULT); // unchanged after throw
-}
-#endif // NDN_MANAGEMENT_NFD_COMMAND_OPTIONS_KEEP_DEPRECATED_SIGNING_PARAMS
-
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests