blob: 1e8b0bd80d0a10113d080b22383ae5d80d3f90e0 [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
Alexander Afanasyevaa0e7da2014-03-17 14:37:33 -070019 Name identity("/TestIO/Basic");
20 identity.appendVersion();
21
Yingdi Yuf50098d2014-02-26 14:26:29 -080022 Name certName;
23 BOOST_REQUIRE_NO_THROW(certName = keychain.createIdentity(identity));
24 shared_ptr<IdentityCertificate> idCert;
25 BOOST_REQUIRE_NO_THROW(idCert = keychain.getCertificate(certName));
26
27 std::string file("/tmp/TestIO-Basic");
28 io::save(*idCert, file);
29 shared_ptr<IdentityCertificate> readCert = io::load<IdentityCertificate>(file);
30
31 BOOST_CHECK(static_cast<bool>(readCert));
32 BOOST_CHECK(idCert->getName() == readCert->getName());
33 keychain.deleteIdentity(identity);
34}
35
36BOOST_AUTO_TEST_SUITE_END()
37
38} // namespace ndn