Bug #4136
closedPibSqlite3::setDefaultIdentity does not create the identity if it doesn't exist
100%
Description
The documentation for setDefaultIdentity says "If identityName identity does not exist, it will be created":
https://github.com/named-data/ndn-cxx/blob/cbe72b07ace4020355f5d1df700ee671440998c9/src/security/pib/pib-impl.hpp#L124
But PibSqlite3::setDefaultIdentity does not do this:
https://github.com/named-data/ndn-cxx/blob/fe4733a1608712e389fe10b329a9fd61575ad075/src/security/pib/pib-sqlite3.cpp#L330
Suggestion: At the beginning of setDefaultIdentity, add the following lines from PibSqlite3::addIdentity:
https://github.com/named-data/ndn-cxx/blob/fe4733a1608712e389fe10b329a9fd61575ad075/src/security/pib/pib-sqlite3.cpp#L289
if (!hasIdentity(identity)) {
Sqlite3Statement statement(m_database, "INSERT INTO identities (identity) values (?)");
statement.bind(1, identity.wireEncode(), SQLITE_TRANSIENT);
statement.step();
}
Updated by Alex Afanasyev over 4 years ago
- Status changed from New to In Progress
- Assignee set to Alex Afanasyev
- Start date deleted (
06/15/2017)
Updated by Alex Afanasyev over 4 years ago
- Status changed from In Progress to Code review
- % Done changed from 0 to 100
Implementation behavior is actually doesn't matter. I pushed the patch that makes Pib implementations to throw an error, but I could switch to a simple assert: the creation of identities when they don't exist is handled by Pib abstraction, not individual realizations.
Updated by Davide Pesavento over 4 years ago
- Status changed from Code review to Closed