Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Davide Pesavento | 8663ed1 | 2022-07-23 03:04:27 -0400 | [diff] [blame] | 3 | * Copyright (c) 2012-2022 University of California, Los Angeles |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 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 | |
Davide Pesavento | 8663ed1 | 2022-07-23 03:04:27 -0400 | [diff] [blame] | 20 | #ifndef CHRONOSYNC_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP |
| 21 | #define CHRONOSYNC_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 22 | |
Davide Pesavento | 07684bc | 2021-02-07 20:09:28 -0500 | [diff] [blame] | 23 | #include "detail/common.hpp" |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 24 | |
| 25 | #include "unit-test-time-fixture.hpp" |
| 26 | |
Davide Pesavento | 8663ed1 | 2022-07-23 03:04:27 -0400 | [diff] [blame] | 27 | namespace ndn::tests { |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 28 | |
| 29 | /** \brief a fixture that cleans up KeyChain identities and certificate files upon destruction |
| 30 | */ |
| 31 | class IdentityManagementFixture |
| 32 | { |
| 33 | public: |
| 34 | IdentityManagementFixture(); |
| 35 | |
| 36 | /** \brief deletes saved certificate files |
| 37 | */ |
| 38 | ~IdentityManagementFixture(); |
| 39 | |
| 40 | /** \brief add identity |
| 41 | * \return whether successful |
| 42 | */ |
| 43 | bool |
| 44 | addIdentity(const Name& identity, |
| 45 | const ndn::KeyParams& params = ndn::KeyChain::getDefaultKeyParams()); |
| 46 | |
| 47 | /** \brief save identity certificate to a file |
| 48 | * \param identity identity name |
| 49 | * \param filename file name, should be writable |
| 50 | * \param wantAdd if true, add new identity when necessary |
| 51 | * \return whether successful |
| 52 | */ |
| 53 | bool |
| 54 | saveIdentityCertificate(const Name& identity, const std::string& filename, bool wantAdd = false); |
| 55 | |
| 56 | protected: |
| 57 | ndn::KeyChain m_keyChain; |
| 58 | |
| 59 | private: |
| 60 | std::vector<std::string> m_certFiles; |
| 61 | }; |
| 62 | |
| 63 | /** \brief convenience base class for inheriting from both UnitTestTimeFixture |
| 64 | * and IdentityManagementFixture |
| 65 | */ |
| 66 | class IdentityManagementTimeFixture : public UnitTestTimeFixture |
| 67 | , public IdentityManagementFixture |
| 68 | { |
| 69 | }; |
| 70 | |
Davide Pesavento | 8663ed1 | 2022-07-23 03:04:27 -0400 | [diff] [blame] | 71 | } // namespace ndn::tests |
Ashlesh Gawande | 08784d4 | 2017-09-06 23:40:21 -0500 | [diff] [blame] | 72 | |
Davide Pesavento | 8663ed1 | 2022-07-23 03:04:27 -0400 | [diff] [blame] | 73 | #endif // CHRONOSYNC_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP |