build: Warnings correction for gcc 4.2
Also in this commit some code style corrections.
Change-Id: Idf2b5b96b328fb3dbea7440362c84d7759a10ec5
Refs: #1429
diff --git a/examples/producer.cpp b/examples/producer.cpp
index b34bae1..1327e94 100644
--- a/examples/producer.cpp
+++ b/examples/producer.cpp
@@ -24,9 +24,9 @@
onInterest(const Name& name, const Interest& interest)
{
std::cout << "<< I: " << interest << std::endl;
-
+
ndn::Data data(ndn::Name(interest.getName()).append("testApp").appendVersion());
- data.setFreshnessPeriod(time::seconds(10));
+ data.setFreshnessPeriod(ndn::time::seconds(10));
data.setContent((const uint8_t*)"HELLO KITTY", sizeof("HELLO KITTY"));
@@ -43,7 +43,7 @@
std::cerr << "ERROR: Failed to register prefix in local hub's daemon (" << reason << ")" << std::endl;
face_.shutdown ();
}
-
+
void
listen()
{
diff --git a/src/security/openssl.hpp b/src/security/openssl.hpp
new file mode 100644
index 0000000..fdbf55a
--- /dev/null
+++ b/src/security/openssl.hpp
@@ -0,0 +1,47 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2014 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_SECURITY_OPENSSL_HPP
+#define NDN_SECURITY_OPENSSL_HPP
+
+// suppress deprecation warnings in OSX >= 10.7
+
+#if defined(__APPLE__)
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif // __clang__
+
+#ifdef __GNUC__
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic push
+#endif
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif // __GNUC__
+
+#endif
+
+
+#include <openssl/ssl.h>
+#include <openssl/sha.h>
+#include <openssl/rsa.h>
+
+
+#if defined(__APPLE__)
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif // __clang__
+
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic pop
+#endif // __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+
+#endif
+
+
+#endif // NDN_SECURITY_OPENSSL_HPP
diff --git a/src/security/sec-tpm-memory.cpp b/src/security/sec-tpm-memory.cpp
index 6e4a371..3c77c15 100644
--- a/src/security/sec-tpm-memory.cpp
+++ b/src/security/sec-tpm-memory.cpp
@@ -10,9 +10,7 @@
#include "sec-tpm-memory.hpp"
#include "public-key.hpp"
-#include <openssl/ssl.h>
-#include <openssl/sha.h>
-#include <openssl/rsa.h>
+#include "openssl.hpp"
#include "cryptopp.hpp"
using namespace std;
@@ -24,29 +22,29 @@
*/
class SecTpmMemory::RsaPrivateKey {
public:
- RsaPrivateKey(const uint8_t *keyDer, size_t keyDerLength)
+ RsaPrivateKey(const uint8_t* keyDer, size_t keyDerLength)
{
// Use a temporary pointer since d2i updates it.
- const uint8_t *derPointer = keyDer;
+ const uint8_t* derPointer = keyDer;
privateKey_ = d2i_RSAPrivateKey(NULL, &derPointer, keyDerLength);
if (!privateKey_)
throw Error("RsaPrivateKey constructor: Error decoding private key DER");
}
-
+
~RsaPrivateKey()
{
if (privateKey_)
RSA_free(privateKey_);
}
-
- rsa_st *
+
+ rsa_st*
getPrivateKey()
{
return privateKey_;
}
-
+
private:
- rsa_st * privateKey_;
+ rsa_st* privateKey_;
};
SecTpmMemory::~SecTpmMemory()
@@ -55,14 +53,14 @@
void
SecTpmMemory::setKeyPairForKeyName(const Name& keyName,
- uint8_t *publicKeyDer, size_t publicKeyDerLength,
- uint8_t *privateKeyDer, size_t privateKeyDerLength)
+ uint8_t* publicKeyDer, size_t publicKeyDerLength,
+ uint8_t* privateKeyDer, size_t privateKeyDerLength)
{
publicKeyStore_[keyName.toUri()] = make_shared<PublicKey>(publicKeyDer, publicKeyDerLength);
privateKeyStore_[keyName.toUri()] = make_shared<RsaPrivateKey>(privateKeyDer, privateKeyDerLength);
}
-void
+void
SecTpmMemory::generateKeyPairInTpm(const Name& keyName, KeyType keyType, int keySize)
{
#if 1
@@ -71,7 +69,7 @@
}
void
-SecTpmMemory::deleteKeyPairInTpm(const Name &keyName)
+SecTpmMemory::deleteKeyPairInTpm(const Name& keyName)
{
throw Error("SecTpmMemory::deleteKeyPairInTpm not implemented");
}
@@ -94,7 +92,7 @@
return false;
}
-shared_ptr<PublicKey>
+shared_ptr<PublicKey>
SecTpmMemory::getPublicKeyFromTpm(const Name& keyName)
{
PublicKeyStore::iterator publicKey = publicKeyStore_.find(keyName.toUri());
@@ -103,8 +101,8 @@
return publicKey->second;
}
-Block
-SecTpmMemory::signInTpm(const uint8_t *data, size_t dataLength,
+Block
+SecTpmMemory::signInTpm(const uint8_t* data, size_t dataLength,
const Name& keyName,
DigestAlgorithm digestAlgorithm)
{
@@ -115,17 +113,17 @@
PrivateKeyStore::iterator privateKey = privateKeyStore_.find(keyName.toUri());
if (privateKey == privateKeyStore_.end())
throw Error(string("MemoryPrivateKeyStorage: Cannot find private key ") + keyName.toUri());
-
+
uint8_t digest[SHA256_DIGEST_LENGTH];
SHA256_CTX sha256;
SHA256_Init(&sha256);
SHA256_Update(&sha256, data, dataLength);
- SHA256_Final(digest, &sha256);
+ SHA256_Final(digest,& sha256);
BufferPtr signatureBuffer = make_shared<Buffer>();
signatureBuffer->resize(RSA_size(privateKey->second->getPrivateKey()));
-
- unsigned int signatureBitsLength;
+
+ unsigned int signatureBitsLength;
if (!RSA_sign(NID_sha256, digest, sizeof(digest),
signatureBuffer->buf(),
&signatureBitsLength,
@@ -153,7 +151,7 @@
#endif
}
-void
+void
SecTpmMemory::generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize)
{
#if 1
diff --git a/src/security/sec-tpm-memory.hpp b/src/security/sec-tpm-memory.hpp
index de48201..2c8cc2b 100644
--- a/src/security/sec-tpm-memory.hpp
+++ b/src/security/sec-tpm-memory.hpp
@@ -23,7 +23,7 @@
public:
struct Error : public SecTpm::Error { Error(const std::string &what) : SecTpm::Error(what) {} };
- virtual
+ virtual
~SecTpmMemory();
/******************************
@@ -43,7 +43,7 @@
{
m_inTerminal = inTerminal;
}
-
+
virtual bool
getInTerminal()
{
@@ -62,34 +62,34 @@
return !locked();
}
- virtual void
+ virtual void
generateKeyPairInTpm(const Name& keyName, KeyType keyType, int keySize);
- virtual shared_ptr<PublicKey>
+ virtual shared_ptr<PublicKey>
getPublicKeyFromTpm(const Name& keyName);
virtual void
deleteKeyPairInTpm(const Name &keyName);
- virtual Block
- signInTpm(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
-
- virtual ConstBufferPtr
+ virtual Block
+ signInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm);
+
+ virtual ConstBufferPtr
decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
virtual ConstBufferPtr
encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
- virtual void
+ virtual void
generateSymmetricKeyInTpm(const Name& keyName, KeyType keyType, int keySize);
virtual bool
- doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
+ doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
virtual bool
generateRandomBlock(uint8_t* res, size_t size);
- virtual void
+ virtual void
addAppToACL(const Name& keyName, KeyClass keyClass, const std::string& appPath, AclType acl)
{}
@@ -107,8 +107,8 @@
* @param privateKeyDerLength The length of privateKeyDer.
*/
void setKeyPairForKeyName(const Name& keyName,
- uint8_t *publicKeyDer, size_t publicKeyDerLength,
- uint8_t *privateKeyDer, size_t privateKeyDerLength);
+ uint8_t* publicKeyDer, size_t publicKeyDerLength,
+ uint8_t* privateKeyDer, size_t privateKeyDerLength);
protected:
/******************************
@@ -119,17 +119,17 @@
virtual bool
importPrivateKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buf, size_t size);
-
+
virtual bool
importPublicKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buf, size_t size);
-
-
+
+
private:
class RsaPrivateKey;
typedef std::map<std::string, shared_ptr<PublicKey> > PublicKeyStore;
typedef std::map<std::string, shared_ptr<RsaPrivateKey> > PrivateKeyStore;
-
+
PublicKeyStore publicKeyStore_; /**< The map key is the keyName.toUri() */
PrivateKeyStore privateKeyStore_; /**< The map key is the keyName.toUri() */
diff --git a/src/security/sec-tpm-osx.cpp b/src/security/sec-tpm-osx.cpp
index ada0b81..24d47ea 100644
--- a/src/security/sec-tpm-osx.cpp
+++ b/src/security/sec-tpm-osx.cpp
@@ -35,7 +35,7 @@
: m_passwordSet(false)
, m_inTerminal(false)
{}
-
+
/**
* @brief Convert NDN name of a key to internal name of the key.
*
@@ -43,62 +43,62 @@
* @param keyClass
* @return the internal key name
*/
- std::string
+ std::string
toInternalKeyName(const Name & keyName, KeyClass keyClass);
-
+
/**
* @brief Get key.
*
- * @param keyName
+ * @param keyName
* @param keyClass
* @returns pointer to the key
*/
- SecKeychainItemRef
+ SecKeychainItemRef
getKey(const Name & keyName, KeyClass keyClass);
-
+
/**
* @brief Convert keyType to MAC OS symmetric key key type
*
* @param keyType
* @returns MAC OS key type
*/
- const CFTypeRef
+ const CFTypeRef
getSymKeyType(KeyType keyType);
-
+
/**
* @brief Convert keyType to MAC OS asymmetirc key type
*
* @param keyType
* @returns MAC OS key type
*/
- const CFTypeRef
+ const CFTypeRef
getAsymKeyType(KeyType keyType);
-
+
/**
* @brief Convert keyClass to MAC OS key class
*
* @param keyClass
* @returns MAC OS key class
*/
- const CFTypeRef
+ const CFTypeRef
getKeyClass(KeyClass keyClass);
-
+
/**
* @brief Convert digestAlgo to MAC OS algorithm id
*
* @param digestAlgo
* @returns MAC OS algorithm id
*/
- const CFStringRef
+ const CFStringRef
getDigestAlgorithm(DigestAlgorithm digestAlgo);
-
+
/**
* @brief Get the digest size of the corresponding algorithm
*
* @param digestAlgo
* @return digest size
*/
- long
+ long
getDigestSize(DigestAlgorithm digestAlgo);
///////////////////////////////////////////////
@@ -121,7 +121,7 @@
SecKeychainSetUserInteractionAllowed (true);
OSStatus res = SecKeychainCopyDefault(&m_impl->m_keyChainRef);
-
+
if (res == errSecNoDefaultKeychain) //If no default key chain, create one.
throw Error("No default keychain, create one first!");
}
@@ -178,7 +178,7 @@
bool
SecTpmOsx::unlockTpm(const char* password, size_t passwordLength, bool usePassword)
{
- OSStatus res;
+ OSStatus res;
// If the default key chain is already unlocked, return immediately.
if(!locked())
@@ -207,26 +207,26 @@
bool locked = true;
const char* fmt = "Password to unlock the default keychain: ";
int count = 0;
-
+
while(locked)
{
if(count > 2)
break;
-
+
char* getPassword = NULL;
getPassword = getpass(fmt);
count++;
-
+
if (!getPassword)
continue;
-
+
res = SecKeychainUnlock(m_impl->m_keyChainRef,
strlen(getPassword),
getPassword,
true);
-
+
memset(getPassword, 0, strlen(getPassword));
-
+
if(res == errSecSuccess)
break;
}
@@ -240,10 +240,10 @@
return !locked();
}
-void
+void
SecTpmOsx::generateKeyPairInTpmInternal(const Name & keyName, KeyType keyType, int keySize, bool retry)
-{
-
+{
+
if(doesKeyExistInTpm(keyName, KEY_CLASS_PUBLIC)){
_LOG_DEBUG("keyName has existed");
throw Error("keyName has existed");
@@ -253,10 +253,10 @@
SecKeyRef publicKey, privateKey;
- CFStringRef keyLabel = CFStringCreateWithCString(NULL,
- keyNameUri.c_str(),
+ CFStringRef keyLabel = CFStringCreateWithCString(NULL,
+ keyNameUri.c_str(),
kCFStringEncodingUTF8);
-
+
CFMutableDictionaryRef attrDict = CFDictionaryCreateMutable(NULL,
3,
&kCFTypeDictionaryKeyCallBacks,
@@ -274,7 +274,7 @@
CFRelease(privateKey);
return;
}
-
+
if (res == errSecAuthFailed && !retry)
{
if(unlockTpm(0, 0, false))
@@ -292,11 +292,11 @@
void
SecTpmOsx::deleteKeyPairInTpmInternal(const Name &keyName, bool retry)
{
- CFStringRef keyLabel = CFStringCreateWithCString(NULL,
- keyName.toUri().c_str(),
+ CFStringRef keyLabel = CFStringCreateWithCString(NULL,
+ keyName.toUri().c_str(),
kCFStringEncodingUTF8);
- CFMutableDictionaryRef searchDict =
+ CFMutableDictionaryRef searchDict =
CFDictionaryCreateMutable(NULL, 5, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFDictionaryAddValue(searchDict, kSecClass, kSecClassKey);
@@ -306,7 +306,7 @@
if (res == errSecSuccess)
return;
-
+
if (res == errSecAuthFailed && !retry)
{
if(unlockTpm(0, 0, false))
@@ -314,7 +314,7 @@
}
}
-void
+void
SecTpmOsx::generateSymmetricKeyInTpm(const Name & keyName, KeyType keyType, int keySize)
{
throw Error("SecTpmOsx::generateSymmetricKeyInTpm is not supported");
@@ -328,8 +328,8 @@
// &kCFTypeDictionaryKeyCallBacks,
// &kCFTypeDictionaryValueCallBacks);
- // CFStringRef keyLabel = CFStringCreateWithCString(NULL,
- // keyNameUri.c_str(),
+ // CFStringRef keyLabel = CFStringCreateWithCString(NULL,
+ // keyNameUri.c_str(),
// kCFStringEncodingUTF8);
// CFDictionaryAddValue(attrDict, kSecAttrKeyType, m_impl->getSymKeyType(keyType));
@@ -341,7 +341,7 @@
// SecKeyRef symmetricKey = SecKeyGenerateSymmetric(attrDict, &error);
- // if (error)
+ // if (error)
// throw Error("Fail to create a symmetric key");
}
@@ -416,12 +416,19 @@
privateKeyAlgorithm.MessageEnd();
DEREncodeOctetString(privateKeyInfo, CFDataGetBytePtr(exportedKey), CFDataGetLength(exportedKey));
}
- privateKeyInfo.MessageEnd();
+ privateKeyInfo.MessageEnd();
CFRelease(exportedKey);
return pkcs1Os.buf();
}
+#ifdef __GNUC__
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic push
+#endif // __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif // __GNUC__
+
bool
SecTpmOsx::importPrivateKeyPkcs1IntoTpmInternal(const Name& keyName, const uint8_t* buf, size_t size, bool retry)
{
@@ -445,7 +452,7 @@
}
BERDecodeOctetString(privateKeyInfo, rawKeyBits);
}
- privateKeyInfo.MessageEnd();
+ privateKeyInfo.MessageEnd();
CFDataRef importedKey = CFDataCreateWithBytesNoCopy(NULL,
rawKeyBits.BytePtr(),
@@ -459,15 +466,18 @@
keyParams.version = SEC_KEY_IMPORT_EXPORT_PARAMS_VERSION;
keyParams.keyAttributes = CSSM_KEYATTR_EXTRACTABLE | CSSM_KEYATTR_PERMANENT;
SecAccessRef access;
- CFStringRef keyLabel = CFStringCreateWithCString(NULL,
- keyName.toUri().c_str(),
+ CFStringRef keyLabel = CFStringCreateWithCString(NULL,
+ keyName.toUri().c_str(),
kCFStringEncodingUTF8);
SecAccessCreate(keyLabel, NULL, &access);
keyParams.accessRef = access;
CFArrayRef outItems;
+#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif // __clang__
+
OSStatus res = SecKeychainItemImport (importedKey,
NULL,
&externalFormat,
@@ -476,8 +486,11 @@
&keyParams,
m_impl->m_keyChainRef,
&outItems);
+
+#ifdef __clang__
#pragma clang diagnostic pop
-
+#endif // __clang__
+
if(res != errSecSuccess)
{
if(res == errSecAuthFailed && !retry)
@@ -502,20 +515,24 @@
attrList.count++;
}
- res = SecKeychainItemModifyAttributesAndData(privateKey,
+ res = SecKeychainItemModifyAttributesAndData(privateKey,
&attrList,
0,
NULL);
-
+
if(res != errSecSuccess)
{
return false;
}
-
+
CFRelease(importedKey);
return true;
}
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic pop
+#endif // __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+
bool
SecTpmOsx::importPublicKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buf, size_t size)
{
@@ -551,11 +568,11 @@
attrList.count++;
}
- res = SecKeychainItemModifyAttributesAndData(publicKey,
+ res = SecKeychainItemModifyAttributesAndData(publicKey,
&attrList,
0,
NULL);
-
+
if(res != errSecSuccess)
return false;
@@ -567,14 +584,14 @@
SecTpmOsx::signInTpmInternal(const uint8_t *data, size_t dataLength, const Name& keyName, DigestAlgorithm digestAlgorithm, bool retry)
{
_LOG_TRACE("OSXPrivateKeyStorage::Sign");
-
+
CFDataRef dataRef = CFDataCreateWithBytesNoCopy(NULL,
data,
dataLength,
kCFAllocatorNull);
SecKeyRef privateKey = (SecKeyRef)m_impl->getKey(keyName, KEY_CLASS_PRIVATE);
-
+
CFErrorRef error;
SecTransformRef signer = SecSignTransformCreate((SecKeyRef)privateKey, &error);
if (error) throw Error("Fail to create signer");
@@ -612,7 +629,7 @@
CFDataRef signature = (CFDataRef) SecTransformExecute(signer, &error);
if (error)
{
- if(!retry)
+ if(!retry)
{
if(unlockTpm(0, 0, false))
return signInTpmInternal(data, dataLength, keyName, digestAlgorithm, true);
@@ -650,7 +667,7 @@
// );
// // _LOG_DEBUG("CreateData");
-
+
// SecKeyRef decryptKey = (SecKeyRef)m_impl->getKey(keyName, keyClass);
// // _LOG_DEBUG("GetKey");
@@ -675,22 +692,22 @@
// return make_shared<Buffer>(CFDataGetBytePtr(output), CFDataGetLength(output));
}
-
+
void
SecTpmOsx::addAppToACL(const Name & keyName, KeyClass keyClass, const string & appPath, AclType acl)
{
if(keyClass == KEY_CLASS_PRIVATE && acl == ACL_TYPE_PRIVATE)
{
SecKeychainItemRef privateKey = m_impl->getKey(keyName, keyClass);
-
+
SecAccessRef accRef;
OSStatus acc_res = SecKeychainItemCopyAccess(privateKey, &accRef);
-
+
CFArrayRef signACL = SecAccessCopyMatchingACLList(accRef,
kSecACLAuthorizationSign);
-
+
SecACLRef aclRef = (SecACLRef) CFArrayGetValueAtIndex(signACL, 0);
-
+
CFArrayRef appList;
CFStringRef description;
SecKeychainPromptSelector promptSelector;
@@ -698,22 +715,22 @@
&appList,
&description,
&promptSelector);
-
+
CFMutableArrayRef newAppList = CFArrayCreateMutableCopy(NULL,
0,
appList);
-
+
SecTrustedApplicationRef trustedApp;
acl_res = SecTrustedApplicationCreateFromPath(appPath.c_str(),
&trustedApp);
-
+
CFArrayAppendValue(newAppList, trustedApp);
-
+
acl_res = SecACLSetContents(aclRef,
newAppList,
description,
promptSelector);
-
+
acc_res = SecKeychainItemSetAccess(privateKey, accRef);
}
}
@@ -729,12 +746,12 @@
// keyClass = KEY_CLASS_SYMMETRIC;
// else
// keyClass = KEY_CLASS_PUBLIC;
-
+
// CFDataRef dataRef = CFDataCreate(NULL,
// reinterpret_cast<const unsigned char*>(data),
// dataLength
// );
-
+
// SecKeyRef encryptKey = (SecKeyRef)m_impl->getKey(keyName, keyClass);
// CFErrorRef error;
@@ -762,10 +779,10 @@
string keyNameUri = m_impl->toInternalKeyName(keyName, keyClass);
- CFStringRef keyLabel = CFStringCreateWithCString(NULL,
- keyNameUri.c_str(),
+ CFStringRef keyLabel = CFStringCreateWithCString(NULL,
+ keyNameUri.c_str(),
kCFStringEncodingUTF8);
-
+
CFMutableDictionaryRef attrDict = CFDictionaryCreateMutable(NULL,
4,
&kCFTypeDictionaryKeyCallBacks,
@@ -775,10 +792,10 @@
// CFDictionaryAddValue(attrDict, kSecAttrKeyClass, m_impl->getKeyClass(keyClass));
CFDictionaryAddValue(attrDict, kSecAttrLabel, keyLabel);
CFDictionaryAddValue(attrDict, kSecReturnRef, kCFBooleanTrue);
-
+
SecKeychainItemRef itemRef;
OSStatus res = SecItemCopyMatching((CFDictionaryRef)attrDict, (CFTypeRef*)&itemRef);
-
+
if(res == errSecSuccess)
return true;
else
@@ -801,10 +818,10 @@
{
string keyNameUri = toInternalKeyName(keyName, keyClass);
- CFStringRef keyLabel = CFStringCreateWithCString(NULL,
- keyNameUri.c_str(),
+ CFStringRef keyLabel = CFStringCreateWithCString(NULL,
+ keyNameUri.c_str(),
kCFStringEncodingUTF8);
-
+
CFMutableDictionaryRef attrDict = CFDictionaryCreateMutable(NULL,
5,
&kCFTypeDictionaryKeyCallBacks,
@@ -814,11 +831,11 @@
CFDictionaryAddValue(attrDict, kSecAttrLabel, keyLabel);
CFDictionaryAddValue(attrDict, kSecAttrKeyClass, getKeyClass(keyClass));
CFDictionaryAddValue(attrDict, kSecReturnRef, kCFBooleanTrue);
-
+
SecKeychainItemRef keyItem;
OSStatus res = SecItemCopyMatching((CFDictionaryRef) attrDict, (CFTypeRef*)&keyItem);
-
+
if(res != errSecSuccess){
_LOG_DEBUG("Fail to find the key!");
return NULL;
@@ -826,8 +843,8 @@
else
return keyItem;
}
-
-string
+
+string
SecTpmOsx::Impl::toInternalKeyName(const Name & keyName, KeyClass keyClass)
{
string keyUri = keyName.toUri();
@@ -838,7 +855,7 @@
return keyUri;
}
-const CFTypeRef
+const CFTypeRef
SecTpmOsx::Impl::getAsymKeyType(KeyType keyType)
{
switch(keyType){
@@ -850,7 +867,7 @@
}
}
-const CFTypeRef
+const CFTypeRef
SecTpmOsx::Impl::getSymKeyType(KeyType keyType)
{
switch(keyType){
@@ -862,7 +879,7 @@
}
}
-const CFTypeRef
+const CFTypeRef
SecTpmOsx::Impl::getKeyClass(KeyClass keyClass)
{
switch(keyClass){
@@ -878,7 +895,7 @@
}
}
-const CFStringRef
+const CFStringRef
SecTpmOsx::Impl::getDigestAlgorithm(DigestAlgorithm digestAlgo)
{
switch(digestAlgo){
@@ -896,7 +913,7 @@
}
}
-long
+long
SecTpmOsx::Impl::getDigestSize(DigestAlgorithm digestAlgo)
{
switch(digestAlgo){
@@ -911,5 +928,5 @@
return -1;
}
}
-
+
} // namespace ndn
diff --git a/src/util/regex/regex-backref-manager.hpp b/src/util/regex/regex-backref-manager.hpp
index bebaedb..f11e431 100644
--- a/src/util/regex/regex-backref-manager.hpp
+++ b/src/util/regex/regex-backref-manager.hpp
@@ -18,21 +18,21 @@
{
public:
RegexBackrefManager(){}
-
+
virtual ~RegexBackrefManager();
-
- int
+
+ int
pushRef(shared_ptr<RegexMatcher> matcher);
-
- void
+
+ void
popRef();
- int
+ size_t
size();
-
- shared_ptr<RegexMatcher>
+
+ shared_ptr<RegexMatcher>
getBackRef(int i);
-
+
private:
std::vector<shared_ptr<RegexMatcher> > m_backRefs;
};
@@ -43,10 +43,10 @@
m_backRefs.clear();
}
-inline int
+inline int
RegexBackrefManager::pushRef(shared_ptr<RegexMatcher> matcher)
{
- int last = m_backRefs.size();
+ size_t last = m_backRefs.size();
m_backRefs.push_back(matcher);
return last;
@@ -58,13 +58,13 @@
m_backRefs.pop_back();
}
-inline int
+inline size_t
RegexBackrefManager::size()
{
return m_backRefs.size();
}
-
-inline shared_ptr<RegexMatcher>
+
+inline shared_ptr<RegexMatcher>
RegexBackrefManager::getBackRef(int i)
{
return m_backRefs[i];
diff --git a/tests-integrated/boost-test.hpp b/tests-integrated/boost-test.hpp
new file mode 100644
index 0000000..6a8293e
--- /dev/null
+++ b/tests-integrated/boost-test.hpp
@@ -0,0 +1,18 @@
+/**
+ * Copyright (C) 2014 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+
+#ifndef NDN_TESTS_INTEGRATED_BOOST_TEST_HPP
+#define NDN_TESTS_INTEGRATED_BOOST_TEST_HPP
+
+// suppress warnings from Boost.Test
+#pragma GCC system_header
+#pragma clang system_header
+
+#include <boost/test/unit_test.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/test/output_test_stream.hpp>
+
+#endif // NDN_TESTS_INTEGRATED_BOOST_TEST_HPP
diff --git a/tests-integrated/main.cpp b/tests-integrated/main.cpp
index 10f957c..3e0ae89 100644
--- a/tests-integrated/main.cpp
+++ b/tests-integrated/main.cpp
@@ -6,13 +6,4 @@
#define BOOST_TEST_MAIN 1
#define BOOST_TEST_DYN_LINK 1
-#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"
diff --git a/tests-integrated/security/test-validator-config.cpp b/tests-integrated/security/test-validator-config.cpp
index 0e778db..2432739 100644
--- a/tests-integrated/security/test-validator-config.cpp
+++ b/tests-integrated/security/test-validator-config.cpp
@@ -6,11 +6,10 @@
#include "security/validator-config.hpp"
-#include <boost/test/unit_test.hpp>
-
#include "security/key-chain.hpp"
#include "util/io.hpp"
+#include "boost-test.hpp"
using namespace std;
diff --git a/tests-integrated/test-all.hpp b/tests-integrated/test-all.hpp
new file mode 100644
index 0000000..1e3e7f8
--- /dev/null
+++ b/tests-integrated/test-all.hpp
@@ -0,0 +1,13 @@
+/**
+ * Copyright (C) 2014 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+// This file is needed for experimental precompiled header support (gcc and clang)
+
+#ifndef NDN_TESTS_INTEGRATED_TEST_ALL_HPP
+#define NDN_TESTS_INTEGRATED_TEST_ALL_HPP
+
+#include "common.hpp"
+
+#endif // NDN_TESTS_INTEGRATED_TEST_ALL_HPP
diff --git a/tests-integrated/test-faces.cpp b/tests-integrated/test-faces.cpp
index 03bfa9b..8c48dbb 100644
--- a/tests-integrated/test-faces.cpp
+++ b/tests-integrated/test-faces.cpp
@@ -3,11 +3,11 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
#include "face.hpp"
#include "util/scheduler.hpp"
-using namespace std;
+#include "boost-test.hpp"
+
namespace ndn {
BOOST_AUTO_TEST_SUITE(TestFaces)
@@ -23,7 +23,7 @@
, regFailedCount(0)
{
}
-
+
void
onData()
{
@@ -100,7 +100,7 @@
face.expressInterest(Interest("/localhost/non-existing/data/should/not/exist/anywhere", time::milliseconds(50)),
ptr_lib::bind(&FacesFixture::onData, this),
ptr_lib::bind(&FacesFixture::onTimeout, this));
-
+
BOOST_REQUIRE_NO_THROW(face.processEvents());
BOOST_CHECK_EQUAL(dataCount, 1);
@@ -138,7 +138,7 @@
Scheduler scheduler(*face.ioService());
scheduler.scheduleEvent(time::milliseconds(300),
bind(&FacesFixture::terminate, this, func_lib::ref(face)));
-
+
regPrefixId = face.setInterestFilter("/Hello/World",
bind(&FacesFixture::onInterest, this, func_lib::ref(face)),
bind(&FacesFixture::onRegFailed, this));
@@ -146,11 +146,11 @@
scheduler.scheduleEvent(time::milliseconds(200),
bind(&FacesFixture::expressInterest, this,
func_lib::ref(face2), Name("/Hello/World/!")));
-
+
BOOST_REQUIRE_NO_THROW(face.processEvents());
- BOOST_CHECK_EQUAL(regFailedCount, 0);
- BOOST_CHECK_EQUAL(inInterestCount, 1);
+ BOOST_CHECK_EQUAL(regFailedCount, 0);
+ BOOST_CHECK_EQUAL(inInterestCount, 1);
BOOST_CHECK_EQUAL(timeoutCount, 1);
BOOST_CHECK_EQUAL(dataCount, 0);
}
@@ -162,11 +162,11 @@
Scheduler scheduler(*face.ioService());
scheduler.scheduleEvent(time::seconds(1),
bind(&FacesFixture::terminate, this, func_lib::ref(face)));
-
+
regPrefixId = face.setInterestFilter("/Hello/World",
bind(&FacesFixture::onInterest, this, func_lib::ref(face)),
bind(&FacesFixture::onRegFailed, this));
-
+
regPrefixId2 = face.setInterestFilter("/Los/Angeles/Lakers",
bind(&FacesFixture::onInterest2, this, func_lib::ref(face)),
bind(&FacesFixture::onRegFailed, this));
@@ -175,12 +175,12 @@
scheduler.scheduleEvent(time::milliseconds(200),
bind(&FacesFixture::expressInterest, this,
func_lib::ref(face2), Name("/Hello/World/!")));
-
+
BOOST_REQUIRE_NO_THROW(face.processEvents());
- BOOST_CHECK_EQUAL(regFailedCount, 0);
- BOOST_CHECK_EQUAL(inInterestCount, 1);
- BOOST_CHECK_EQUAL(inInterestCount2, 0);
+ BOOST_CHECK_EQUAL(regFailedCount, 0);
+ BOOST_CHECK_EQUAL(inInterestCount, 1);
+ BOOST_CHECK_EQUAL(inInterestCount2, 0);
BOOST_CHECK_EQUAL(timeoutCount, 1);
BOOST_CHECK_EQUAL(dataCount, 0);
}
diff --git a/tests-integrated/wscript b/tests-integrated/wscript
index 98f6dab..4e99eb3 100644
--- a/tests-integrated/wscript
+++ b/tests-integrated/wscript
@@ -11,6 +11,7 @@
source=bld.path.ant_glob(['**/*.cpp'],
excl=['**/*-osx.cpp', '**/*-sqlite3.cpp']),
use='ndn-cpp-dev',
+ includes='.',
install_path=None,
)
diff --git a/tests/boost-test.hpp b/tests/boost-test.hpp
new file mode 100644
index 0000000..e1198ce
--- /dev/null
+++ b/tests/boost-test.hpp
@@ -0,0 +1,18 @@
+/**
+ * Copyright (C) 2014 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+
+#ifndef NDN_TESTS_BOOST_TEST_HPP
+#define NDN_TESTS_BOOST_TEST_HPP
+
+// suppress warnings from Boost.Test
+#pragma GCC system_header
+#pragma clang system_header
+
+#include <boost/test/unit_test.hpp>
+#include <boost/concept_check.hpp>
+#include <boost/test/output_test_stream.hpp>
+
+#endif // NDN_TESTS_BOOST_TEST_HPP
diff --git a/tests/key-locator.cpp b/tests/key-locator.cpp
index 00f4ff9..fac6729 100644
--- a/tests/key-locator.cpp
+++ b/tests/key-locator.cpp
@@ -5,8 +5,7 @@
#include "key-locator.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/concept_check.hpp>
+#include "boost-test.hpp"
namespace ndn {
diff --git a/tests/main.cpp b/tests/main.cpp
index 10f957c..3e0ae89 100644
--- a/tests/main.cpp
+++ b/tests/main.cpp
@@ -6,13 +6,4 @@
#define BOOST_TEST_MAIN 1
#define BOOST_TEST_DYN_LINK 1
-#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"
diff --git a/tests/management/nfd-control-command.cpp b/tests/management/nfd-control-command.cpp
index 5cf1910..2a3dec4 100644
--- a/tests/management/nfd-control-command.cpp
+++ b/tests/management/nfd-control-command.cpp
@@ -5,9 +5,8 @@
*/
#include "management/nfd-control-command.hpp"
-// Having a separate compilation unit is necessary to ensure .hpp can compile on its own.
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/nfd-control-parameters.cpp b/tests/management/nfd-control-parameters.cpp
index d5320b1..d8c203b 100644
--- a/tests/management/nfd-control-parameters.cpp
+++ b/tests/management/nfd-control-parameters.cpp
@@ -5,9 +5,8 @@
*/
#include "management/nfd-control-parameters.hpp"
-// Having a separate compilation unit is necessary to ensure .hpp can compile on its own.
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/nfd-controller.cpp b/tests/management/nfd-controller.cpp
index 9176690..37b9cc6 100644
--- a/tests/management/nfd-controller.cpp
+++ b/tests/management/nfd-controller.cpp
@@ -5,11 +5,11 @@
*/
#include "management/nfd-controller.hpp"
-// Having a separate compilation unit is necessary to ensure .hpp can compile on its own.
#include "management/nfd-control-response.hpp"
#include "../transport/dummy-face.hpp"
-#include <boost/test/unit_test.hpp>
+
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/nfd-face-event-notification.cpp b/tests/management/nfd-face-event-notification.cpp
index 76be7c4..2ff00cf 100644
--- a/tests/management/nfd-face-event-notification.cpp
+++ b/tests/management/nfd-face-event-notification.cpp
@@ -6,7 +6,7 @@
#include "management/nfd-face-event-notification.hpp"
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/nfd-face-status.cpp b/tests/management/nfd-face-status.cpp
index 08b5fb0..56693dd 100644
--- a/tests/management/nfd-face-status.cpp
+++ b/tests/management/nfd-face-status.cpp
@@ -6,7 +6,7 @@
#include "management/nfd-face-status.hpp"
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/nfd-forwarder-status.cpp b/tests/management/nfd-forwarder-status.cpp
index d881ad1..2523795 100644
--- a/tests/management/nfd-forwarder-status.cpp
+++ b/tests/management/nfd-forwarder-status.cpp
@@ -7,7 +7,7 @@
#include "management/nfd-forwarder-status.hpp"
#include "data.hpp"
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/test-ndnd-forwarding-entry.cpp b/tests/management/test-ndnd-forwarding-entry.cpp
index 7ad5c94..c116fd6 100644
--- a/tests/management/test-ndnd-forwarding-entry.cpp
+++ b/tests/management/test-ndnd-forwarding-entry.cpp
@@ -4,19 +4,10 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "management/ndnd-forwarding-entry.hpp"
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#endif
+#include "boost-test.hpp"
-#include <fstream>
-#include <boost/test/output_test_stream.hpp>
-
-using namespace std;
namespace ndn {
namespace ndnd {
@@ -40,7 +31,7 @@
BOOST_AUTO_TEST_CASE (Decode)
{
ForwardingEntry forwardingEntry;
-
+
BOOST_REQUIRE_NO_THROW(forwardingEntry.wireDecode(Block(FORWARDING_ENTRY, sizeof(FORWARDING_ENTRY))));
BOOST_REQUIRE_EQUAL(forwardingEntry.getAction(), "selfreg");
diff --git a/tests/management/test-nfd-control.cpp b/tests/management/test-nfd-control.cpp
index 68eece2..0aabbe9 100644
--- a/tests/management/test-nfd-control.cpp
+++ b/tests/management/test-nfd-control.cpp
@@ -8,10 +8,7 @@
#include "management/nfd-fib-management-options.hpp"
#include "management/nfd-face-management-options.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/test/output_test_stream.hpp>
-
-using namespace std;
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/test-nfd-fib-entry.cpp b/tests/management/test-nfd-fib-entry.cpp
index e92c39f..ccb26d5 100644
--- a/tests/management/test-nfd-fib-entry.cpp
+++ b/tests/management/test-nfd-fib-entry.cpp
@@ -6,8 +6,7 @@
#include "management/nfd-fib-entry.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/test/output_test_stream.hpp>
+#include "boost-test.hpp"
namespace ndn {
namespace nfd {
diff --git a/tests/management/test-nrd.cpp b/tests/management/test-nrd.cpp
index 92622f0..197857d 100644
--- a/tests/management/test-nrd.cpp
+++ b/tests/management/test-nrd.cpp
@@ -6,10 +6,7 @@
#include "management/nrd-prefix-reg-options.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/test/output_test_stream.hpp>
-
-using namespace std;
+#include "boost-test.hpp"
namespace ndn {
namespace nrd {
@@ -21,38 +18,39 @@
0x08, 0x03, 0x72, 0x65, 0x67, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x66, 0x01, 0x00,
};
-BOOST_AUTO_TEST_CASE (PrefixRegOptionsEncode)
+BOOST_AUTO_TEST_CASE(PrefixRegOptionsEncode)
{
- Name n ("/localhost/reg/test");
+ Name n("/localhost/reg/test");
PrefixRegOptions opt;
- opt.setName (n);
- opt.setFaceId (0);
- opt.setCost (0);
+ opt.setName(n);
+ opt.setFaceId(0);
+ opt.setCost(0);
- const Block& blk = opt.wireEncode ();
+ const Block& blk = opt.wireEncode();
BOOST_CHECK_EQUAL_COLLECTIONS(RealPrefixRegOptions,
- RealPrefixRegOptions + sizeof (RealPrefixRegOptions),
- blk.begin (), blk.end ());
+ RealPrefixRegOptions + sizeof(RealPrefixRegOptions),
+ blk.begin(), blk.end());
std::ostringstream os;
os << opt;
BOOST_CHECK_EQUAL(os.str(), "PrefixRegOptions(Prefix: /localhost/reg/test, "
- "FaceID: 0, Flags: 1, Cost: 0, ExpirationPeriod: -9223372036854775808 milliseconds, Protocol: )");
+ "FaceID: 0, Flags: 1, Cost: 0, "
+ "ExpirationPeriod: -9223372036854775808 milliseconds, Protocol: )");
}
-BOOST_AUTO_TEST_CASE (PrefixRegOptionsDecoding)
+BOOST_AUTO_TEST_CASE(PrefixRegOptionsDecoding)
{
- Block blk (RealPrefixRegOptions, sizeof (RealPrefixRegOptions));
- Name n ("/localhost/reg/test");
+ Block blk(RealPrefixRegOptions, sizeof(RealPrefixRegOptions));
+ Name n("/localhost/reg/test");
PrefixRegOptions opt;
- BOOST_REQUIRE_NO_THROW (opt.wireDecode (blk));
-
- BOOST_CHECK_EQUAL (opt.getName (), n);
- BOOST_CHECK_EQUAL (opt.getFaceId (), 0);
- BOOST_CHECK_EQUAL (opt.getCost (), 0);
+ BOOST_REQUIRE_NO_THROW(opt.wireDecode(blk));
+
+ BOOST_CHECK_EQUAL(opt.getName(), n);
+ BOOST_CHECK_EQUAL(opt.getFaceId(), 0);
+ BOOST_CHECK_EQUAL(opt.getCost(), 0);
}
BOOST_AUTO_TEST_SUITE_END()
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
diff --git a/tests/test-all.hpp b/tests/test-all.hpp
index 0e4c8c5..4b5e1a8 100644
--- a/tests/test-all.hpp
+++ b/tests/test-all.hpp
@@ -1,10 +1,12 @@
/**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (C) 2014 Regents of the University of California.
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_TEST_ALL_HPP
-#define NDN_TEST_ALL_HPP
+// This file is needed for experimental precompiled header support (gcc and clang)
+
+#ifndef NDN_TESTS_TEST_ALL_HPP
+#define NDN_TESTS_TEST_ALL_HPP
#include "common.hpp"
diff --git a/tests/test-block.cpp b/tests/test-block.cpp
index 1c7557d..c0b9671 100644
--- a/tests/test-block.cpp
+++ b/tests/test-block.cpp
@@ -5,8 +5,7 @@
#include "encoding/encoding-buffer.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/concept_check.hpp>
+#include "boost-test.hpp"
using namespace std;
namespace ndn {
diff --git a/tests/test-data.cpp b/tests/test-data.cpp
index 0034ffa..30d39df 100644
--- a/tests/test-data.cpp
+++ b/tests/test-data.cpp
@@ -3,15 +3,12 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "data.hpp"
#include "security/key-chain.hpp"
-
-#include <fstream>
-
#include "security/cryptopp.hpp"
+#include "boost-test.hpp"
+
using namespace std;
namespace ndn {
@@ -20,29 +17,29 @@
const uint8_t Content1[] = {0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x21};
const uint8_t Data1[] = {
-0x06, 0xc5, // NDN Data
- 0x07, 0x14, // Name
- 0x08, 0x05,
+0x06, 0xc5, // NDN Data
+ 0x07, 0x14, // Name
+ 0x08, 0x05,
0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x08, 0x03,
+ 0x08, 0x03,
0x6e, 0x64, 0x6e,
- 0x08, 0x06,
+ 0x08, 0x06,
0x70, 0x72, 0x65, 0x66, 0x69, 0x78,
0x14, 0x04, // MetaInfo
0x19, 0x02, // FreshnessPeriod
- 0x27, 0x10,
- 0x15, 0x08, // Content
+ 0x27, 0x10,
+ 0x15, 0x08, // Content
0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x21,
0x16, 0x1b, // SignatureInfo
0x1b, 0x01, // SignatureType
- 0x01,
+ 0x01,
0x1c, 0x16, // KeyLocator
- 0x07, 0x14, // Name
- 0x08, 0x04,
+ 0x07, 0x14, // Name
+ 0x08, 0x04,
0x74, 0x65, 0x73, 0x74,
- 0x08, 0x03,
+ 0x08, 0x03,
0x6b, 0x65, 0x79,
- 0x08, 0x07,
+ 0x08, 0x07,
0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72,
0x17, 0x80, // SignatureValue
0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1
@@ -109,7 +106,7 @@
BOOST_FIXTURE_TEST_CASE (Decode, TestDataFixture)
{
Block dataBlock(Data1, sizeof(Data1));
-
+
ndn::Data d;
// BOOST_REQUIRE_NO_THROW
(d.wireDecode(dataBlock));
@@ -125,10 +122,10 @@
block.parse();
KeyLocator keyLocator;
BOOST_REQUIRE_NO_THROW(keyLocator.wireDecode(block.get(Tlv::KeyLocator)));
-
+
BOOST_REQUIRE_EQUAL(keyLocator.getName().toUri(), "/test/key/locator");
- using namespace CryptoPP;
+ using namespace CryptoPP;
RSASS<PKCS1v15, SHA256>::Verifier verifier(publicKey_);
bool signatureVerified = verifier.VerifyMessage(d.wireEncode().value(), d.wireEncode().value_size() - d.getSignature().getValue().size(),
d.getSignature().getValue().value(), d.getSignature().getValue().value_size());
@@ -138,11 +135,11 @@
BOOST_FIXTURE_TEST_CASE (Encode, TestDataFixture)
{
// manual data packet creation for now
-
+
ndn::Data d(ndn::Name("/local/ndn/prefix"));
d.setContentType(MetaInfo::TYPE_DEFAULT);
d.setFreshnessPeriod(time::seconds(10));
-
+
d.setContent(Content1, sizeof(Content1));
Block signatureInfo(Tlv::SignatureInfo);
@@ -155,7 +152,7 @@
{
KeyLocator keyLocator;
keyLocator.setName("/test/key/locator");
-
+
signatureInfo.push_back(keyLocator.wireEncode());
}
signatureInfo.encode();
@@ -165,7 +162,7 @@
Tlv::writeVarNumber(os, Tlv::SignatureValue);
using namespace CryptoPP;
-
+
RSASS<PKCS1v15, SHA256>::Signer signer(privateKey_);
PK_MessageAccumulator *hash = signer.NewSignatureAccumulator(rng_);
@@ -173,7 +170,7 @@
hash->Update(d.getMetaInfo().wireEncode().wire(), d.getMetaInfo().wireEncode().size());
hash->Update(d.getContent(). wire(), d.getContent(). size());
hash->Update(signatureInfo. wire(), signatureInfo. size());
-
+
size_t length = signer.MaxSignatureLength();
SecByteBlock buf(length);
signer.Sign(rng_, hash, buf);
@@ -182,7 +179,7 @@
os.write(reinterpret_cast<const char *> (buf.BytePtr()), buf.size());
ndn::Block signatureValue (Block(os.buf()));
-
+
Signature signature(signatureInfo, signatureValue);
d.setSignature(signature);
@@ -208,11 +205,11 @@
BOOST_REQUIRE_NO_THROW(meta.wireEncode());
BOOST_REQUIRE_EQUAL_COLLECTIONS(MetaInfo2, MetaInfo2+sizeof(MetaInfo2),
meta.wireEncode().begin(), meta.wireEncode().end());
-
+
meta.setType(MetaInfo::TYPE_LINK);
BOOST_REQUIRE_NO_THROW(meta.wireEncode());
BOOST_REQUIRE_EQUAL_COLLECTIONS(MetaInfo3, MetaInfo3+sizeof(MetaInfo3),
- meta.wireEncode().begin(), meta.wireEncode().end());
+ meta.wireEncode().begin(), meta.wireEncode().end());
}
BOOST_AUTO_TEST_CASE (DecodeMetaInfo)
diff --git a/tests/test-exclude.cpp b/tests/test-exclude.cpp
index 033fdea..296d9ab 100644
--- a/tests/test-exclude.cpp
+++ b/tests/test-exclude.cpp
@@ -5,41 +5,41 @@
#include "exclude.hpp"
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
namespace ndn {
BOOST_AUTO_TEST_SUITE(TestExclude)
-BOOST_AUTO_TEST_CASE (Basic)
+BOOST_AUTO_TEST_CASE(Basic)
{
Exclude e;
- e.excludeOne (name::Component("b"));
- BOOST_CHECK_EQUAL (e.size (), 1);
- BOOST_CHECK_EQUAL (e.toUri(), "b");
+ e.excludeOne(name::Component("b"));
+ BOOST_CHECK_EQUAL(e.size(), 1);
+ BOOST_CHECK_EQUAL(e.toUri(), "b");
- e.excludeOne (name::Component("d"));
- BOOST_CHECK_EQUAL (e.size (), 2);
- BOOST_CHECK_EQUAL (e.toUri(), "b,d");
+ e.excludeOne(name::Component("d"));
+ BOOST_CHECK_EQUAL(e.size(), 2);
+ BOOST_CHECK_EQUAL(e.toUri(), "b,d");
- e.excludeOne (name::Component("a"));
- BOOST_CHECK_EQUAL (e.size (), 3);
- BOOST_CHECK_EQUAL (e.toUri(), "a,b,d");
+ e.excludeOne(name::Component("a"));
+ BOOST_CHECK_EQUAL(e.size(), 3);
+ BOOST_CHECK_EQUAL(e.toUri(), "a,b,d");
- e.excludeOne (name::Component("aa"));
- BOOST_CHECK_EQUAL (e.size (), 4);
- BOOST_CHECK_EQUAL (e.toUri(), "a,b,d,aa");
+ e.excludeOne(name::Component("aa"));
+ BOOST_CHECK_EQUAL(e.size(), 4);
+ BOOST_CHECK_EQUAL(e.toUri(), "a,b,d,aa");
- e.excludeOne (name::Component("cc"));
- BOOST_CHECK_EQUAL (e.size (), 5);
- BOOST_CHECK_EQUAL (e.toUri(), "a,b,d,aa,cc");
+ e.excludeOne(name::Component("cc"));
+ BOOST_CHECK_EQUAL(e.size(), 5);
+ BOOST_CHECK_EQUAL(e.toUri(), "a,b,d,aa,cc");
- e.excludeOne (name::Component("c"));
- BOOST_CHECK_EQUAL (e.size (), 6);
- BOOST_CHECK_EQUAL (e.toUri(), "a,b,c,d,aa,cc");
+ e.excludeOne(name::Component("c"));
+ BOOST_CHECK_EQUAL(e.size(), 6);
+ BOOST_CHECK_EQUAL(e.toUri(), "a,b,c,d,aa,cc");
}
-BOOST_AUTO_TEST_CASE (Before)
+BOOST_AUTO_TEST_CASE(Before)
{
// based on http://redmine.named-data.net/issues/1158
ndn::Exclude e;
@@ -48,56 +48,56 @@
BOOST_CHECK_EQUAL(e.toUri(), "*,PuQxMaf91");
}
-BOOST_AUTO_TEST_CASE (Ranges)
+BOOST_AUTO_TEST_CASE(Ranges)
{
// example: ANY /b /d ANY /f
Exclude e;
- e.excludeOne (name::Component ("b0"));
- BOOST_CHECK_EQUAL (e.size (), 1);
- BOOST_CHECK_EQUAL (e.toUri(), "b0");
+ e.excludeOne(name::Component("b0"));
+ BOOST_CHECK_EQUAL(e.size(), 1);
+ BOOST_CHECK_EQUAL(e.toUri(), "b0");
- e.excludeRange (name::Component (), name::Component ("b1"));
- BOOST_CHECK_EQUAL (e.size (), 2);
- BOOST_CHECK_EQUAL (e.toUri(), "*,b1");
+ e.excludeRange(name::Component(), name::Component("b1"));
+ BOOST_CHECK_EQUAL(e.size(), 2);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,b1");
- e.excludeRange (name::Component (), name::Component("c0"));
- BOOST_CHECK_EQUAL (e.size (), 2);
- BOOST_CHECK_EQUAL (e.toUri(), "*,c0");
+ e.excludeRange(name::Component(), name::Component("c0"));
+ BOOST_CHECK_EQUAL(e.size(), 2);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,c0");
- e.excludeRange (name::Component("a0"), name::Component("c0"));
- BOOST_CHECK_EQUAL (e.size (), 2);
- BOOST_CHECK_EQUAL (e.toUri(), "*,c0");
+ e.excludeRange(name::Component("a0"), name::Component("c0"));
+ BOOST_CHECK_EQUAL(e.size(), 2);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,c0");
- e.excludeRange (name::Component("d0"), name::Component("e0"));
- BOOST_CHECK_EQUAL (e.size (), 4);
- BOOST_CHECK_EQUAL (e.toUri(), "*,c0,d0,*,e0");
+ e.excludeRange(name::Component("d0"), name::Component("e0"));
+ BOOST_CHECK_EQUAL(e.size(), 4);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,c0,d0,*,e0");
- e.excludeRange (name::Component("c1"), name::Component("d1"));
- BOOST_CHECK_EQUAL (e.size (), 4);
- BOOST_CHECK_EQUAL (e.toUri(), "*,c0,c1,*,e0");
+ e.excludeRange(name::Component("c1"), name::Component("d1"));
+ BOOST_CHECK_EQUAL(e.size(), 4);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,c0,c1,*,e0");
- e.excludeRange (name::Component("a1"), name::Component("d1"));
- BOOST_CHECK_EQUAL (e.size (), 2);
- BOOST_CHECK_EQUAL (e.toUri(), "*,e0");
+ e.excludeRange(name::Component("a1"), name::Component("d1"));
+ BOOST_CHECK_EQUAL(e.size(), 2);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,e0");
- e.excludeBefore (name::Component("e2"));
- BOOST_CHECK_EQUAL (e.size (), 2);
- BOOST_CHECK_EQUAL (e.toUri(), "*,e2");
+ e.excludeBefore(name::Component("e2"));
+ BOOST_CHECK_EQUAL(e.size(), 2);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,e2");
- e.excludeAfter (name::Component("f0"));
- BOOST_CHECK_EQUAL (e.size (), 3);
- BOOST_CHECK_EQUAL (e.toUri(), "*,e2,f0,*");
+ e.excludeAfter(name::Component("f0"));
+ BOOST_CHECK_EQUAL(e.size(), 3);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,e2,f0,*");
- e.excludeAfter (name::Component("e5"));
- BOOST_CHECK_EQUAL (e.size (), 3);
- BOOST_CHECK_EQUAL (e.toUri(), "*,e2,e5,*");
+ e.excludeAfter(name::Component("e5"));
+ BOOST_CHECK_EQUAL(e.size(), 3);
+ BOOST_CHECK_EQUAL(e.toUri(), "*,e2,e5,*");
- e.excludeAfter (name::Component("b2"));
- BOOST_CHECK_EQUAL (e.size (), 1);
- BOOST_CHECK_EQUAL (e.toUri(), "*");
+ e.excludeAfter(name::Component("b2"));
+ BOOST_CHECK_EQUAL(e.size(), 1);
+ BOOST_CHECK_EQUAL(e.toUri(), "*");
- BOOST_REQUIRE_THROW (e.excludeRange (name::Component("d0"), name::Component("a0")), Exclude::Error);
+ BOOST_REQUIRE_THROW(e.excludeRange(name::Component("d0"), name::Component("a0")), Exclude::Error);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/test-interest.cpp b/tests/test-interest.cpp
index 321685e..3da58ec 100644
--- a/tests/test-interest.cpp
+++ b/tests/test-interest.cpp
@@ -8,7 +8,7 @@
#include "security/signature-sha256-with-rsa.hpp"
#include "security/signature-sha256.hpp"
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
using namespace std;
namespace ndn {
@@ -65,48 +65,48 @@
0x01
};
-BOOST_AUTO_TEST_CASE (Decode)
+BOOST_AUTO_TEST_CASE(Decode)
{
Block interestBlock(Interest1, sizeof(Interest1));
ndn::Interest i;
BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock));
- BOOST_REQUIRE_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
- BOOST_REQUIRE_EQUAL(i.getScope(), 1);
- BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), time::milliseconds(1000));
- BOOST_REQUIRE_EQUAL(i.getMinSuffixComponents(), 1);
- BOOST_REQUIRE_EQUAL(i.getMaxSuffixComponents(), 1);
- BOOST_REQUIRE_EQUAL(i.getPublisherPublicKeyLocator().getType(),
- static_cast<uint32_t>(KeyLocator::KeyLocator_Name));
- BOOST_REQUIRE_EQUAL(i.getPublisherPublicKeyLocator().getName(), "ndn:/test/key/locator");
- BOOST_REQUIRE_EQUAL(i.getChildSelector(), 1);
- BOOST_REQUIRE_EQUAL(i.getMustBeFresh(), false);
- BOOST_REQUIRE_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy");
- BOOST_REQUIRE_EQUAL(i.getNonce(), 1);
+ BOOST_CHECK_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
+ BOOST_CHECK_EQUAL(i.getScope(), 1);
+ BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds(1000));
+ BOOST_CHECK_EQUAL(i.getMinSuffixComponents(), 1);
+ BOOST_CHECK_EQUAL(i.getMaxSuffixComponents(), 1);
+ BOOST_CHECK_EQUAL(i.getPublisherPublicKeyLocator().getType(),
+ static_cast<uint32_t>(KeyLocator::KeyLocator_Name));
+ BOOST_CHECK_EQUAL(i.getPublisherPublicKeyLocator().getName(), "ndn:/test/key/locator");
+ BOOST_CHECK_EQUAL(i.getChildSelector(), 1);
+ BOOST_CHECK_EQUAL(i.getMustBeFresh(), false);
+ BOOST_CHECK_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy");
+ BOOST_CHECK_EQUAL(i.getNonce(), 1U);
}
-BOOST_AUTO_TEST_CASE (DecodeFromStream)
+BOOST_AUTO_TEST_CASE(DecodeFromStream)
{
- boost::iostreams::stream<boost::iostreams::array_source> is (reinterpret_cast<const char *>(Interest1), sizeof(Interest1));
+ boost::iostreams::stream<boost::iostreams::array_source> is(reinterpret_cast<const char *>(Interest1), sizeof(Interest1));
Block interestBlock(is);
ndn::Interest i;
BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock));
- BOOST_REQUIRE_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
- BOOST_REQUIRE_EQUAL(i.getScope(), 1);
- BOOST_REQUIRE_EQUAL(i.getInterestLifetime(), time::milliseconds(1000));
- BOOST_REQUIRE_EQUAL(i.getMinSuffixComponents(), 1);
- BOOST_REQUIRE_EQUAL(i.getMaxSuffixComponents(), 1);
- BOOST_REQUIRE_EQUAL(i.getChildSelector(), 1);
- BOOST_REQUIRE_EQUAL(i.getMustBeFresh(), false);
- BOOST_REQUIRE_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy");
- BOOST_REQUIRE_EQUAL(i.getNonce(), 1);
+ BOOST_CHECK_EQUAL(i.getName().toUri(), "/local/ndn/prefix");
+ BOOST_CHECK_EQUAL(i.getScope(), 1);
+ BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds(1000));
+ BOOST_CHECK_EQUAL(i.getMinSuffixComponents(), 1);
+ BOOST_CHECK_EQUAL(i.getMaxSuffixComponents(), 1);
+ BOOST_CHECK_EQUAL(i.getChildSelector(), 1);
+ BOOST_CHECK_EQUAL(i.getMustBeFresh(), false);
+ BOOST_CHECK_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy");
+ BOOST_CHECK_EQUAL(i.getNonce(), 1U);
}
-BOOST_AUTO_TEST_CASE (Encode)
+BOOST_AUTO_TEST_CASE(Encode)
{
ndn::Interest i(ndn::Name("/local/ndn/prefix"));
i.setScope(1);
@@ -125,7 +125,7 @@
const Block &wire = i.wireEncode();
- BOOST_CHECK_EQUAL_COLLECTIONS(Interest1, Interest1+sizeof(Interest1),
+ BOOST_CHECK_EQUAL_COLLECTIONS(Interest1, Interest1 + sizeof(Interest1),
wire.begin(), wire.end());
}
@@ -149,7 +149,7 @@
BOOST_CHECK_EQUAL(headerBlock.size(), 5);
BOOST_CHECK_EQUAL_COLLECTIONS(InterestWithLocalControlHeader,
- InterestWithLocalControlHeader+5,
+ InterestWithLocalControlHeader + 5,
headerBlock.begin(), headerBlock.end());
interest.setNonce(1000);
@@ -158,14 +158,14 @@
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5);
// only length should have changed
- BOOST_CHECK_EQUAL_COLLECTIONS(updatedHeaderBlock.begin()+2, updatedHeaderBlock.end(),
- headerBlock.begin()+2, headerBlock.end());
+ BOOST_CHECK_EQUAL_COLLECTIONS(updatedHeaderBlock.begin() + 2, updatedHeaderBlock.end(),
+ headerBlock.begin() + 2, headerBlock.end());
// updating IncomingFaceId that keeps the length
interest.setIncomingFaceId(100);
updatedHeaderBlock = interest.getLocalControlHeader().wireEncode(interest, true, true);
BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5);
- BOOST_CHECK_NE(*(updatedHeaderBlock.begin()+4), *(headerBlock.begin()+4));
+ BOOST_CHECK_NE(*(updatedHeaderBlock.begin() + 4), *(headerBlock.begin() + 4));
// updating IncomingFaceId that increases the length by 2
interest.setIncomingFaceId(1000);
@@ -191,14 +191,14 @@
}
-BOOST_AUTO_TEST_CASE (DecodeWithLocalHeader)
+BOOST_AUTO_TEST_CASE(DecodeWithLocalHeader)
{
Block wireBlock(InterestWithLocalControlHeader, sizeof(InterestWithLocalControlHeader));
const Block& payload = nfd::LocalControlHeader::getPayload(wireBlock);
BOOST_REQUIRE_NE(&payload, &wireBlock);
- BOOST_CHECK_EQUAL(payload.type(), (uint32_t)Tlv::Interest);
- BOOST_CHECK_EQUAL(wireBlock.type(), (uint32_t)tlv::nfd::LocalControlHeader);
+ BOOST_CHECK_EQUAL(payload.type(), static_cast<uint32_t>(Tlv::Interest));
+ BOOST_CHECK_EQUAL(wireBlock.type(), static_cast<uint32_t>(tlv::nfd::LocalControlHeader));
Interest interest(payload);
BOOST_CHECK(!interest.getLocalControlHeader().hasIncomingFaceId());
@@ -226,7 +226,7 @@
BOOST_CHECK_EQUAL(interest.getLocalControlHeader().wireEncode(interest, true, true).size(), 5);
}
-BOOST_AUTO_TEST_CASE (DecodeWithoutLocalHeader)
+BOOST_AUTO_TEST_CASE(DecodeWithoutLocalHeader)
{
Block wireBlock(InterestWithoutLocalControlHeader, sizeof(InterestWithoutLocalControlHeader));
const Block& payload = nfd::LocalControlHeader::getPayload(wireBlock);
diff --git a/tests/test-name.cpp b/tests/test-name.cpp
index 32e3a10..ba8aa96 100644
--- a/tests/test-name.cpp
+++ b/tests/test-name.cpp
@@ -4,10 +4,10 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "name.hpp"
+#include "boost-test.hpp"
+
namespace ndn {
BOOST_AUTO_TEST_SUITE(TestName)
@@ -25,7 +25,7 @@
const uint8_t Name1[] = {0x7, 0x7, // Name
0x8, 0x5, // NameComponent
0x6c, 0x6f, 0x63, 0x61, 0x6c};
-
+
const uint8_t Name2[] = {0x7, 0xc, // Name
0x8, 0x5, // NameComponent
0x6c, 0x6f, 0x63, 0x61, 0x6c,
@@ -61,11 +61,11 @@
// if (i != wire.begin())
// std::cout << ", ";
// std::cout << "0x" << static_cast<uint32_t>(*i);
-
+
// std::cout.flags(saveFlags);
// }
// std::cout << std::endl;
-
+
BOOST_CHECK_EQUAL_COLLECTIONS(TestName, TestName+sizeof(TestName),
wire.begin(), wire.end());
}
@@ -83,12 +83,12 @@
BOOST_AUTO_TEST_CASE(AppendsAndMultiEncode)
{
Name name("/local");
-
+
BOOST_CHECK_EQUAL_COLLECTIONS(name.wireEncode().begin(), name.wireEncode().end(),
Name1, Name1 + sizeof(Name1));
name.append("ndn");
-
+
BOOST_CHECK_EQUAL_COLLECTIONS(name.wireEncode().begin(), name.wireEncode().end(),
Name2, Name2 + sizeof(Name2));
@@ -100,14 +100,14 @@
BOOST_AUTO_TEST_CASE(AppendNumber)
{
Name name;
- for (int i = 0; i < 10; i++)
+ for (uint32_t i = 0; i < 10; i++)
{
name.appendNumber(i);
}
BOOST_CHECK_EQUAL(name.size(), 10);
- for (int i = 0; i < 10; i++)
+ for (uint32_t i = 0; i < 10; i++)
{
BOOST_CHECK_EQUAL(name[i].toNumber(), i);
}
diff --git a/tests/transport/dummy-face.hpp b/tests/transport/dummy-face.hpp
index 1ac3cc9..134eb72 100644
--- a/tests/transport/dummy-face.hpp
+++ b/tests/transport/dummy-face.hpp
@@ -1,10 +1,10 @@
/**
- * Copyright (C) 2013 Regents of the University of California.
+ * Copyright (C) 2013-2014 Regents of the University of California.
* See COPYING for copyright and distribution information.
*/
-#ifndef NDN_TESTS_DUMMY_FACE_HPP
-#define NDN_TESTS_DUMMY_FACE_HPP
+#ifndef NDN_TESTS_TRANSPORT_DUMMY_FACE_HPP
+#define NDN_TESTS_TRANSPORT_DUMMY_FACE_HPP
#include "face.hpp"
@@ -95,4 +95,5 @@
}
} // namespace ndn
-#endif // NDN_TESTS_DUMMY_FACE_HPP
+
+#endif // NDN_TESTS_TRANSPORT_DUMMY_FACE_HPP
diff --git a/tests/transport/test-unix-transport.cpp b/tests/transport/test-unix-transport.cpp
index ffb0494..535b63c 100644
--- a/tests/transport/test-unix-transport.cpp
+++ b/tests/transport/test-unix-transport.cpp
@@ -4,12 +4,11 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-#include <boost/test/output_test_stream.hpp>
-
#include "transport/unix-transport.hpp"
#include "util/config-file.hpp"
+#include "boost-test.hpp"
+
namespace ndn {
class UnixTransportFixture
@@ -63,4 +62,3 @@
BOOST_AUTO_TEST_SUITE_END()
} // namespace ndn
-
diff --git a/tests/util/test-config-file.cpp b/tests/util/test-config-file.cpp
index c091ccf..c431e19 100644
--- a/tests/util/test-config-file.cpp
+++ b/tests/util/test-config-file.cpp
@@ -4,12 +4,12 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "util/config-file.hpp"
#include <cstdlib>
+#include "boost-test.hpp"
+
namespace ndn {
class ConfigFileFixture
diff --git a/tests/util/test-io.cpp b/tests/util/test-io.cpp
index 1e8b0bd..c3c247b 100644
--- a/tests/util/test-io.cpp
+++ b/tests/util/test-io.cpp
@@ -3,11 +3,11 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "util/io.hpp"
#include "security/key-chain.hpp"
+#include "boost-test.hpp"
+
namespace ndn {
BOOST_AUTO_TEST_SUITE(TestIO)
diff --git a/tests/util/test-regex.cpp b/tests/util/test-regex.cpp
index b5d5903..86bad95 100644
--- a/tests/util/test-regex.cpp
+++ b/tests/util/test-regex.cpp
@@ -5,8 +5,6 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "util/regex/regex-backref-manager.hpp"
#include "util/regex/regex-component-matcher.hpp"
#include "util/regex/regex-component-set-matcher.hpp"
@@ -16,7 +14,7 @@
#include "util/regex/regex-top-matcher.hpp"
#include "util/regex.hpp"
-#include <iostream>
+#include "boost-test.hpp"
using namespace std;
namespace ndn {
@@ -58,11 +56,11 @@
BOOST_CHECK_EQUAL(res, true);
BOOST_CHECK_EQUAL(cm->getMatchResult ().size(), 1);
BOOST_CHECK_EQUAL(cm->getMatchResult ()[0].toEscapedString(), string("a"));
-
+
res = cm->match(Name("/a/b/"), 1, 1);
BOOST_CHECK_EQUAL(res, false);
BOOST_CHECK_EQUAL(cm->getMatchResult ().size(), 0);
-
+
res = cm->match(Name("/a/b/"), 0, 2);
BOOST_CHECK_EQUAL(res, false);
BOOST_CHECK_EQUAL(cm->getMatchResult ().size(), 0);
@@ -77,12 +75,12 @@
res = cm->match(Name("/a/b/d"), 2, 1);
BOOST_CHECK_EQUAL(res, false);
BOOST_CHECK_EQUAL(cm->getMatchResult ().size(), 0);
-
+
backRef = ptr_lib::make_shared<RegexBackrefManager>();
cm = ptr_lib::make_shared<RegexComponentSetMatcher>("[^<a><b><c>]", backRef);
res = cm->match(Name("/b/d"), 1, 1);
BOOST_CHECK_EQUAL(res, true);
- BOOST_CHECK_EQUAL(cm->getMatchResult ().size(), 1);
+ BOOST_CHECK_EQUAL(cm->getMatchResult ().size(), 1);
BOOST_CHECK_EQUAL(cm->getMatchResult ()[0].toEscapedString(), string("d"));
}
@@ -229,7 +227,7 @@
BOOST_CHECK_EQUAL(cm->getMatchResult ().size(), 0);
-
+
backRef = ptr_lib::make_shared<RegexBackrefManager>();
cm = ptr_lib::make_shared<RegexRepeatMatcher>("[<a><b>]{,2}", backRef, 8);
res = cm->match(Name("/a/b/a/b/e/"), 0, 3);
diff --git a/tests/util/test-scheduler.cpp b/tests/util/test-scheduler.cpp
index 66417da..01fb18c 100644
--- a/tests/util/test-scheduler.cpp
+++ b/tests/util/test-scheduler.cpp
@@ -6,7 +6,7 @@
#include "util/scheduler.hpp"
-#include <boost/test/unit_test.hpp>
+#include "boost-test.hpp"
namespace ndn {
diff --git a/tests/util/test-time.cpp b/tests/util/test-time.cpp
index 6351bb1..9a6bf1e 100644
--- a/tests/util/test-time.cpp
+++ b/tests/util/test-time.cpp
@@ -3,10 +3,10 @@
* See COPYING for copyright and distribution information.
*/
-#include <boost/test/unit_test.hpp>
-
#include "util/time.hpp"
+#include "boost-test.hpp"
+
namespace ndn {
BOOST_AUTO_TEST_SUITE(TestTime)
diff --git a/tests/wscript b/tests/wscript
index 6caa5f3..f5ebcc8 100644
--- a/tests/wscript
+++ b/tests/wscript
@@ -11,6 +11,7 @@
source=bld.path.ant_glob(['**/*.cpp'],
excl=['**/*-osx.cpp', '**/*-sqlite3.cpp']),
use='ndn-cpp-dev',
+ includes='.',
install_path=None,
)
diff --git a/tools/ndnsec-cert-gen.hpp b/tools/ndnsec-cert-gen.hpp
index 197cc6b..796c3ed 100644
--- a/tools/ndnsec-cert-gen.hpp
+++ b/tools/ndnsec-cert-gen.hpp
@@ -17,6 +17,7 @@
using boost::escaped_list_separator;
using namespace ndn;
+ using namespace ndn::time;
namespace po = boost::program_options;
std::string notBeforeStr;
@@ -97,27 +98,27 @@
it++;
}
- time::system_clock::TimePoint notBefore;
- time::system_clock::TimePoint notAfter;
+ system_clock::TimePoint notBefore;
+ system_clock::TimePoint notAfter;
if (vm.count("not-before") == 0)
{
- notBefore = time::system_clock::now();
+ notBefore = system_clock::now();
}
else
{
- notBefore = time::fromIsoString(notBeforeStr.substr(0, 8) + "T" +
- notBeforeStr.substr(8, 6));
+ notBefore = fromIsoString(notBeforeStr.substr(0, 8) + "T" +
+ notBeforeStr.substr(8, 6));
}
if (vm.count("not-after") == 0)
{
- notAfter = notBefore + time::days(365);
+ notAfter = notBefore + days(365);
}
else
{
- notAfter = time::fromIsoString(notAfterStr.substr(0, 8) + "T" +
- notAfterStr.substr(8, 6));
+ notAfter = fromIsoString(notAfterStr.substr(0, 8) + "T" +
+ notAfterStr.substr(8, 6));
if (notAfter < notBefore)
{