tests: Implement IdentityManagementV2Fixture for v2::KeyChain

The old IdentityManagementFixture is renamed to IdentityManagementV1Fixture.

This commit also removes global KeyChainFixture, as it doesn't work with
TestKeyChain test suites.  Instead, IdentityManagementFixtures are
customizing PIB/TPM modules.

Change-Id: Iadc43b78523cd43bff4f454d6aea2fca8107a650
Refs: #2926
diff --git a/tests/unit-tests/security/command-interest-validator.t.cpp b/tests/unit-tests/security/command-interest-validator.t.cpp
index f31f3a3..09ae2b9 100644
--- a/tests/unit-tests/security/command-interest-validator.t.cpp
+++ b/tests/unit-tests/security/command-interest-validator.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -56,7 +56,7 @@
   {
     Name name("/localhost/CommandInterestValidatorIdentity");
     name.appendSequenceNumber(identity);
-    BOOST_REQUIRE(m_keyChain.doesIdentityExist(name) || this->addIdentity(name));
+    this->addIdentity(name);
     return name;
   }
 
diff --git a/tests/unit-tests/security/conf/checker.t.cpp b/tests/unit-tests/security/conf/checker.t.cpp
index 9ddf43a..493ac16 100644
--- a/tests/unit-tests/security/conf/checker.t.cpp
+++ b/tests/unit-tests/security/conf/checker.t.cpp
@@ -42,11 +42,11 @@
   using security::conf::RelationKeyLocatorNameChecker;
 
   Name identity("/SecurityTestConfChecker/CustomizedCheckerTest1");
-  BOOST_REQUIRE(addIdentity(identity, RsaKeyParams()));
+  addIdentity(identity, RsaKeyParams());
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name identity2("/SecurityTestConfChecker/CustomizedCheckerTest1Wrong");
-  BOOST_REQUIRE(addIdentity(identity2, RsaKeyParams()));
+  addIdentity(identity2, RsaKeyParams());
   Name certName2 = m_keyChain.getDefaultCertificateNameForIdentity(identity2);
 
   Name packetName("/SecurityTestConfChecker/CustomizedCheckerTest1/Data");
@@ -157,11 +157,11 @@
   using security::conf::RegexKeyLocatorNameChecker;
 
   Name identity("/SecurityTestConfChecker/CustomizedCheckerTest2");
-  BOOST_REQUIRE(addIdentity(identity, RsaKeyParams()));
+  addIdentity(identity, RsaKeyParams());
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name identity2("/SecurityTestConfChecker/CustomizedCheckerTest2Wrong");
-  BOOST_REQUIRE(addIdentity(identity2, RsaKeyParams()));
+  addIdentity(identity2, RsaKeyParams());
   Name certName2 = m_keyChain.getDefaultCertificateNameForIdentity(identity2);
 
   Name packetName("/SecurityTestConfChecker/CustomizedCheckerTest2/Data");
@@ -213,11 +213,11 @@
   using security::conf::RegexKeyLocatorNameChecker;
 
   Name identity("/SecurityTestConfChecker/CustomizedCheckerTest3");
-  BOOST_REQUIRE(addIdentity(identity, EcdsaKeyParams()));
+  addIdentity(identity, EcdsaKeyParams());
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name identity2("/SecurityTestConfChecker/CustomizedCheckerTest3Wrong");
-  BOOST_REQUIRE(addIdentity(identity2, EcdsaKeyParams()));
+  addIdentity(identity2, EcdsaKeyParams());
   Name certName2 = m_keyChain.getDefaultCertificateNameForIdentity(identity2);
 
   Name packetName("/SecurityTestConfChecker/CustomizedCheckerTest3/Data");
@@ -273,11 +273,11 @@
   using security::conf::HierarchicalChecker;
 
   Name identity("/SecurityTestConfChecker/HierarchicalCheckerTest1");
