Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014-2016, Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 26 | #ifndef NFD_TESTS_NFD_MGMT_NFD_MANAGER_COMMON_FIXTURE_HPP |
| 27 | #define NFD_TESTS_NFD_MGMT_NFD_MANAGER_COMMON_FIXTURE_HPP |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 28 | |
| 29 | #include "manager-common-fixture.hpp" |
| 30 | #include "fw/forwarder.hpp" |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 31 | #include "mgmt/command-authenticator.hpp" |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 32 | |
| 33 | namespace nfd { |
| 34 | namespace tests { |
| 35 | |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 36 | /** \brief base fixture for testing an NFD Manager |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 37 | */ |
| 38 | class NfdManagerCommonFixture : public ManagerCommonFixture |
| 39 | { |
| 40 | public: |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 41 | NfdManagerCommonFixture(); |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 42 | |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 43 | /** \brief add /localhost/nfd as a top prefix to the dispatcher |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 44 | */ |
| 45 | void |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 46 | setTopPrefix(); |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 47 | |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 48 | /** \brief grant m_identityName privilege to sign commands for the management module |
| 49 | */ |
| 50 | void |
| 51 | setPrivilege(const std::string& privilege); |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 52 | |
| 53 | protected: |
| 54 | Forwarder m_forwarder; |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 55 | shared_ptr<CommandAuthenticator> m_authenticator; |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 56 | }; |
| 57 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 58 | class CommandSuccess |
| 59 | { |
| 60 | public: |
| 61 | ControlResponse |
| 62 | getExpected() |
| 63 | { |
| 64 | return ControlResponse() |
| 65 | .setCode(200) |
| 66 | .setText("OK"); |
| 67 | } |
| 68 | }; |
| 69 | |
| 70 | template<int CODE> |
| 71 | class CommandFailure |
| 72 | { |
| 73 | public: |
| 74 | ControlResponse |
| 75 | getExpected() |
| 76 | { |
| 77 | return ControlResponse() |
| 78 | .setCode(CODE); |
| 79 | // error description should not be checked |
| 80 | } |
| 81 | }; |
| 82 | |
Yanbiao Li | df846e5 | 2016-01-30 21:53:47 -0800 | [diff] [blame] | 83 | } // namespace tests |
| 84 | } // namespace nfd |
| 85 | |
Junxiao Shi | 9ddf1b5 | 2016-08-22 03:58:55 +0000 | [diff] [blame] | 86 | #endif // NFD_TESTS_NFD_MGMT_NFD_MANAGER_COMMON_FIXTURE_HPP |