blob: f7d74b184c8e2ecf3b69a982cd51669e588706b7 [file] [log] [blame]
Junxiao Shi0eba1aa2014-10-25 09:54:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento0f830802018-01-16 23:58:58 -05002/*
Davide Pesavento47ce2ee2023-05-09 01:33:33 -04003 * Copyright (c) 2013-2023 Regents of the University of California.
Junxiao Shi0eba1aa2014-10-25 09:54:08 -07004 *
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 Pesavento7e780642018-11-24 15:51:34 -050022#include "ndn-cxx/mgmt/nfd/command-options.hpp"
23#include "ndn-cxx/security/signing-helpers.hpp"
Junxiao Shic6acc7a2015-06-23 10:03:56 -070024
Davide Pesavento7e780642018-11-24 15:51:34 -050025#include "tests/boost-test.hpp"
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070026
Davide Pesavento47ce2ee2023-05-09 01:33:33 -040027namespace ndn::tests {
28
29using namespace ndn::nfd;
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070030
Junxiao Shi7357ef22016-09-07 02:39:37 +000031BOOST_AUTO_TEST_SUITE(Mgmt)
32BOOST_AUTO_TEST_SUITE(Nfd)
33BOOST_AUTO_TEST_SUITE(TestCommandOptions)
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070034
35BOOST_AUTO_TEST_CASE(Timeout)
36{
37 CommandOptions co;
38 BOOST_CHECK_EQUAL(co.getTimeout(), CommandOptions::DEFAULT_TIMEOUT);
39
Davide Pesavento0f830802018-01-16 23:58:58 -050040 co.setTimeout(7414_ms);
41 BOOST_CHECK_EQUAL(co.getTimeout(), 7414_ms);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070042
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 Pesavento0f830802018-01-16 23:58:58 -050045 BOOST_CHECK_EQUAL(co.getTimeout(), 7414_ms); // unchanged after throw
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070046
Davide Pesavento0f830802018-01-16 23:58:58 -050047 co.setTimeout(1_ms);
48 BOOST_CHECK_EQUAL(co.getTimeout(), 1_ms);
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070049}
50
51BOOST_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 Shic6acc7a2015-06-23 10:03:56 -070063BOOST_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 Shi7357ef22016-09-07 02:39:37 +000073BOOST_AUTO_TEST_SUITE_END() // TestCommandOptions
74BOOST_AUTO_TEST_SUITE_END() // Nfd
75BOOST_AUTO_TEST_SUITE_END() // Mgmt
Junxiao Shi0eba1aa2014-10-25 09:54:08 -070076
Davide Pesavento47ce2ee2023-05-09 01:33:33 -040077} // namespace ndn::tests