-  BOOST_REQUIRE(addIdentity(identity, EcdsaKeyParams()));
+  addIdentity(identity, EcdsaKeyParams());
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name identity2("/SecurityTestConfChecker/HierarchicalCheckerTest1/Data");
-  BOOST_REQUIRE(addIdentity(identity2, RsaKeyParams()));
+  addIdentity(identity2, RsaKeyParams());
   Name certName2 = m_keyChain.getDefaultCertificateNameForIdentity(identity2);
 
   Name packetName("/SecurityTestConfChecker/HierarchicalCheckerTest1/Data");
@@ -363,12 +363,12 @@
   using security::conf::FixedSignerChecker;
 
   Name identity("/SecurityTestConfChecker/FixedSignerCheckerTest1");
-  BOOST_REQUIRE(addIdentity(identity, EcdsaKeyParams()));
+  addIdentity(identity, EcdsaKeyParams());
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
   shared_ptr<v1::IdentityCertificate> cert1 = m_keyChain.getCertificate(certName);
 
   Name identity2("/SecurityTestConfChecker/FixedSignerCheckerTest1Wrong");
-  BOOST_REQUIRE(addIdentity(identity2, RsaKeyParams()));
+  addIdentity(identity2, RsaKeyParams());
   Name certName2 = m_keyChain.getDefaultCertificateNameForIdentity(identity2);
   shared_ptr<v1::IdentityCertificate> cert2 = m_keyChain.getCertificate(certName2);
 
