security: consolidate creation of identities/keys in the respective containers

Change-Id: I754e5711fd95b97834dd2e9c0ab1830eaff4be35
diff --git a/tests/unit/security/pib/impl/identity-impl.t.cpp b/tests/unit/security/pib/impl/identity-impl.t.cpp
index 390cee4..b7701aa 100644
--- a/tests/unit/security/pib/impl/identity-impl.t.cpp
+++ b/tests/unit/security/pib/impl/identity-impl.t.cpp
@@ -20,8 +20,6 @@
  */
 
 #include "ndn-cxx/security/pib/impl/identity-impl.hpp"
-#include "ndn-cxx/security/pib/impl/pib-memory.hpp"
-#include "ndn-cxx/security/pib/pib.hpp"
 
 #include "tests/boost-test.hpp"
 #include "tests/unit/security/pib/pib-data-fixture.hpp"
@@ -34,23 +32,26 @@
 
 BOOST_AUTO_TEST_SUITE(Security)
 BOOST_AUTO_TEST_SUITE(Pib)
-BOOST_FIXTURE_TEST_SUITE(TestIdentityImpl, ndn::security::tests::PibDataFixture)
 
 using pib::Pib;
 
-BOOST_AUTO_TEST_CASE(Basic)
+class IdentityImplFixture : public pib::tests::PibDataFixture
 {
-  IdentityImpl identity1(id1, std::make_shared<pib::PibMemory>(), true);
+protected:
+  const shared_ptr<PibImpl> pibImpl = makePibWithIdentity(id1);
+  IdentityImpl identity1{id1, pibImpl};
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestIdentityImpl, IdentityImplFixture)
+
+BOOST_AUTO_TEST_CASE(Properties)
+{
   BOOST_CHECK_EQUAL(identity1.getName(), id1);
 }
 
 BOOST_AUTO_TEST_CASE(KeyOperations)
 {
-  auto pibImpl = std::make_shared<pib::PibMemory>();
-  IdentityImpl identity1(id1, pibImpl, true);
-  BOOST_CHECK_NO_THROW(IdentityImpl(id1, pibImpl, false));
-
-  // identity does not have any key
+  // identity does not have any keys
   BOOST_CHECK_EQUAL(identity1.getKeys().size(), 0);
 
   // get non-existing key, throw Pib::Error
@@ -114,26 +115,19 @@
   BOOST_CHECK_THROW(identity1.getDefaultKey(), Pib::Error);
 }
 
-BOOST_AUTO_TEST_CASE(Overwrite)
+BOOST_AUTO_TEST_CASE(ReplaceKey)
 {
-  IdentityImpl identity1(id1, std::make_shared<pib::PibMemory>(), true);
-
   identity1.addKey(id1Key1, id1Key1Name);
   auto k1 = identity1.getKey(id1Key1Name);
   BOOST_TEST(k1.getPublicKey() == id1Key1, boost::test_tools::per_element());
 
-  identity1.addKey(id1Key2, id1Key1Name); // overwriting key should work
+  identity1.addKey(id1Key2, id1Key1Name); // overwrite key
   auto k2 = identity1.getKey(id1Key1Name);
   BOOST_TEST(k2.getPublicKey() == id1Key2, boost::test_tools::per_element());
 }
 
 BOOST_AUTO_TEST_CASE(Errors)
 {
-  auto pibImpl = std::make_shared<pib::PibMemory>();
-
-  BOOST_CHECK_THROW(IdentityImpl(id1, pibImpl, false), Pib::Error);
-  IdentityImpl identity1(id1, pibImpl, true);
-
   identity1.addKey(id1Key1, id1Key1Name);
   BOOST_CHECK_THROW(identity1.addKey(id2Key1, id2Key1Name), std::invalid_argument);
   BOOST_CHECK_THROW(identity1.removeKey(id2Key1Name), std::invalid_argument);