Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 2 | /* |
Davide Pesavento | 47ce2ee | 2023-05-09 01:33:33 -0400 | [diff] [blame] | 3 | * Copyright (c) 2013-2023 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 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 22 | #include "ndn-cxx/mgmt/nfd/command-options.hpp" |
| 23 | #include "ndn-cxx/security/signing-helpers.hpp" |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 24 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 25 | #include "tests/boost-test.hpp" |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 26 | |
Davide Pesavento | 47ce2ee | 2023-05-09 01:33:33 -0400 | [diff] [blame] | 27 | namespace ndn::tests { |
| 28 | |
| 29 | using namespace ndn::nfd; |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 30 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 31 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 32 | BOOST_AUTO_TEST_SUITE(Nfd) |
| 33 | BOOST_AUTO_TEST_SUITE(TestCommandOptions) |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 34 | |
| 35 | BOOST_AUTO_TEST_CASE(Timeout) |
| 36 | { |
| 37 | CommandOptions co; |
| 38 | BOOST_CHECK_EQUAL(co.getTimeout(), CommandOptions::DEFAULT_TIMEOUT); |
| 39 | |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 40 | co.setTimeout(7414_ms); |
| 41 | BOOST_CHECK_EQUAL(co.getTimeout(), 7414_ms); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 42 | |
| 43 | BOOST_CHECK_THROW(co.setTimeout(time::milliseconds::zero()), std::out_of_range); |
| 44 | BOOST_CHECK_THROW(co.setTimeout(time::milliseconds(-1)), std::out_of_range); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 45 | BOOST_CHECK_EQUAL(co.getTimeout(), 7414_ms); // unchanged after throw |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 46 | |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 47 | co.setTimeout(1_ms); |
| 48 | BOOST_CHECK_EQUAL(co.getTimeout(), 1_ms); |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | BOOST_AUTO_TEST_CASE(Prefix) |
| 52 | { |
| 53 | CommandOptions co; |
| 54 | BOOST_CHECK_EQUAL(co.getPrefix(), CommandOptions::DEFAULT_PREFIX); |
| 55 | |
| 56 | co.setPrefix(Name()); // empty Name is okay |
| 57 | BOOST_CHECK_EQUAL(co.getPrefix(), Name()); |
| 58 | |
| 59 | co.setPrefix("ndn:/localhop/net/example/nfd"); |
| 60 | BOOST_CHECK_EQUAL(co.getPrefix(), Name("ndn:/localhop/net/example/nfd")); |
| 61 | } |
| 62 | |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 63 | BOOST_AUTO_TEST_CASE(SigningInfo) |
| 64 | { |
| 65 | CommandOptions co; |
| 66 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_NULL); |
| 67 | |
| 68 | co.setSigningInfo(signingByIdentity("ndn:/tmp/identity")); |
| 69 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerType(), security::SigningInfo::SIGNER_TYPE_ID); |
| 70 | BOOST_CHECK_EQUAL(co.getSigningInfo().getSignerName(), "ndn:/tmp/identity"); |
| 71 | } |
| 72 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 73 | BOOST_AUTO_TEST_SUITE_END() // TestCommandOptions |
| 74 | BOOST_AUTO_TEST_SUITE_END() // Nfd |
| 75 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
Junxiao Shi | 0eba1aa | 2014-10-25 09:54:08 -0700 | [diff] [blame] | 76 | |
Davide Pesavento | 47ce2ee | 2023-05-09 01:33:33 -0400 | [diff] [blame] | 77 | } // namespace ndn::tests |