blob: 1e8b0bd80d0a10113d080b22383ae5d80d3f90e0 [file] [log] [blame]
/**
* Copyright (C) 2013 Regents of the University of California.
* See COPYING for copyright and distribution information.
*/
#include <boost/test/unit_test.hpp>
#include "util/io.hpp"
#include "security/key-chain.hpp"
namespace ndn {
BOOST_AUTO_TEST_SUITE(TestIO)
BOOST_AUTO_TEST_CASE (Basic)
{
KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keychain;
Name identity("/TestIO/Basic");
identity.appendVersion();
Name certName;
BOOST_REQUIRE_NO_THROW(certName = keychain.createIdentity(identity));
shared_ptr<IdentityCertificate> idCert;
BOOST_REQUIRE_NO_THROW(idCert = keychain.getCertificate(certName));
std::string file("/tmp/TestIO-Basic");
io::save(*idCert, file);
shared_ptr<IdentityCertificate> readCert = io::load<IdentityCertificate>(file);
BOOST_CHECK(static_cast<bool>(readCert));
BOOST_CHECK(idCert->getName() == readCert->getName());
keychain.deleteIdentity(identity);
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace ndn