tests: ignore ParametersSha256DigestComponent in name prefix check

Plus various minor cleanups

Change-Id: I0907eb80a550a663fbef2ff0a7e24a40614e8655
diff --git a/tests/boost-test.hpp b/tests/boost-test.hpp
index bb32232..77b879f 100644
--- a/tests/boost-test.hpp
+++ b/tests/boost-test.hpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2014-2019, Regents of the University of California,
  *                          Arizona Board of Regents,
  *                          Colorado State University,
@@ -34,7 +34,5 @@
 
 #define BOOST_TEST_DYN_LINK
 #include <boost/test/unit_test.hpp>
-#include <boost/concept_check.hpp>
-#include <boost/test/output_test_stream.hpp>
 
 #endif // NDNCERT_TESTS_BOOST_TEST_HPP
diff --git a/tests/main.cpp b/tests/main.cpp
index 96026e9..72ad856 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2014-2019, Regents of the University of California,
  *                          Arizona Board of Regents,
  *                          Colorado State University,
@@ -25,8 +25,7 @@
  * See AUTHORS.md for complete list of ndncert authors and contributors.
  */
 
-#define BOOST_TEST_DYN_LINK
-#define BOOST_TEST_ALTERNATIVE_INIT_API
+#define BOOST_TEST_MODULE NDNCERT Unit Tests
 
 #include <boost/version.hpp>
 
@@ -34,9 +33,9 @@
 // Boost.Test v3.3 (Boost 1.62) natively supports multi-logger output
 #include "boost-test.hpp"
 #else
+#define BOOST_TEST_ALTERNATIVE_INIT_API
 #define BOOST_TEST_NO_MAIN
 #include "boost-test.hpp"
-
 #include "boost-multi-log-formatter.hpp"
 
 #include <boost/program_options/options_description.hpp>
@@ -114,4 +113,4 @@
   return ::boost::unit_test::unit_test_main(&init_tests, argc, argv);
 }
 
-#endif // BOOST_VERSION >= 106200
\ No newline at end of file
+#endif // BOOST_VERSION >= 106200
diff --git a/tests/unit-tests/ca-config.t.cpp b/tests/unit-tests/ca-config.t.cpp
index 0e53dff..0cebb26 100644
--- a/tests/unit-tests/ca-config.t.cpp
+++ b/tests/unit-tests/ca-config.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -21,6 +21,7 @@
 #include "ca-config.hpp"
 
 #include "identity-management-fixture.hpp"
+
 #include <ndn-cxx/security/transform/base64-encode.hpp>
 #include <ndn-cxx/security/transform/buffer-source.hpp>
 #include <ndn-cxx/security/transform/stream-sink.hpp>
