tests: Simplify to create IdentityManager with make_shared<MemoryIdentityStorage>().
diff --git a/tests/test-encode-decode-data.cpp b/tests/test-encode-decode-data.cpp
index 7521221..70cf81c 100644
--- a/tests/test-encode-decode-data.cpp
+++ b/tests/test-encode-decode-data.cpp
@@ -237,24 +237,20 @@
freshData->setContent(freshContent, sizeof(freshContent) - 1);
freshData->getMetaInfo().setTimestampMilliseconds(time(NULL) * 1000.0);
- shared_ptr<MemoryIdentityStorage> identityStorage(new MemoryIdentityStorage());
shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(shared_ptr<IdentityManager>(new IdentityManager(identityStorage, privateKeyStorage)));
+ KeyChain keyChain(shared_ptr<IdentityManager>
+ (new IdentityManager(make_shared<MemoryIdentityStorage>(), privateKeyStorage)));
// Initialize the storage.
- Name identityName("/testname");
- Name keyName = Name(identityName).append(Name("DSK-123"));
+ Name keyName("/testname/DSK-123");
Name certificateName = Name(keyName).append(Name("ID-CERT/0"));
- identityStorage->addIdentity(identityName);
- identityStorage->setDefaultIdentity(identityName);
privateKeyStorage->setKeyPairForKeyName
(keyName, DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER), DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));
keyChain.signData(*freshData, certificateName);
cout << endl << "Freshly-signed Data:" << endl;
dumpData(*freshData);
- Blob freshEncoding = freshData->wireEncode();
-
+
keyChain.verifyData(freshData, bind(&onVerified, "Freshly-signed Data", _1), bind(&onVerifyFailed, "Freshly-signed Data"));
} catch (std::exception& e) {
cout << "exception: " << e.what() << endl;
diff --git a/tests/test-publish-async.cpp b/tests/test-publish-async.cpp
index 749c7c1..467780e 100644
--- a/tests/test-publish-async.cpp
+++ b/tests/test-publish-async.cpp
@@ -105,16 +105,15 @@
{
try {
Face face("localhost");
-
- shared_ptr<MemoryIdentityStorage> identityStorage(new MemoryIdentityStorage());
+
shared_ptr<MemoryPrivateKeyStorage> privateKeyStorage(new MemoryPrivateKeyStorage());
- KeyChain keyChain(shared_ptr<IdentityManager>(new IdentityManager(identityStorage, privateKeyStorage)));
+ KeyChain keyChain(shared_ptr<IdentityManager>
+ (new IdentityManager(make_shared<MemoryIdentityStorage>(), privateKeyStorage)));
keyChain.setFace(&face);
// Initialize the storage.
Name keyName("/testname/DSK-123");
- Name certificateName = keyName;
- certificateName.append(Name("ID-CERT/0"));
+ Name certificateName = Name(keyName).append(Name("ID-CERT/0"));
privateKeyStorage->setKeyPairForKeyName
(keyName, DEFAULT_PUBLIC_KEY_DER, sizeof(DEFAULT_PUBLIC_KEY_DER), DEFAULT_PRIVATE_KEY_DER, sizeof(DEFAULT_PRIVATE_KEY_DER));