diff --git a/tests/unit-tests/security/identity-management-fixture.t.cpp b/tests/unit-tests/security/identity-management-fixture.t.cpp
deleted file mode 100644
index 81dcfe5..0000000
--- a/tests/unit-tests/security/identity-management-fixture.t.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#include "identity-management-fixture.hpp"
-
-#include "boost-test.hpp"
-
-namespace ndn {
-namespace tests {
-
-BOOST_AUTO_TEST_SUITE(Security)
-BOOST_FIXTURE_TEST_SUITE(TestIdentityManagementFixture, IdentityManagementFixture)
-
-BOOST_AUTO_TEST_CASE(Tmp)
-{
-  Name identity("/tmp/identity");
-  BOOST_REQUIRE(addIdentity(identity));
-  Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
-  BOOST_REQUIRE_EQUAL(certName.empty(), false);
-  BOOST_REQUIRE_NO_THROW(m_keyChain.getCertificate(certName));
-}
-
-BOOST_AUTO_TEST_SUITE_END() // TestIdentityManagementFixture
-BOOST_AUTO_TEST_SUITE_END() // Security
-
-} // namespace tests
-} // namespace ndn
diff --git a/tests/unit-tests/security/sec-rule-relative.t.cpp b/tests/unit-tests/security/sec-rule-relative.t.cpp
index 21f805e..4209f28 100644
--- a/tests/unit-tests/security/sec-rule-relative.t.cpp
+++ b/tests/unit-tests/security/sec-rule-relative.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2016 Regents of the University of California.
+ * Copyright (c) 2013-2017 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -34,9 +34,9 @@
 BOOST_AUTO_TEST_CASE(Basic)
 {
   Name rsaIdentity("/SecurityTestSecRule/Basic/Rsa");
-  BOOST_REQUIRE(addIdentity(rsaIdentity, RsaKeyParams()));
+  addIdentity(rsaIdentity, RsaKeyParams());
   Name ecdsaIdentity("/SecurityTestSecRule/Basic/Ecdsa");
-  BOOST_REQUIRE(addIdentity(ecdsaIdentity, EcdsaKeyParams()));
+  addIdentity(ecdsaIdentity, EcdsaKeyParams());
 
   Name dataName("SecurityTestSecRule/Basic");
   Data rsaData(dataName);
diff --git a/tests/unit-tests/security/sec-rule-specific.t.cpp b/tests/unit-tests/security/sec-rule-specific.t.cpp
index d8c5d24..761b60f 100644
--- a/tests/unit-tests/security/sec-rule-specific.t.cpp
+++ b/tests/unit-tests/security/sec-rule-specific.t.cpp
@@ -36,9 +36,9 @@
 BOOST_AUTO_TEST_CASE(Basic)
 {
   Name rsaIdentity("/SecurityTestSecRule/Basic/Rsa");
-  BOOST_REQUIRE(addIdentity(rsaIdentity, RsaKeyParams()));
+  addIdentity(rsaIdentity, RsaKeyParams());
   Name ecdsaIdentity("/SecurityTestSecRule/Basic/Ecdsa");
-  BOOST_REQUIRE(addIdentity(ecdsaIdentity, EcdsaKeyParams()));
+  addIdentity(ecdsaIdentity, EcdsaKeyParams());
 
   Name dataName("SecurityTestSecRule/Basic");
   Data rsaData(dataName);
diff --git a/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp b/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
index c54ee4c..7f20981 100644
--- a/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
+++ b/tests/unit-tests/security/signature-sha256-with-ecdsa.t.cpp
@@ -105,7 +105,7 @@
 BOOST_AUTO_TEST_CASE(DataSignature)
 {
   Name identityName("/SecurityTestSignatureSha256WithEcdsa/DataSignature");
-  BOOST_REQUIRE(addIdentity(identityName, EcdsaKeyParams()));
+  addIdentity(identityName, EcdsaKeyParams());
   shared_ptr<security::v1::PublicKey> publicKey;
   BOOST_REQUIRE_NO_THROW(publicKey = m_keyChain.getPublicKeyFromTpm(
     m_keyChain.getDefaultKeyNameForIdentity(identityName)));
@@ -126,7 +126,7 @@
 BOOST_AUTO_TEST_CASE(InterestSignature)
 {
   Name identityName("/SecurityTestSignatureSha256WithEcdsa/InterestSignature");
-  BOOST_REQUIRE(addIdentity(identityName, EcdsaKeyParams()));
+  addIdentity(identityName, EcdsaKeyParams());
   shared_ptr<security::v1::PublicKey> publicKey;
   BOOST_REQUIRE_NO_THROW(publicKey = m_keyChain.getPublicKeyFromTpm(
     m_keyChain.getDefaultKeyNameForIdentity(identityName)));
diff --git a/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp b/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
index 494ea71..4944cbd 100644
--- a/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
+++ b/tests/unit-tests/security/signature-sha256-with-rsa.t.cpp
@@ -110,7 +110,7 @@
 BOOST_AUTO_TEST_CASE(DataSignature)
 {
   Name identityName("/SecurityTestSignatureSha256WithRsa/DataSignature");
-  BOOST_REQUIRE(addIdentity(identityName, RsaKeyParams()));
+  addIdentity(identityName, RsaKeyParams());
   shared_ptr<security::v1::PublicKey> publicKey;
   BOOST_REQUIRE_NO_THROW(publicKey = m_keyChain.getPublicKeyFromTpm(
     m_keyChain.getDefaultKeyNameForIdentity(identityName)));
@@ -131,7 +131,7 @@
 BOOST_AUTO_TEST_CASE(InterestSignature)
 {
   Name identityName("/SecurityTestSignatureSha256WithRsa/InterestSignature");
-  BOOST_REQUIRE(addIdentity(identityName, RsaKeyParams()));
+  addIdentity(identityName, RsaKeyParams());
   shared_ptr<security::v1::PublicKey> publicKey;
   BOOST_REQUIRE_NO_THROW(publicKey = m_keyChain.getPublicKeyFromTpm(
     m_keyChain.getDefaultKeyNameForIdentity(identityName)));
diff --git a/tests/unit-tests/security/v1/key-chain.t.cpp b/tests/unit-tests/security/v1/key-chain.t.cpp
index 6130cae..36dac9c 100644
--- a/tests/unit-tests/security/v1/key-chain.t.cpp
+++ b/tests/unit-tests/security/v1/key-chain.t.cpp
@@ -26,7 +26,7 @@
 #include "boost-test.hpp"
 #include "dummy-keychain.hpp"
 #include "../../test-home-env-saver.hpp"
-#include "key-chain-fixture.hpp"
+#include "test-home-fixture.hpp"
 #include "identity-management-fixture.hpp"
 
 #include <boost/algorithm/string.hpp>
diff --git a/tests/unit-tests/security/v2/key-chain.t.cpp b/tests/unit-tests/security/v2/key-chain.t.cpp
index db14070..8ce962e 100644
--- a/tests/unit-tests/security/v2/key-chain.t.cpp
+++ b/tests/unit-tests/security/v2/key-chain.t.cpp
@@ -24,7 +24,7 @@
 
 #include "boost-test.hpp"
 #include "unit-tests/test-home-env-saver.hpp"
-#include "key-chain-fixture.hpp"
+#include "test-home-fixture.hpp"
 #include "validator.hpp"
 
 namespace ndn {
diff --git a/tests/unit-tests/security/validator-config.t.cpp b/tests/unit-tests/security/validator-config.t.cpp
index 74aab21..022e80b 100644
--- a/tests/unit-tests/security/validator-config.t.cpp
+++ b/tests/unit-tests/security/validator-config.t.cpp
@@ -49,7 +49,7 @@
 {
   Name identity("/TestValidatorConfig/NameFilter");
   identity.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity, "trust-anchor-1.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity), "trust-anchor-1.cert"));
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name dataName1("/simple/equal");
@@ -113,7 +113,7 @@
 {
   Name identity("/TestValidatorConfig/NameFilter2");
   identity.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity, "trust-anchor-2.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity), "trust-anchor-2.cert"));
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name dataName1("/simple/isPrefixOf");
@@ -185,7 +185,7 @@
 {
   Name identity("/TestValidatorConfig/NameFilter3");
   identity.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity, "trust-anchor-3.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity), "trust-anchor-3.cert"));
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name dataName1("/simple/isStrictPrefixOf");
@@ -257,7 +257,7 @@
 {
   Name identity("/TestValidatorConfig/NameFilter4");
   identity.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity, "trust-anchor-4.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity), "trust-anchor-4.cert"));
   Name certName = m_keyChain.getDefaultCertificateNameForIdentity(identity);
 
   Name dataName1("/simple/regex");
@@ -328,7 +328,7 @@
 {
   Name identity("/TestValidatorConfig/KeyLocatorNameChecker1");
   identity.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity, "trust-anchor-5.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity), "trust-anchor-5.cert"));
 
   Name dataName1 = identity;
   dataName1.append("1");
@@ -397,11 +397,11 @@
 
   Name identity1 = identity;
   identity1.append("1").appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity1, "trust-anchor-7.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity1), "trust-anchor-7.cert"));
 
   Name identity2 = identity;
   identity2.append("2").appendVersion();
-  BOOST_REQUIRE_NO_THROW(addIdentity(identity2));
+  addIdentity(identity2);
 
   Name dataName1 = identity;
   dataName1.append("data").appendVersion();
@@ -483,11 +483,11 @@
 {
   Name identity1("/TestValidatorConfig/MultiCheckers/");
   identity1.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity1, "trust-anchor-multi-1.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity1), "trust-anchor-multi-1.cert"));
 
   Name identity2("/TestValidatorConfig/");
   identity2.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity2, "trust-anchor-multi-2.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity2), "trust-anchor-multi-2.cert"));
 
   const std::string CONFIG =
     "rule\n"
@@ -596,7 +596,7 @@
 BOOST_AUTO_TEST_CASE(Reset)
 {
   Name root("/TestValidatorConfig/Reload");
-  BOOST_REQUIRE(saveIdentityCertificate(root, "trust-anchor-8.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(root), "trust-anchor-8.cert"));
 
   Face face(nullptr, m_keyChain);
 
@@ -657,7 +657,7 @@
 {
   Name identity("/TestValidatorConfig/Wildcard");
   identity.appendVersion();
-  BOOST_REQUIRE_NO_THROW(addIdentity(identity));
+  addIdentity(identity);
 
   Name dataName1("/any/data");
   shared_ptr<Data> data1 = make_shared<Data>(dataName1);
@@ -687,7 +687,7 @@
 
   Name identity1 = identity;
   identity1.appendVersion();
-  BOOST_REQUIRE(saveIdentityCertificate(identity1, "trust-anchor-9.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity1), "trust-anchor-9.cert"));
 
   Name interestName("/TestValidatorConfig/SignedInterestTest");
   Name interestName1 = interestName;
@@ -750,15 +750,15 @@
 
   Name identity1 = identity;
   identity1.append("Key1");
-  BOOST_REQUIRE(saveIdentityCertificate(identity1, "trust-anchor-10-1.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity1), "trust-anchor-10-1.cert"));
 
   Name identity2 = identity;
   identity2.append("Key2");
-  BOOST_REQUIRE(saveIdentityCertificate(identity2, "trust-anchor-10-2.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity2), "trust-anchor-10-2.cert"));
 
   Name identity3 = identity;
   identity3.append("Key3");
-  BOOST_REQUIRE(saveIdentityCertificate(identity3, "trust-anchor-10-3.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity3), "trust-anchor-10-3.cert"));
 
 
   Name interestName("/TestValidatorConfig/MaxKeyTest");
@@ -850,19 +850,19 @@
 
   Name identity1 = identity;
   identity1.append("Key1");
-  BOOST_REQUIRE(saveIdentityCertificate(identity1, "trust-anchor-10-1.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity1), "trust-anchor-10-1.cert"));
 
   Name identity2 = identity;
   identity2.append("Key2");
-  BOOST_REQUIRE(saveIdentityCertificate(identity2, "trust-anchor-10-2.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity2), "trust-anchor-10-2.cert"));
 
   Name identity3 = identity;
   identity3.append("Key3");
-  BOOST_REQUIRE(saveIdentityCertificate(identity3, "trust-anchor-10-3.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity3), "trust-anchor-10-3.cert"));
 
   Name identity4 = identity;
   identity4.append("Key4");
-  BOOST_REQUIRE(saveIdentityCertificate(identity4, "trust-anchor-10-4.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(identity4), "trust-anchor-10-4.cert"));
 
 
   Name interestName("/TestValidatorConfig/MaxKeyTest");
@@ -983,12 +983,12 @@
 BOOST_AUTO_TEST_CASE(FixedSignerChecker2)
 {
   Name rsaIdentity("/TestValidatorConfig/FixedSignerChecker2/Rsa");
-  BOOST_REQUIRE(addIdentity(rsaIdentity));
-  Name rsaCertName = m_keyChain.getDefaultCertificateNameForIdentity(rsaIdentity);
+  addIdentity(rsaIdentity);
+  // Name rsaCertName = m_keyChain.getDefaultCertificateNameForIdentity(rsaIdentity);
 
   Name ecdsaIdentity("/TestValidatorConfig/FixedSignerChecker2/Ecdsa");
-  BOOST_REQUIRE(addIdentity(ecdsaIdentity, EcdsaKeyParams()));
-  BOOST_REQUIRE(saveIdentityCertificate(ecdsaIdentity, "trust-anchor-11.cert"));
+  auto identity = addIdentity(ecdsaIdentity, EcdsaKeyParams());
+  BOOST_REQUIRE(saveIdentityCertificate(identity, "trust-anchor-11.cert"));
 
   Name dataName("/TestValidatorConfig/FixedSignerChecker2");
   shared_ptr<Data> dataRsa = make_shared<Data>(dataName);
@@ -1127,11 +1127,11 @@
   std::vector<v1::CertificateSubjectDescription> subjectDescription;
 
   Name root("/TestValidatorConfig");
-  BOOST_REQUIRE(saveIdentityCertificate(root, "trust-anchor-6.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(root), "trust-anchor-6.cert"));
 
 
   Name sld("/TestValidatorConfig/HierarchicalChecker");
-  BOOST_REQUIRE(addIdentity(sld));
+  addIdentity(sld);
   advanceClocks(time::milliseconds(100));
   Name sldKeyName = m_keyChain.generateRsaKeyPairAsDefault(sld, true);
   shared_ptr<v1::IdentityCertificate> sldCert =
@@ -1144,7 +1144,7 @@
   m_keyChain.addCertificateAsIdentityDefault(*sldCert);
 
   Name nld("/TestValidatorConfig/HierarchicalChecker/NextLevel");
-  BOOST_REQUIRE(addIdentity(nld));
+  addIdentity(nld);
   advanceClocks(time::milliseconds(100));
   Name nldKeyName = m_keyChain.generateRsaKeyPairAsDefault(nld, true);
   shared_ptr<v1::IdentityCertificate> nldCert =
@@ -1224,10 +1224,10 @@
   std::vector<v1::CertificateSubjectDescription> subjectDescription;
 
   Name root("/TestValidatorConfig");
-  BOOST_REQUIRE(saveIdentityCertificate(root, "trust-anchor-8.cert", true));
+  BOOST_REQUIRE(saveIdentityCertificate(addIdentity(root), "trust-anchor-8.cert"));
 
   Name sld("/TestValidatorConfig/Nrd-1");
-  BOOST_REQUIRE(addIdentity(sld));
+  addIdentity(sld);
   advanceClocks(time::milliseconds(100));
   Name sldKeyName = m_keyChain.generateRsaKeyPairAsDefault(sld, true);
   shared_ptr<v1::IdentityCertificate> sldCert =
@@ -1240,7 +1240,7 @@
   m_keyChain.addCertificateAsIdentityDefault(*sldCert);
 
   Name nld("/TestValidatorConfig/Nrd-1/Nrd-2");
-  BOOST_REQUIRE(addIdentity(nld));
+  addIdentity(nld);
   advanceClocks(time::milliseconds(100));
   Name nldKeyName = m_keyChain.generateRsaKeyPairAsDefault(nld, true);
   shared_ptr<v1::IdentityCertificate> nldCert =
@@ -1386,13 +1386,13 @@
                       std::string("trust-anchor-2.cert"));
 
     firstIdentity = Name("/TestValidatorConfig/Dir/First");
-    BOOST_REQUIRE(addIdentity(firstIdentity));
+    addIdentity(firstIdentity);
     Name firstCertName = m_keyChain.getDefaultCertificateNameForIdentity(firstIdentity);
     firstCert = m_keyChain.getCertificate(firstCertName);
     io::save(*firstCert, firstCertPath.string());
 
     secondIdentity = Name("/TestValidatorConfig/Dir/Second");
-    BOOST_REQUIRE(addIdentity(secondIdentity));
+    addIdentity(secondIdentity);
     Name secondCertName = m_keyChain.getDefaultCertificateNameForIdentity(secondIdentity);
     secondCert = m_keyChain.getCertificate(secondCertName);
   }
@@ -1494,9 +1494,9 @@
     : clientFace(io, m_keyChain, {true, true})
     , validationResult(boost::logic::indeterminate)
   {
-    BOOST_REQUIRE(addIdentity(ca));
-    BOOST_REQUIRE(saveIdentityCertificate(ca, "trust-anchor-1.cert", true));
-    BOOST_REQUIRE(addSubCertificate(user, ca));
+    auto certName = addIdentity(ca);
+    saveIdentityCertificate(certName, "trust-anchor-1.cert");
+    addSubCertificate(user, ca);
 
     userCertName = m_keyChain.getDefaultCertificateNameForIdentity(user);
     userCert = m_keyChain.getCertificate(userCertName);
diff --git a/tests/unit-tests/security/validator.t.cpp b/tests/unit-tests/security/validator.t.cpp
index 90bd1b9..0b7cda2 100644
--- a/tests/unit-tests/security/validator.t.cpp
+++ b/tests/unit-tests/security/validator.t.cpp
@@ -50,7 +50,7 @@
 {
   Name identity("/TestValidator/Null");
   identity.appendVersion();
-  BOOST_REQUIRE(addIdentity(identity, RsaKeyParams()));
+  addIdentity(identity, RsaKeyParams());
 
   Name dataName = identity;
   dataName.append("1");
@@ -94,12 +94,12 @@
 BOOST_AUTO_TEST_CASE(RsaSignatureVerification)
 {
   Name identity("/TestValidator/RsaSignatureVerification");
-  BOOST_REQUIRE(addIdentity(identity, RsaKeyParams()));
+  addIdentity(identity, RsaKeyParams());
   Name keyName = m_keyChain.getDefaultKeyNameForIdentity(identity);
   shared_ptr<v1::PublicKey> publicKey = m_keyChain.getPublicKey(keyName);
 
   Name identity2("/TestValidator/RsaSignatureVerification/id2");
-  BOOST_REQUIRE(addIdentity(identity2, RsaKeyParams()));
+  addIdentity(identity2, RsaKeyParams());
   Name keyName2 = m_keyChain.getDefaultKeyNameForIdentity(identity2);
   shared_ptr<v1::PublicKey> publicKey2 = m_keyChain.getPublicKey(keyName2);
 
@@ -157,12 +157,12 @@
 BOOST_AUTO_TEST_CASE(EcdsaSignatureVerification)
 {
   Name identity("/TestValidator/EcdsaSignatureVerification");
-  BOOST_REQUIRE(addIdentity(identity, EcdsaKeyParams()));
+  addIdentity(identity, EcdsaKeyParams());
   Name keyName = m_keyChain.getDefaultKeyNameForIdentity(identity);
   shared_ptr<v1::PublicKey> publicKey = m_keyChain.getPublicKey(keyName);
 
   Name identity2("/TestValidator/EcdsaSignatureVerification/id2");
-  BOOST_REQUIRE(addIdentity(identity2, EcdsaKeyParams()));
+  addIdentity(identity2, EcdsaKeyParams());
   Name keyName2 = m_keyChain.getDefaultKeyNameForIdentity(identity2);
   shared_ptr<v1::PublicKey> publicKey2 = m_keyChain.getPublicKey(keyName2);
 
@@ -192,12 +192,12 @@
 BOOST_AUTO_TEST_CASE(EcdsaSignatureVerification2)
 {
   Name ecdsaIdentity("/SecurityTestValidator/EcdsaSignatureVerification2/ecdsa");
-  BOOST_REQUIRE(addIdentity(ecdsaIdentity, EcdsaKeyParams()));
+  addIdentity(ecdsaIdentity, EcdsaKeyParams());
   Name ecdsaCertName = m_keyChain.getDefaultCertificateNameForIdentity(ecdsaIdentity);
   shared_ptr<v1::IdentityCertificate> ecdsaCert = m_keyChain.getCertificate(ecdsaCertName);
 
   Name rsaIdentity("/SecurityTestValidator/EcdsaSignatureVerification2/rsa");
-  BOOST_REQUIRE(addIdentity(rsaIdentity, RsaKeyParams()));
+  addIdentity(rsaIdentity, RsaKeyParams());
   Name rsaCertName = m_keyChain.getDefaultCertificateNameForIdentity(rsaIdentity);
   shared_ptr<v1::IdentityCertificate> rsaCert = m_keyChain.getCertificate(rsaCertName);