build: reanimate the dead
Fix build with ndn-cxx 0.7.1 and ChronoSync 0.5.3
* Adapt to new API
* Upgrade to Qt5
* Several other bugs
Refs: #4563, #4087
Change-Id: Ic55d687caade08f557f9b9ec3e9569bc96798710
diff --git a/test/cert/endorse.cert b/test/cert/endorse.cert
new file mode 100644
index 0000000..0f5396a
--- /dev/null
+++ b/test/cert/endorse.cert
@@ -0,0 +1,15 @@
+Bv0CpQc5CBdFbmRvcnNlQ2VydGlmaWNhdGVUZXN0cwgDS0VZCAg2x+MG7IxCPQgE
+c2VsZggJ/QAAAXXVNWGzFAkYAQIZBAA27oAV/QEmMIIBIjANBgkqhkiG9w0BAQEF
+AAOCAQ8AMIIBCgKCAQEAv3BM/bpWTmcKTeOzykiFm/GWYnhJgTQxQlRp4mQHsEmH
+SFmrCtx2g0mwoPUPwjBhXuH0J4PSIuudb8VLiPGD03/gFUeGtY9VRrH5dZuIOpHT
+tklBz8rA3DsCf0rMggU6IrYd6Vjlk+hseoAlKvVVgmGT+NXdmtO+Xhxt16S2jPUs
++ZxKc+gBGKEHKKZkEDlRWzWrj+hBKasOic3v7Lc22M4tvjANxyMApZ/rXKdIi1rN
+Da0u4dk6lL/qW5fIEQEjsf4dngZkHaHkpK6wEnXyTQIX71/cmMB42xggfZ7YAvfO
+smuc0mg3fuuwTMo5fKxHCES14i6y7TMhqlxkgdb66QIDAQABFv0BDxsBAP0BAqP9
+AgBc/QIBCDIuNS40LjQx/QICTC9FbmRvcnNlQ2VydGlmaWNhdGVUZXN0cy9LRVkv
+NiVDNyVFMyUwNiVFQyU4Q0IlM0Qvc2VsZi8lRkQlMDAlMDAlMDF1JUQ1NWElQjP9
+AgA//QIBBnNpZ25lcv0CAjEvRW5kb3JzZUNlcnRpZmljYXRlVGVzdHMvS0VZLzYl
+QzclRTMlMDYlRUMlOENCJTNEiCaJJIoISURFTlRJVFmLGC9FbmRvcnNlQ2VydGlm
+aWNhdGVUZXN0c4wRiwVlbWFpbIsIaG9tZXBhZ2X9AP0m/QD+DzE5NzAwMTAxVDAw
+MDAwMP0A/w8yMDQwMTExMlQwNzU3MjYXIOzz9eftz8S3vFHaq8yVJalZzs7SPtvo
+7Xu8QhXQq17e
\ No newline at end of file
diff --git a/test/cert/testid.cert b/test/cert/testid.cert
new file mode 100644
index 0000000..849ab19
--- /dev/null
+++ b/test/cert/testid.cert
@@ -0,0 +1,16 @@
+Bv0Czwc5CBdFbmRvcnNlQ2VydGlmaWNhdGVUZXN0cwgDS0VZCAg2x+MG7IxCPQgE
+c2VsZggJ/QAAAXXVNWGzFAkYAQIZBAA27oAV/QEmMIIBIjANBgkqhkiG9w0BAQEF
+AAOCAQ8AMIIBCgKCAQEAv3BM/bpWTmcKTeOzykiFm/GWYnhJgTQxQlRp4mQHsEmH
+SFmrCtx2g0mwoPUPwjBhXuH0J4PSIuudb8VLiPGD03/gFUeGtY9VRrH5dZuIOpHT
+tklBz8rA3DsCf0rMggU6IrYd6Vjlk+hseoAlKvVVgmGT+NXdmtO+Xhxt16S2jPUs
++ZxKc+gBGKEHKKZkEDlRWzWrj+hBKasOic3v7Lc22M4tvjANxyMApZ/rXKdIi1rN
+Da0u4dk6lL/qW5fIEQEjsf4dngZkHaHkpK6wEnXyTQIX71/cmMB42xggfZ7YAvfO
+smuc0mg3fuuwTMo5fKxHCES14i6y7TMhqlxkgdb66QIDAQABFlkbAQEcKgcoCBdF
+bmRvcnNlQ2VydGlmaWNhdGVUZXN0cwgDS0VZCAg2x+MG7IxCPf0A/Sb9AP4PMTk3
+MDAxMDFUMDAwMDAw/QD/DzIwNDAxMTEyVDA3NTcyNhf9AQA0C8yYGgrruSJe1n5q
+oTSdmomnRdZgdczblgL5jY9dP9OAUJL6vy5bHwnjFU484T6vKANETL/BZfnkI/h9
+39gMjXiqaQ4zStuSNBVO/41IyOzDbg2KyQk41mB1M1r7pvzIziNM//ammYBzaQN/
+ixlKPrReUIypEswYnCXaw4VZPLkReR8yjVqLW2B6X8a1zfDWMOyv39Gayhpfcvbo
+2juJZ75JTk6KL8lEO8KO84M2ym/VABDZUHbXnMPYmqU4aMRRLfytzeZlLOdRzLpb
+FrE4AHwudakhruPB39NluYu2IHhyIB0x1u4xxyzGfgoIRIPXnW4zoulFn9RFgg9A
+6lNM
\ No newline at end of file
diff --git a/test/cert/testid.key b/test/cert/testid.key
new file mode 100644
index 0000000..0be9558
--- /dev/null
+++ b/test/cert/testid.key
@@ -0,0 +1,7 @@
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv3BM/bpWTmcKTeOzykiF
+m/GWYnhJgTQxQlRp4mQHsEmHSFmrCtx2g0mwoPUPwjBhXuH0J4PSIuudb8VLiPGD
+03/gFUeGtY9VRrH5dZuIOpHTtklBz8rA3DsCf0rMggU6IrYd6Vjlk+hseoAlKvVV
+gmGT+NXdmtO+Xhxt16S2jPUs+ZxKc+gBGKEHKKZkEDlRWzWrj+hBKasOic3v7Lc2
+2M4tvjANxyMApZ/rXKdIi1rNDa0u4dk6lL/qW5fIEQEjsf4dngZkHaHkpK6wEnXy
+TQIX71/cmMB42xggfZ7YAvfOsmuc0mg3fuuwTMo5fKxHCES14i6y7TMhqlxkgdb6
+6QIDAQAB
\ No newline at end of file
diff --git a/test/endorse-certificate.t.cpp b/test/endorse-certificate.t.cpp
index 5fa5c79..baa2ecf 100644
--- a/test/endorse-certificate.t.cpp
+++ b/test/endorse-certificate.t.cpp
@@ -30,122 +30,37 @@
using std::string;
using ndn::KeyChain;
-using ndn::IdentityCertificate;
+using ndn::security::Certificate;
BOOST_AUTO_TEST_SUITE(TestEndorseCertificate)
-const string testIdCert("\
-Bv0DXwdRCBdFbmRvcnNlQ2VydGlmaWNhdGVUZXN0cwgDS0VZCAxFbmNvZGVEZWNv\
-ZGUIEWtzay0xMzk0MDcyMTQ3MzM1CAdJRC1DRVJUCAf9AUSVLNXoFAMYAQIV/QG8\
-MIIBuDAiGA8yMDE0MDMwNjAyMTU0N1oYDzIwMTQwMzEzMDkyNzQ3WjBu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b2RliRaKCGhvbWVwYWdliwpNeUhvbWVQYWdliQ6KBG5hbWWLBk15TmFt\
-ZTAtBgcrBgEFIAICAQH/BB+MHYsLaW5zdGl0dXRpb26LBWdyb3VwiwdhZHZpc29y\
-FgMbAQAXIHalD2NUzM7abX6QY+2qWNLVMC+ch2xnVyrlf89ZH/IV");
+std::string
+getTestFile(std::string path) {
+ std::ifstream t(path);
+ std::stringstream buffer;
+ buffer << t.rdbuf();
+ return buffer.str();
+}
BOOST_AUTO_TEST_CASE(IdCert)
{
+ const std::string testIdCert = getTestFile("test/cert/testid.cert");
boost::iostreams::stream<boost::iostreams::array_source> is(testIdCert.c_str(),
testIdCert.size());
- shared_ptr<IdentityCertificate> idCert = ndn::io::load<IdentityCertificate>(is);
+ std::shared_ptr<Certificate> idCert = ndn::io::load<Certificate>(is);
BOOST_CHECK(static_cast<bool>(idCert));
- const ndn::Certificate::SubjectDescriptionList& subjectDescription =
- idCert->getSubjectDescriptionList();
- BOOST_CHECK_EQUAL(subjectDescription.size(), 6);
-
- ndn::Certificate::SubjectDescriptionList::const_iterator it = subjectDescription.begin();
- ndn::Certificate::SubjectDescriptionList::const_iterator end = subjectDescription.end();
- int count = 0;
- for(; it != end; it++)
- {
- if(it->getOidString() == "2.5.4.41")
- {
- BOOST_CHECK_EQUAL(it->getValue(), "MyName");
- count++;
- }
- if(it->getOidString() == "2.5.4.11")
- {
- BOOST_CHECK_EQUAL(it->getValue(), "MyInstitute");
- count++;
- }
- if(it->getOidString() == "2.5.4.1")
- {
- BOOST_CHECK_EQUAL(it->getValue(), "MyGroup");
- count++;
- }
- if(it->getOidString() == "2.5.4.3")
- {
- BOOST_CHECK_EQUAL(it->getValue(), "MyHomePage");
- count++;
- }
- if(it->getOidString() == "2.5.4.80")
- {
- BOOST_CHECK_EQUAL(it->getValue(), "MyAdvisor");
- count++;
- }
- if(it->getOidString() == "1.2.840.113549.1.9.1")
- {
- BOOST_CHECK_EQUAL(it->getValue(), "MyEmail");
- count++;
- }
- }
- BOOST_CHECK_EQUAL(count, 6);
-
BOOST_CHECK_EQUAL(idCert->getName().toUri(),
- "/EndorseCertificateTests/KEY/EncodeDecode/ksk-1394072147335/ID-CERT/%FD%01D%95%2C%D5%E8");
-
- ndn::OBufferStream keyOs;
- {
- using namespace CryptoPP;
- StringSource(testKey, true, new Base64Decoder(new FileSink(keyOs)));
- }
- ndn::PublicKey key(keyOs.buf()->buf(), keyOs.buf()->size());
- BOOST_CHECK(key == idCert->getPublicKeyInfo());
+ "/EndorseCertificateTests/KEY/6%C7%E3%06%EC%8CB%3D/self/%FD%00%00%01u%D55a%B3");
}
BOOST_AUTO_TEST_CASE(ConstructFromIdCert)
{
+ const std::string testIdCert = getTestFile("test/cert/testid.cert");
boost::iostreams::stream<boost::iostreams::array_source> is(testIdCert.c_str(),
testIdCert.size());
- shared_ptr<IdentityCertificate> idCert = ndn::io::load<IdentityCertificate>(is);
+ std::shared_ptr<Certificate> idCert = ndn::io::load<Certificate>(is);
Profile profile(*idCert);
vector<string> endorseList;
@@ -153,32 +68,37 @@
endorseList.push_back("homepage");
EndorseCertificate endorseCertificate(*idCert, profile, endorseList);
- boost::filesystem::path keyChainTmpPath =
- boost::filesystem::path(TEST_CERT_PATH) / "TestEndorseCertificate";
- KeyChain keyChain(std::string("sqlite3:").append(keyChainTmpPath.string()),
- std::string("tpm-file:").append(keyChainTmpPath.string()));
+ KeyChain keyChain("pib-memory:", "tpm-memory:");
- keyChain.signWithSha256(endorseCertificate);
+ auto signOpts = ndn::security::SigningInfo(ndn::security::SigningInfo::SignerType::SIGNER_TYPE_SHA256);
+ keyChain.sign(endorseCertificate, signOpts.setSignatureInfo(endorseCertificate.getSignatureInfo()));
const Block& endorseDataBlock = endorseCertificate.wireEncode();
Data decodedEndorseData;
decodedEndorseData.wireDecode(endorseDataBlock);
EndorseCertificate decodedEndorse(decodedEndorseData);
BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("IDENTITY"),
- "/EndorseCertificateTests/EncodeDecode");
- BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("name"), "MyName");
- BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("homepage"), "MyHomePage");
+ "/EndorseCertificateTests");
BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().size(), 2);
BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().at(0), "email");
BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().at(1), "homepage");
BOOST_CHECK_EQUAL(decodedEndorse.getSigner(),
- "/EndorseCertificateTests/EncodeDecode/ksk-1394072147335");
- BOOST_CHECK_EQUAL(decodedEndorse.getPublicKeyName(),
- "/EndorseCertificateTests/EncodeDecode/ksk-1394072147335");
+ "/EndorseCertificateTests/KEY/6%C7%E3%06%EC%8CB%3D");
+ BOOST_CHECK_EQUAL(decodedEndorse.getKeyName(),
+ "/EndorseCertificateTests/PROFILE-CERT/KEY/6%C7%E3%06%EC%8CB%3D");
+
+ const std::string testIdKey = getTestFile("test/cert/testid.key");
+ ndn::OBufferStream keyOs;
+ {
+ using namespace CryptoPP;
+ StringSource(testIdKey, true, new Base64Decoder(new FileSink(keyOs)));
+ }
+ BOOST_CHECK(idCert->getPublicKey() == *keyOs.buf());
}
BOOST_AUTO_TEST_CASE(ConstructFromEndorseCert)
{
+ const std::string testEndorseCert = getTestFile("test/cert/endorse.cert");
boost::iostreams::stream<boost::iostreams::array_source> is(testEndorseCert.c_str(),
testEndorseCert.size());
shared_ptr<Data> rawData = ndn::io::load<Data>(is);
@@ -191,12 +111,10 @@
Name signer("/EndorseCertificateTests/Singer/ksk-1234567890");
EndorseCertificate endorseCertificate(rawEndorse, signer, endorseList);
- boost::filesystem::path keyChainTmpPath =
- boost::filesystem::path(TEST_CERT_PATH) / "TestEndorseCertificate";
- KeyChain keyChain(std::string("sqlite3:").append(keyChainTmpPath.string()),
- std::string("tpm-file:").append(keyChainTmpPath.string()));
+ KeyChain keyChain("pib-memory:", "tpm-memory:");
- keyChain.signWithSha256(endorseCertificate);
+ auto signOpts = ndn::security::SigningInfo(ndn::security::SigningInfo::SignerType::SIGNER_TYPE_SHA256);
+ keyChain.sign(endorseCertificate, signOpts.setSignatureInfo(endorseCertificate.getSignatureInfo()));
const Block& endorseDataBlock = endorseCertificate.wireEncode();
@@ -204,17 +122,15 @@
decodedEndorseData.wireDecode(endorseDataBlock);
EndorseCertificate decodedEndorse(decodedEndorseData);
BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("IDENTITY"),
- "/EndorseCertificateTests/EncodeDecode");
- BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("name"), "MyName");
- BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("homepage"), "MyHomePage");
+ "/EndorseCertificateTests");
BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().size(), 3);
BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().at(0), "institution");
BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().at(1), "group");
BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().at(2), "advisor");
BOOST_CHECK_EQUAL(decodedEndorse.getSigner(),
"/EndorseCertificateTests/Singer/ksk-1234567890");
- BOOST_CHECK_EQUAL(decodedEndorse.getPublicKeyName(),
- "/EndorseCertificateTests/EncodeDecode/ksk-1394072147335");
+ BOOST_CHECK_EQUAL(decodedEndorse.getKeyName(),
+ "/EndorseCertificateTests/KEY/6%C7%E3%06%EC%8CB%3D");
}
BOOST_AUTO_TEST_SUITE_END()