@@ -35,7 +36,7 @@
 {
   CaConfig config;
   config.load("tests/unit-tests/ca.conf.test");
-  BOOST_CHECK_EQUAL(config.m_caName.toUri(), "/ndn");
+  BOOST_CHECK_EQUAL(config.m_caName, "/ndn");
   BOOST_CHECK_EQUAL(config.m_freshnessPeriod, time::seconds(720));
   BOOST_CHECK_EQUAL(config.m_validityPeriod, time::days(360));
   BOOST_CHECK_EQUAL(config.m_probe, "");
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index b1d8777..bb6153f 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -24,11 +24,11 @@
 #include "challenge-module.hpp"
 #include "challenge-module/challenge-pin.hpp"
 #include "challenge-module/challenge-email.hpp"
+
 #include <ndn-cxx/util/dummy-client-face.hpp>
 #include <ndn-cxx/security/signing-helpers.hpp>
 #include <ndn-cxx/security/transform/public-key.hpp>
 #include <ndn-cxx/security/verification-helpers.hpp>
-#include <iostream>
 
 namespace ndn {
 namespace ndncert {
@@ -40,7 +40,7 @@
 {
   util::DummyClientFace face(io, {true, true});
   CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
-  BOOST_CHECK_EQUAL(ca.getCaConf().m_caName.toUri(), "/ndn");
+  BOOST_CHECK_EQUAL(ca.getCaConf().m_caName, "/ndn");
 
   auto identity = addIdentity(Name("/ndn/site2"));
   auto key = identity.getDefaultKey();
@@ -107,7 +107,7 @@
       BOOST_CHECK(security::verifySignature(response, cert));
       auto contentJson = ClientModule::getJsonFromData(response);
       auto caItem = ClientConfig::extractCaItem(contentJson);
-      BOOST_CHECK_EQUAL(caItem.m_caName.toUri(), "/ndn");
+      BOOST_CHECK_EQUAL(caItem.m_caName, "/ndn");
       BOOST_CHECK_EQUAL(caItem.m_probe, "");
       BOOST_CHECK_EQUAL(caItem.m_anchor.wireEncode(), cert.wireEncode());
       BOOST_CHECK_EQUAL(caItem.m_caInfo, "ndn testbed ca");
@@ -241,7 +241,6 @@
   auto newInterest = client.generateNewInterest(time::system_clock::now(),
                                                 time::system_clock::now() + time::days(10), Name("/ndn/zhiyi"));
 
-  std::cout << "hi there" << std::endl;
   // generate CHALLENGE Interest
   ChallengePin pinChallenge;
   shared_ptr<Interest> challengeInterest = nullptr;
@@ -252,14 +251,8 @@
   face.onSendData.connect([&] (const Data& response) {
     if (Name("/ndn/CA/_NEW").isPrefixOf(response.getName())) {
       auto contentJson = ClientModule::getJsonFromData(response);
-      std::cout << "Request ID " << contentJson.get<std::string>(JSON_CA_EQUEST_ID) << std::endl;
       client.onNewResponse(response);
-
       auto paramJson = pinChallenge.getRequirementForChallenge(client.m_status, client.m_challengeStatus);
-      for (auto& item : paramJson) {
-        std::cout << "JSON attribute" << item.first;
-        std::cout << " : " << item.second.get<std::string>("") << std::endl;
-      }
       challengeInterest = client.generateChallengeInterest(pinChallenge.genChallengeRequestJson(client.m_status,
                                                                                                 client.m_challengeStatus,
                                                                                                 paramJson));
@@ -271,11 +264,8 @@
       client.onChallengeResponse(response);
       BOOST_CHECK_EQUAL(client.m_status, STATUS_CHALLENGE);
       BOOST_CHECK_EQUAL(client.m_challengeStatus, ChallengePin::NEED_CODE);
+
       auto paramJson = pinChallenge.getRequirementForChallenge(client.m_status, client.m_challengeStatus);
-      for (auto& item : paramJson) {
-        std::cout << "JSON attribute" << item.first;
-        std::cout << " : " << item.second.get<std::string>("") << std::endl;
-      }
       challengeInterest2 = client.generateChallengeInterest(pinChallenge.genChallengeRequestJson(client.m_status,
                                                                                                  client.m_challengeStatus,
                                                                                                  paramJson));
@@ -287,14 +277,13 @@
       client.onChallengeResponse(response);
       BOOST_CHECK_EQUAL(client.m_status, STATUS_CHALLENGE);
       BOOST_CHECK_EQUAL(client.m_challengeStatus, ChallengePin::WRONG_CODE);
+
       auto paramJson = pinChallenge.getRequirementForChallenge(client.m_status, client.m_challengeStatus);
       auto request = ca.getCertificateRequest(*challengeInterest2);
       auto secret = request.m_challengeSecrets.get(ChallengePin::JSON_PIN_CODE, "");
-      for (auto& item : paramJson) {
-        std::cout << "JSON attribute" << item.first;
-        std::cout << " : " << item.second.get<std::string>("") << std::endl;
-        if (item.first == ChallengePin::JSON_PIN_CODE)
-          item.second.put("", secret);
+      for (auto& i : paramJson) {
+        if (i.first == ChallengePin::JSON_PIN_CODE)
+          i.second.put("", secret);
       }
       challengeInterest3 = client.generateChallengeInterest(pinChallenge.genChallengeRequestJson(client.m_status,
                                                                                                  client.m_challengeStatus,
@@ -308,7 +297,8 @@
       BOOST_CHECK_EQUAL(client.m_status, STATUS_SUCCESS);
       BOOST_CHECK_EQUAL(client.m_challengeStatus, CHALLENGE_STATUS_SUCCESS);
     }
-    });
+  });
+
   face.receive(*newInterest);
   advanceClocks(time::milliseconds(20), 60);
   face.receive(*challengeInterest);
diff --git a/tests/unit-tests/ca-sqlite.t.cpp b/tests/unit-tests/ca-sqlite.t.cpp
index 16dbfe8..d78bb46 100644
--- a/tests/unit-tests/ca-sqlite.t.cpp
+++ b/tests/unit-tests/ca-sqlite.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -19,8 +19,8 @@
  */
 
 #include "ca-detail/ca-sqlite.hpp"
+
 #include "database-fixture.hpp"
-#include <iostream>
 
 namespace ndn {
 namespace ndncert {
diff --git a/tests/unit-tests/challenge-email.t.cpp b/tests/unit-tests/challenge-email.t.cpp
index af86a5f..e67397e 100644
--- a/tests/unit-tests/challenge-email.t.cpp
+++ b/tests/unit-tests/challenge-email.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -19,6 +19,7 @@
  */
 
 #include "challenge-module/challenge-email.hpp"
+
 #include "identity-management-fixture.hpp"
 
 namespace ndn {
@@ -27,7 +28,7 @@
 
 BOOST_FIXTURE_TEST_SUITE(TestChallengeEmail, IdentityManagementFixture)
 
-BOOST_AUTO_TEST_CASE(TestChallengeType)
+BOOST_AUTO_TEST_CASE(ChallengeType)
 {
   ChallengeEmail challenge;
   BOOST_CHECK_EQUAL(challenge.CHALLENGE_TYPE, "Email");
@@ -85,7 +86,7 @@
   line = line.substr(end + 1);
 
   std::string certName = line;
-  BOOST_CHECK_EQUAL(certName, cert.getName().toUri());
+  BOOST_CHECK_EQUAL(certName, cert.getName());
   std::remove("tmp.txt");
 }
 
diff --git a/tests/unit-tests/challenge-pin.t.cpp b/tests/unit-tests/challenge-pin.t.cpp
index 95c7259..35466ff 100644
--- a/tests/unit-tests/challenge-pin.t.cpp
+++ b/tests/unit-tests/challenge-pin.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -19,6 +19,7 @@
  */
 
 #include "challenge-module/challenge-pin.hpp"
+
 #include "identity-management-fixture.hpp"
 
 namespace ndn {
@@ -27,7 +28,7 @@
 
 BOOST_FIXTURE_TEST_SUITE(TestChallengePin, IdentityManagementFixture)
 
-BOOST_AUTO_TEST_CASE(TestGetInitInfo)
+BOOST_AUTO_TEST_CASE(ChallengeType)
 {
   ChallengePin challenge;
   BOOST_CHECK_EQUAL(challenge.CHALLENGE_TYPE, "PIN");
diff --git a/tests/unit-tests/client-config.t.cpp b/tests/unit-tests/client-config.t.cpp
index 1026ad8..5d662ff 100644
--- a/tests/unit-tests/client-config.t.cpp
+++ b/tests/unit-tests/client-config.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -35,10 +35,10 @@
   BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
 
   const auto& item = config.m_caItems.front();
-  BOOST_CHECK_EQUAL(item.m_caName.toUri(), "/ndn/edu/ucla");
+  BOOST_CHECK_EQUAL(item.m_caName, "/ndn/edu/ucla");
   BOOST_CHECK_EQUAL(item.m_caInfo, "UCLA's ceritificate authority, located in BH4805.");
   BOOST_CHECK_EQUAL(item.m_probe, "email");
-  BOOST_CHECK_EQUAL(item.m_anchor.getName().toUri(),
+  BOOST_CHECK_EQUAL(item.m_anchor.getName(),
                     "/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
 
   BOOST_CHECK_EQUAL(config.m_localNdncertAnchor, "/usr/local/etc/ndncert/anchor.key");
@@ -57,12 +57,12 @@
   config.m_caItems.push_back(item);
   BOOST_CHECK_EQUAL(config.m_caItems.size(), 3);
   auto lastItem = config.m_caItems.back();
-  BOOST_CHECK_EQUAL(lastItem.m_caName.toUri(), "/test");
+  BOOST_CHECK_EQUAL(lastItem.m_caName, "/test");
 
   config.removeCaItem(Name("/test"));
   BOOST_CHECK_EQUAL(config.m_caItems.size(), 2);
   lastItem = config.m_caItems.back();
-  BOOST_CHECK_EQUAL(lastItem.m_caName.toUri(), "/ndn/edu/ucla/zhiyi");
+  BOOST_CHECK_EQUAL(lastItem.m_caName, "/ndn/edu/ucla/zhiyi");
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestClientConfig
diff --git a/tests/unit-tests/client-module.t.cpp b/tests/unit-tests/client-module.t.cpp
index 1da13ce..9dde9dd 100644
--- a/tests/unit-tests/client-module.t.cpp
+++ b/tests/unit-tests/client-module.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -19,9 +19,11 @@
  */
 
 #include "client-module.hpp"
-#include "identity-management-fixture.hpp"
 #include "challenge-module.hpp"
 #include "ca-module.hpp"
+
+#include "identity-management-fixture.hpp"
+
 #include <ndn-cxx/util/dummy-client-face.hpp>
 #include <ndn-cxx/security/signing-helpers.hpp>
 #include <ndn-cxx/security/transform/public-key.hpp>
@@ -56,12 +58,14 @@
   client.getClientConf().m_caItems.push_back(item);
 
   auto firstInterest = client.generateProbeInterest(item, "zhiyi@cs.ucla.edu:987654321:Zhiyi Zhang");
-  BOOST_CHECK_EQUAL(firstInterest->getName().toUri(), "/site/CA/_PROBE");
+  BOOST_CHECK(firstInterest->getName().at(-1).isParametersSha256Digest());
+  // ignore the last name component (ParametersSha256Digest)
+  BOOST_CHECK_EQUAL(firstInterest->getName().getPrefix(-1), "/site/CA/_PROBE");
   BOOST_CHECK_EQUAL(CaModule::jsonFromBlock(firstInterest->getApplicationParameters()).get<std::string>("email"),
                     "zhiyi@cs.ucla.edu");
 }
 
-BOOST_AUTO_TEST_CASE(genProbeRequestJson)
+BOOST_AUTO_TEST_CASE(GenProbeRequestJson)
 {
   ClientModule client(m_keyChain);
   client.getClientConf().load("tests/unit-tests/client.conf.test");
diff --git a/tests/unit-tests/crypto-helper.t.cpp b/tests/unit-tests/crypto-helper.t.cpp
index 385dbbd..dc2dd66 100644
--- a/tests/unit-tests/crypto-helper.t.cpp
+++ b/tests/unit-tests/crypto-helper.t.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2017-2019, Regents of the University of California.
  *
  * This file is part of ndncert, a certificate management system based on NDN.
@@ -19,8 +19,8 @@
  */
 
 #include "crypto-support/crypto-helper.hpp"
+
 #include "identity-management-fixture.hpp"
-#include <iostream>
 
 namespace ndn {
 namespace ndncert {
@@ -72,11 +72,10 @@
                                 bobResult, bobResult + 32);
 }
 
-
-BOOST_AUTO_TEST_CASE(NDN_COMPUTE_HMAC_SHA256_TEST1)
+BOOST_AUTO_TEST_CASE(HmacSha256)
 {
   uint8_t secret[] = {0x00,0x01,0x02,0x03,0x04,0x05,
-                 0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c};
+                      0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c};
 
   uint8_t salt[] = {0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
                     0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
@@ -95,7 +94,7 @@
   BOOST_CHECK(memcmp(expected, result, sizeof(result)) == 0);
 }
 
-BOOST_AUTO_TEST_CASE(IETF_TEST_1)
+BOOST_AUTO_TEST_CASE(HkdfIetf1)
 {
   uint8_t secret[] = {0x00,0x01,0x02,0x03,0x04,0x05,
                       0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c};
@@ -124,7 +123,7 @@
   BOOST_CHECK(memcmp(expected, result, sizeof(result)) == 0);
 }
 
-BOOST_AUTO_TEST_CASE(IETF_TEST_2)
+BOOST_AUTO_TEST_CASE(HkdfIetf2)
 {
   uint8_t secret[] = {0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,
                       0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
@@ -182,7 +181,7 @@
   BOOST_CHECK(memcmp(expected, result, 42) == 0);
 }
 
-BOOST_AUTO_TEST_CASE(IETF_TEST_3)
+BOOST_AUTO_TEST_CASE(HkdfIetf3)
 {
   //uint8_t secret[] = {}; secret is empty in this test
 
@@ -209,7 +208,6 @@
   BOOST_CHECK(memcmp(expected, result, sizeof(result)) == 0);
 }
 
-
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests
diff --git a/tests/wscript b/tests/wscript
index 685a0bf..a366fe6 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -13,7 +13,6 @@
         features='cxx',
         source="main.cpp",
         use='ndn-cert BOOST',
-        defines=['BOOST_TEST_MODULE=\"NDNCERT Tests\"']
         )
 
     unit_test = bld.program(