Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef VALIDATION_COMMON_HPP |
| 8 | #define VALIDATION_COMMON_HPP |
| 9 | |
| 10 | #include <ndn-cpp-dev/util/command-interest-generator.hpp> |
| 11 | |
| 12 | namespace nfd { |
| 13 | namespace tests { |
| 14 | |
| 15 | // class ValidatedManagementFixture |
| 16 | // { |
| 17 | // public: |
| 18 | // ValidatedManagementFixture() |
| 19 | // : m_validator(make_shared<ndn::CommandInterestValidator>()) |
| 20 | // { |
| 21 | // } |
| 22 | |
| 23 | // virtual |
| 24 | // ~ValidatedManagementFixture() |
| 25 | // { |
| 26 | // } |
| 27 | |
| 28 | // protected: |
| 29 | // shared_ptr<ndn::CommandInterestValidator> m_validator; |
| 30 | // }; |
| 31 | |
| 32 | |
| 33 | template<typename T> |
| 34 | class CommandFixture : public T |
| 35 | { |
| 36 | public: |
| 37 | virtual |
| 38 | ~CommandFixture() |
| 39 | { |
| 40 | m_keys.deleteIdentity(m_identityName); |
| 41 | |
| 42 | } |
| 43 | |
| 44 | void |
| 45 | generateCommand(Interest& interest) |
| 46 | { |
| 47 | m_generator.generateWithIdentity(interest, m_identityName); |
| 48 | } |
| 49 | |
| 50 | const Name& |
| 51 | getIdentityName() const |
| 52 | { |
| 53 | return m_identityName; |
| 54 | } |
| 55 | |
| 56 | protected: |
| 57 | CommandFixture() |
| 58 | : m_identityName("/unit-test/CommandFixture/id"), |
| 59 | m_certificate(m_keys.getCertificate(m_keys.createIdentity(m_identityName))) |
| 60 | { |
| 61 | |
| 62 | } |
| 63 | |
| 64 | protected: |
| 65 | ndn::KeyChain m_keys; |
| 66 | const Name m_identityName; |
| 67 | shared_ptr<ndn::IdentityCertificate> m_certificate; |
| 68 | ndn::CommandInterestGenerator m_generator; |
| 69 | }; |
| 70 | |
| 71 | template <typename T> |
| 72 | class UnauthorizedCommandFixture : public CommandFixture<T> |
| 73 | { |
| 74 | public: |
| 75 | UnauthorizedCommandFixture() |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | virtual |
| 80 | ~UnauthorizedCommandFixture() |
| 81 | { |
| 82 | } |
| 83 | }; |
| 84 | |
| 85 | } //namespace tests |
| 86 | } // namespace nfd |
| 87 | |
| 88 | #endif // VALIDATION_COMMON_HPP |