build: Warnings correction for gcc 4.2
Also in this commit some code style corrections.
Change-Id: Idf2b5b96b328fb3dbea7440362c84d7759a10ec5
Refs: #1429
diff --git a/tests/security/identity-fixture.cpp b/tests/security/identity-fixture.cpp
index 899f5de..a39ecbe 100644
--- a/tests/security/identity-fixture.cpp
+++ b/tests/security/identity-fixture.cpp
@@ -6,16 +6,7 @@
#include "security/key-chain.hpp"
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
-#endif // __clang__
-
-#include <boost/test/unit_test.hpp>
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif // __clang__
+#include "boost-test.hpp"
namespace ndn {
diff --git a/tests/security/test-certificate-cache.cpp b/tests/security/test-certificate-cache.cpp
index ee7fd6f..d259e28 100644
--- a/tests/security/test-certificate-cache.cpp
+++ b/tests/security/test-certificate-cache.cpp
@@ -4,11 +4,11 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-#include <unistd.h>
#include "security/certificate-cache-ttl.hpp"
#include "face.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
@@ -39,7 +39,7 @@
Name name1 = certName1.getPrefix(-1);
Name name2 = certName2.getPrefix(-1);
-
+
cache->insertCertificate(cert1);
cache->insertCertificate(cert2);
diff --git a/tests/security/test-encode-decode-certificate.cpp b/tests/security/test-encode-decode-certificate.cpp
index 05c310c..b9d8d36 100644
--- a/tests/security/test-encode-decode-certificate.cpp
+++ b/tests/security/test-encode-decode-certificate.cpp
@@ -3,15 +3,12 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "security/certificate.hpp"
#include "security/public-key.hpp"
#include "security/cryptopp.hpp"
-#include <fstream>
-#include <boost/test/output_test_stream.hpp>
+#include "boost-test.hpp"
using namespace std;
namespace ndn {
diff --git a/tests/security/test-keychain.cpp b/tests/security/test-keychain.cpp
index 8a76b79..00e848a 100644
--- a/tests/security/test-keychain.cpp
+++ b/tests/security/test-keychain.cpp
@@ -4,10 +4,10 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "security/key-chain.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
@@ -21,7 +21,7 @@
Name identity("/TestKeyChain/ExportIdentity/");
identity.appendVersion();
keyChain.createIdentity(identity);
-
+
shared_ptr<SecuredBag> exported = keyChain.exportIdentity(identity, "1234");
Block block = exported->wireEncode();
@@ -59,7 +59,7 @@
BOOST_AUTO_TEST_CASE (PrepareIdentityCertificate)
{
KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
-
+
Name identity("/TestKeyChain/PrepareIdentityCertificate/");
identity.appendVersion();
keyChain.createIdentity(identity);
@@ -105,7 +105,7 @@
time::system_clock::now() + time::days(365),
subjectDescription);
BOOST_CHECK(!static_cast<bool>(idCert4));
-
+
Name wrongKeyName3("/TestKeyChain/PrepareIdentityCertificate/ksk-1234");
shared_ptr<IdentityCertificate> idCert5
diff --git a/tests/security/test-sec-public-info-sqlite3.cpp b/tests/security/test-sec-public-info-sqlite3.cpp
index c50183d..52ae0ec 100644
--- a/tests/security/test-sec-public-info-sqlite3.cpp
+++ b/tests/security/test-sec-public-info-sqlite3.cpp
@@ -4,15 +4,11 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#endif
-
-#include <boost/test/unit_test.hpp>
-
#include "security/key-chain.hpp"
#include "util/time.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
@@ -28,18 +24,18 @@
Name certName1;
BOOST_REQUIRE_NO_THROW(certName1 = keyChain.createIdentity(identity));
- Name keyName1 = IdentityCertificate::certificateNameToPublicKeyName(certName1);
+ Name keyName1 = IdentityCertificate::certificateNameToPublicKeyName(certName1);
Name keyName2;
BOOST_REQUIRE_NO_THROW(keyName2 = keyChain.generateRSAKeyPairAsDefault(identity));
-
+
shared_ptr<IdentityCertificate> cert2;
BOOST_REQUIRE_NO_THROW(cert2 = keyChain.selfSign(keyName2));
Name certName2 = cert2->getName();
BOOST_REQUIRE_NO_THROW(keyChain.addCertificateAsKeyDefault(*cert2));
-
+
Name keyName3;
BOOST_REQUIRE_NO_THROW(keyName3 = keyChain.generateRSAKeyPairAsDefault(identity));
-
+
shared_ptr<IdentityCertificate> cert3;
BOOST_REQUIRE_NO_THROW(cert3 = keyChain.selfSign(keyName3));
Name certName3 = cert3->getName();
diff --git a/tests/security/test-sec-tpm-file.cpp b/tests/security/test-sec-tpm-file.cpp
index 056fedf..1ef4ad4 100644
--- a/tests/security/test-sec-tpm-file.cpp
+++ b/tests/security/test-sec-tpm-file.cpp
@@ -4,12 +4,12 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "security/key-chain.hpp"
#include "util/time.hpp"
#include "security/cryptopp.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
@@ -18,15 +18,15 @@
BOOST_AUTO_TEST_CASE (Delete)
{
SecTpmFile tpm;
-
+
Name keyName("/TestSecTpmFile/Delete/ksk-" + boost::lexical_cast<string>(time::toUnixTimestamp(time::system_clock::now())));
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
-
+
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
-
+
tpm.deleteKeyPairInTpm(keyName);
-
+
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
}
@@ -37,7 +37,7 @@
Name keyName("/TestSecTpmFile/SignVerify/ksk-" + boost::lexical_cast<string>(time::toUnixTimestamp(time::system_clock::now())));
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
-
+
Data data("/tmp/test/1");
const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
@@ -49,16 +49,16 @@
try
{
using namespace CryptoPP;
-
+
RSA::PublicKey publicKey;
ByteQueue queue;
queue.Put(reinterpret_cast<const byte*>(pubkeyPtr->get().buf()), pubkeyPtr->get().size());
publicKey.Load(queue);
-
+
RSASS<PKCS1v15, SHA256>::Verifier verifier (publicKey);
bool result = verifier.VerifyMessage(content, sizeof(content),
sigBlock.value(), sigBlock.value_size());
-
+
BOOST_CHECK_EQUAL(result, true);
}
catch(CryptoPP::Exception& e)
@@ -106,7 +106,7 @@
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
-
+
BOOST_REQUIRE_NO_THROW(tpm.importPrivateKeyPkcs8IntoTpm(keyName, reinterpret_cast<const uint8_t*>(decoded.c_str()), decoded.size(), "1234"));
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
@@ -122,16 +122,16 @@
try
{
using namespace CryptoPP;
-
+
RSA::PublicKey publicKey;
ByteQueue queue;
queue.Put(reinterpret_cast<const byte*>(pubkeyPtr->get().buf()), pubkeyPtr->get().size());
publicKey.Load(queue);
-
+
RSASS<PKCS1v15, SHA256>::Verifier verifier (publicKey);
bool result = verifier.VerifyMessage(content, sizeof(content),
sigBlock.value(), sigBlock.value_size());
-
+
BOOST_CHECK_EQUAL(result, true);
}
catch(CryptoPP::Exception& e)
@@ -148,10 +148,10 @@
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
BOOST_REQUIRE(tpm.importPrivateKeyPkcs8IntoTpm(keyName, exported->buf(), exported->size(), "5678"));
-
+
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == true);
-
+
const uint8_t content2[] = {0x05, 0x06, 0x07, 0x08};
Block sigBlock2;
BOOST_CHECK_NO_THROW(sigBlock2 = tpm.signInTpm(content2, sizeof(content2), keyName, DIGEST_ALGORITHM_SHA256));
@@ -159,7 +159,7 @@
try
{
using namespace CryptoPP;
-
+
RSA::PublicKey publicKey;
ByteQueue queue;
queue.Put(reinterpret_cast<const byte*>(pubkeyPtr->get().buf()), pubkeyPtr->get().size());
@@ -168,14 +168,14 @@
RSASS<PKCS1v15, SHA256>::Verifier verifier (publicKey);
bool result = verifier.VerifyMessage(content2, sizeof(content2),
sigBlock2.value(), sigBlock2.value_size());
-
+
BOOST_CHECK_EQUAL(result, true);
}
catch(CryptoPP::Exception& e)
{
BOOST_CHECK(false);
}
-
+
tpm.deleteKeyPairInTpm(keyName);
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
diff --git a/tests/security/test-sec-tpm-osx.cpp b/tests/security/test-sec-tpm-osx.cpp
index 941b06d..1ae9996 100644
--- a/tests/security/test-sec-tpm-osx.cpp
+++ b/tests/security/test-sec-tpm-osx.cpp
@@ -4,12 +4,12 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "security/key-chain.hpp"
#include "util/time.hpp"
#include "security/cryptopp.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
@@ -18,16 +18,16 @@
BOOST_AUTO_TEST_CASE (Delete)
{
SecTpmOsx tpm;
-
+
Name keyName("/TestSecTpmOsx/Delete/ksk-" + boost::lexical_cast<string>(
time::toUnixTimestamp(time::system_clock::now()).count()));
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
-
+
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), true);
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), true);
-
+
tpm.deleteKeyPairInTpm(keyName);
-
+
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC), false);
BOOST_REQUIRE_EQUAL(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE), false);
}
@@ -39,7 +39,7 @@
Name keyName("/TestSecTpmOsx/SignVerify/ksk-" + boost::lexical_cast<string>(
time::toUnixTimestamp(time::system_clock::now()).count()));
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
-
+
Data data("/TestSecTpmOsx/SignVaerify/Data/1");
const uint8_t content[] = {0x01, 0x02, 0x03, 0x04};
@@ -60,7 +60,7 @@
RSASS<PKCS1v15, SHA256>::Verifier verifier (publicKey);
bool result = verifier.VerifyMessage(content, sizeof(content),
sigBlock.value(), sigBlock.value_size());
-
+
BOOST_CHECK_EQUAL(result, true);
}
catch(CryptoPP::Exception& e)
@@ -100,7 +100,7 @@
Name keyName("/TestSecTpmOsx/ExportImportKey/ksk-" + boost::lexical_cast<string>(
time::toUnixTimestamp(time::system_clock::now()).count()));
-
+
BOOST_CHECK_NO_THROW(tpm.generateKeyPairInTpm(keyName, KEY_TYPE_RSA, 2048));
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
@@ -117,7 +117,7 @@
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == false);
BOOST_REQUIRE(tpm.importPrivateKeyPkcs8IntoTpm(keyName, exported->buf(), exported->size(), "1234"));
-
+
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC) == true);
BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == true);
@@ -137,14 +137,14 @@
RSASS<PKCS1v15, SHA256>::Verifier verifier (publicKey);
bool result = verifier.VerifyMessage(content, sizeof(content),
sigBlock.value(), sigBlock.value_size());
-
+
BOOST_CHECK_EQUAL(result, true);
}
catch(CryptoPP::Exception& e)
{
BOOST_CHECK(false);
}
-
+
tpm.deleteKeyPairInTpm(keyName);
// This is some problem related to Mac OS Key chain, and we will fix it later.
// BOOST_REQUIRE(tpm.doesKeyExistInTpm(keyName, KEY_CLASS_PRIVATE) == false);
diff --git a/tests/security/test-signature-sha256.cpp b/tests/security/test-signature-sha256.cpp
index daf359b..a5450b9 100644
--- a/tests/security/test-signature-sha256.cpp
+++ b/tests/security/test-signature-sha256.cpp
@@ -4,13 +4,13 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "security/key-chain.hpp"
#include "security/validator.hpp"
#include "security/cryptopp.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
@@ -38,14 +38,14 @@
Data testData(name);
char content[5] = "1234";
testData.setContent(reinterpret_cast<uint8_t*>(content), 5);
-
+
KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keychain;
keychain.signWithSha256(testData);
testData.wireEncode();
SignatureSha256 sig(testData.getSignature());
-
+
BOOST_REQUIRE(Validator::verifySignature(testData, sig));
}
diff --git a/tests/security/test-signed-interest.cpp b/tests/security/test-signed-interest.cpp
index db051c3..b870fb1 100644
--- a/tests/security/test-signed-interest.cpp
+++ b/tests/security/test-signed-interest.cpp
@@ -4,14 +4,14 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "security/key-chain.hpp"
#include "security/validator.hpp"
#include "util/command-interest-generator.hpp"
#include "util/command-interest-validator.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
diff --git a/tests/security/test-validator.cpp b/tests/security/test-validator.cpp
index c909c06..6e9ce4c 100644
--- a/tests/security/test-validator.cpp
+++ b/tests/security/test-validator.cpp
@@ -4,12 +4,11 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "security/validator-null.hpp"
#include "security/key-chain.hpp"
#include "util/time.hpp"
+#include "boost-test.hpp"
using namespace std;
@@ -23,8 +22,8 @@
void
onValidationFailed(const shared_ptr<const Data>& data, const string& failureInfo)
-{
- BOOST_CHECK(false);
+{
+ BOOST_CHECK(false);
}
BOOST_AUTO_TEST_CASE (Null)
@@ -41,7 +40,7 @@
shared_ptr<Data> data = make_shared<Data>(dataName);
BOOST_CHECK_NO_THROW(keyChain.signByIdentity(*data, identity));
-
+
ValidatorNull validator;
// data must be a shared pointer