blob: 2776eb0ec3544247e620c8e05a9ee4db500514b8 [file] [log] [blame]
Ashlesh Gawande08784d42017-09-06 23:40:21 -05001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012-2017 University of California, Los Angeles
4 *
5 * This file is part of ChronoSync, synchronization library for distributed realtime
6 * applications for NDN.
7 *
8 * ChronoSync is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation, either
10 * version 3 of the License, or (at your option) any later version.
11 *
12 * ChronoSync is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ChronoSync, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
21#define NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
22
23#include "common.hpp"
24
25#include "unit-test-time-fixture.hpp"
26
27namespace ndn {
28namespace tests {
29
30/** \brief a fixture that cleans up KeyChain identities and certificate files upon destruction
31 */
32class IdentityManagementFixture
33{
34public:
35 IdentityManagementFixture();
36
37 /** \brief deletes saved certificate files
38 */
39 ~IdentityManagementFixture();
40
41 /** \brief add identity
42 * \return whether successful
43 */
44 bool
45 addIdentity(const Name& identity,
46 const ndn::KeyParams& params = ndn::KeyChain::getDefaultKeyParams());
47
48 /** \brief save identity certificate to a file
49 * \param identity identity name
50 * \param filename file name, should be writable
51 * \param wantAdd if true, add new identity when necessary
52 * \return whether successful
53 */
54 bool
55 saveIdentityCertificate(const Name& identity, const std::string& filename, bool wantAdd = false);
56
57protected:
58 ndn::KeyChain m_keyChain;
59
60private:
61 std::vector<std::string> m_certFiles;
62};
63
64/** \brief convenience base class for inheriting from both UnitTestTimeFixture
65 * and IdentityManagementFixture
66 */
67class IdentityManagementTimeFixture : public UnitTestTimeFixture
68 , public IdentityManagementFixture
69{
70};
71
72} // namespace tests
73} // namespace ndn
74
75#endif // NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP