Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 60f8cc1 | 2018-05-10 22:05:21 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014-2018, Regents of the University of California. |
Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 6 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
| 7 | * |
| 8 | * ndn-tools 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, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * ndn-tools 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 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #ifndef NDN_TOOLS_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP |
| 21 | #define NDN_TOOLS_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP |
| 22 | |
| 23 | #include "tests/test-common.hpp" |
Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 24 | |
| 25 | namespace ndn { |
| 26 | namespace tests { |
| 27 | |
Junxiao Shi | 20b2297 | 2017-05-24 21:04:16 +0000 | [diff] [blame] | 28 | /** \brief a fixture providing an in-memory KeyChain |
Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 29 | */ |
| 30 | class IdentityManagementFixture |
| 31 | { |
| 32 | public: |
| 33 | IdentityManagementFixture(); |
| 34 | |
Junxiao Shi | 20b2297 | 2017-05-24 21:04:16 +0000 | [diff] [blame] | 35 | /** \brief deletes saved certificate files |
Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 36 | */ |
| 37 | ~IdentityManagementFixture(); |
| 38 | |
| 39 | /** \brief add identity |
| 40 | * \return whether successful |
| 41 | */ |
| 42 | bool |
Junxiao Shi | 20b2297 | 2017-05-24 21:04:16 +0000 | [diff] [blame] | 43 | addIdentity(const Name& identity, const KeyParams& params = KeyChain::getDefaultKeyParams()); |
Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 44 | |
| 45 | /** \brief save identity certificate to a file |
| 46 | * \param identity identity name |
| 47 | * \param filename file name, should be writable |
| 48 | * \param wantAdd if true, add new identity when necessary |
| 49 | * \return whether successful |
| 50 | */ |
| 51 | bool |
| 52 | saveIdentityCertificate(const Name& identity, const std::string& filename, bool wantAdd = false); |
| 53 | |
Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 54 | protected: |
| 55 | KeyChain m_keyChain; |
| 56 | |
| 57 | private: |
Davide Pesavento | 013de9b | 2016-09-01 12:06:56 +0000 | [diff] [blame] | 58 | std::vector<std::string> m_certFiles; |
| 59 | }; |
| 60 | |
| 61 | /** \brief convenience base class for inheriting from both UnitTestTimeFixture |
| 62 | * and IdentityManagementFixture |
| 63 | */ |
| 64 | class IdentityManagementTimeFixture : public UnitTestTimeFixture |
| 65 | , public IdentityManagementFixture |
| 66 | { |
| 67 | }; |
| 68 | |
| 69 | } // namespace tests |
| 70 | } // namespace ndn |
| 71 | |
| 72 | #endif // NDN_TOOLS_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP |