switch to ndn-cxx KeyChain v2
refs #4089
Change-Id: I32bc19db156de49275b681ef67f684b76631d50b
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index dbc5ec4..a2977f8 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-fixture.cpp
@@ -24,8 +24,10 @@
*/
#include "identity-management-fixture.hpp"
-#include <ndn-cxx/security/v1/identity-certificate.hpp>
-#include <ndn-cxx/security/v1/sec-public-info.hpp>
+#include <ndn-cxx/security/pib/identity.hpp>
+#include <ndn-cxx/security/pib/key.hpp>
+#include <ndn-cxx/security/pib/pib.hpp>
+#include <ndn-cxx/security/v2/certificate.hpp>
#include <ndn-cxx/util/io.hpp>
#include <boost/filesystem.hpp>
@@ -33,17 +35,13 @@
namespace tests {
IdentityManagementFixture::IdentityManagementFixture()
- : m_keyChain("sqlite3", "file")
+ : m_keyChain("pib-memory:", "tpm-memory:")
{
- m_keyChain.getDefaultCertificate(); // side effect: create a default cert if it doesn't exist
+ m_keyChain.createIdentity("/DEFAULT");
}
IdentityManagementFixture::~IdentityManagementFixture()
{
- for (const auto& id : m_identities) {
- m_keyChain.deleteIdentity(id);
- }
-
boost::system::error_code ec;
for (const auto& certFile : m_certFiles) {
boost::filesystem::remove(certFile, ec); // ignore error
@@ -55,7 +53,6 @@
{
try {
m_keyChain.createIdentity(identity, params);
- m_identities.push_back(identity);
return true;
}
catch (const std::runtime_error&) {
@@ -66,11 +63,11 @@
bool
IdentityManagementFixture::saveIdentityCertificate(const Name& identity, const std::string& filename, bool wantAdd)
{
- shared_ptr<ndn::security::v1::IdentityCertificate> cert;
+ ndn::security::v2::Certificate cert;
try {
- cert = m_keyChain.getCertificate(m_keyChain.getDefaultCertificateNameForIdentity(identity));
+ cert = m_keyChain.getPib().getIdentity(identity).getDefaultKey().getDefaultCertificate();
}
- catch (const ndn::security::v1::SecPublicInfo::Error&) {
+ catch (const ndn::security::Pib::Error&) {
if (wantAdd && this->addIdentity(identity)) {
return this->saveIdentityCertificate(identity, filename, false);
}
@@ -79,7 +76,7 @@
m_certFiles.push_back(filename);
try {
- ndn::io::save(*cert, filename);
+ ndn::io::save(cert, filename);
return true;
}
catch (const ndn::io::Error&) {