blob: acbdc385c1fb27708ffc361e532e0830fe43e040 [file] [log] [blame]
Yingdi Yuf50098d2014-02-26 14:26:29 -08001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * See COPYING for copyright and distribution information.
4 */
5
6#include <boost/test/unit_test.hpp>
7
8#include "util/io.hpp"
9#include "security/key-chain.hpp"
10
11namespace ndn {
12
13BOOST_AUTO_TEST_SUITE(TestIO)
14
15BOOST_AUTO_TEST_CASE (Basic)
16{
17 KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keychain;
18
19 Name identity("/TestIO/Basic/" + boost::lexical_cast<std::string>(time::now()));
20 Name certName;
21 BOOST_REQUIRE_NO_THROW(certName = keychain.createIdentity(identity));
22 shared_ptr<IdentityCertificate> idCert;
23 BOOST_REQUIRE_NO_THROW(idCert = keychain.getCertificate(certName));
24
25 std::string file("/tmp/TestIO-Basic");
26 io::save(*idCert, file);
27 shared_ptr<IdentityCertificate> readCert = io::load<IdentityCertificate>(file);
28
29 BOOST_CHECK(static_cast<bool>(readCert));
30 BOOST_CHECK(idCert->getName() == readCert->getName());
31 keychain.deleteIdentity(identity);
32}
33
34BOOST_AUTO_TEST_SUITE_END()
35
36} // namespace ndn