security: Correct behavior of PibImpl::setDefaultIdentity

The high level logic of Pib class ensures that an identity exists (i.e.,
creates when missing).  With this correction, specific realizations
of the low-level logic (PibSqlite and PibMemory) simply throw an error
if the caller attempts to set a non-existing identity as default.

Change-Id: I9d07ca8db4817b7938c04b05341444f1150948f8
Refs: #4136
diff --git a/tests/unit/security/pib/pib-impl.t.cpp b/tests/unit/security/pib/pib-impl.t.cpp
index 24d2b86..e16f658 100644
--- a/tests/unit/security/pib/pib-impl.t.cpp
+++ b/tests/unit/security/pib/pib-impl.t.cpp
@@ -129,6 +129,9 @@
   this->pib.addIdentity(this->id2);
   BOOST_CHECK_EQUAL(this->pib.getDefaultIdentity(), this->id2);
 
+  // try to set non-existing identity as a default
+  BOOST_CHECK_THROW(this->pib.setDefaultIdentity("/non-existing-identity"), Pib::Error);
+
   // get all identities, should contain id1 and id2
   std::set<Name> idNames = this->pib.getIdentities();
   BOOST_CHECK_EQUAL(idNames.size(), 2);