Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2015 Regents of the University of California. |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 20 | */ |
| 21 | |
| 22 | #include "management/nfd-command-options.hpp" |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 23 | #include "security/signing-helpers.hpp" |
| 24 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 25 | #include "boost-test.hpp" |
| 26 | |
| 27 | namespace ndn { |
| 28 | namespace nfd { |
| 29 | namespace tests { |
| 30 | |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 31 | BOOST_AUTO_TEST_SUITE(ManagementNfdCommandOptions) |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 32 | |
| 33 | BOOST_AUTO_TEST_CASE(Timeout) |
| 34 | { |
| 35 | CommandOptions co; |
| 36 | BOOST_CHECK_EQUAL(co.getTimeout(), CommandOptions::DEFAULT_TIMEOUT); |
| 37 | |
| 38 | co.setTimeout(time::milliseconds(7414)); |
| 39 | BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414)); |
| 40 | |
| 41 | BOOST_CHECK_THROW(co.setTimeout(time::milliseconds::zero()), std::out_of_range); |
| 42 | BOOST_CHECK_THROW(co.setTimeout(time::milliseconds(-1)), std::out_of_range); |
| 43 | BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(7414)); // unchanged after throw |
| 44 | |
| 45 | co.setTimeout(time::milliseconds(1)); |
| 46 | BOOST_CHECK_EQUAL(co.getTimeout(), time::milliseconds(1)); |
| 47 | } |
| 48 | |
| 49 | BOOST_AUTO_TEST_CASE(Prefix) |
| 50 | { |
| 51 | CommandOptions co; |
| 52 | BOOST_CHECK_EQUAL(co.getPrefix(), CommandOptions::DEFAULT_PREFIX); |
| 53 | |
| 54 | co.setPrefix(Name()); // empty Name is okay |
| 55 | BOOST_CHECK_EQUAL(co.getPrefix(), Name()); |
| 56 | |
| 57 | co.setPrefix("ndn:/localhop/net/example/nfd"); |
| 58 | BOOST_CHECK_EQUAL(co.getPrefix(), Name("ndn:/localhop/net/example/nfd")); |
| 59 | } |
| 60 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 61 | BOOST_AUTO_TEST_CASE(SigningInfo) |
| 62 | { |
| 63 | CommandOptions co; |
| 64 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_NULL); |
| 65 | |
| 66 | co.setSigningInfo(signingByIdentity("ndn:/tmp/identity")); |
| 67 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_ID); |
| 68 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerName(), "ndn:/tmp/identity"); |
| 69 | } |
| 70 | |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 71 | BOOST_AUTO_TEST_SUITE_END() |
| 72 | |
| 73 | } // namespace tests |
| 74 | } // namespace nfd |
| 75 | } // namespace ndn |