Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2024, The University of Memphis, |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 4 | * Regents of the University of California |
| 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 19 | */ |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 20 | |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 21 | #include "tests/test-common.hpp" |
| 22 | |
| 23 | #include <ndn-cxx/mgmt/nfd/control-parameters.hpp> |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 24 | |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame] | 25 | namespace nlsr::tests { |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 26 | |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 27 | std::shared_ptr<ndn::Data> |
| 28 | makeData(const ndn::Name& name) |
| 29 | { |
| 30 | auto data = std::make_shared<ndn::Data>(name); |
| 31 | return signData(data); |
| 32 | } |
| 33 | |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 34 | ndn::Data& |
| 35 | signData(ndn::Data& data) |
| 36 | { |
Davide Pesavento | 8de8a8b | 2022-05-12 01:26:43 -0400 | [diff] [blame] | 37 | data.setSignatureInfo(ndn::SignatureInfo(ndn::tlv::NullSignature)); |
| 38 | data.setSignatureValue(std::make_shared<ndn::Buffer>()); |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 39 | data.wireEncode(); |
Nick Gordon | d5c1a37 | 2016-10-31 13:56:23 -0500 | [diff] [blame] | 40 | return data; |
| 41 | } |
| 42 | |
Saurab Dulal | 427e012 | 2019-11-28 11:58:02 -0600 | [diff] [blame] | 43 | void |
Junxiao Shi | 43f37a0 | 2023-08-09 00:09:00 +0000 | [diff] [blame] | 44 | checkPrefixRegistered(const ndn::DummyClientFace& face, const ndn::Name& prefix) |
Saurab Dulal | 427e012 | 2019-11-28 11:58:02 -0600 | [diff] [blame] | 45 | { |
| 46 | bool registerCommandEmitted = false; |
| 47 | for (const auto& interest : face.sentInterests) { |
Davide Pesavento | 69904fc | 2022-10-14 09:45:34 -0400 | [diff] [blame] | 48 | const auto& name = interest.getName(); |
| 49 | if (name.size() > 4 && name[3] == ndn::name::Component("register")) { |
| 50 | ndn::nfd::ControlParameters params(name[4].blockFromValue()); |
Saurab Dulal | 427e012 | 2019-11-28 11:58:02 -0600 | [diff] [blame] | 51 | if (params.getName() == prefix) { |
| 52 | registerCommandEmitted = true; |
| 53 | break; |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | BOOST_CHECK(registerCommandEmitted); |
| 58 | } |
| 59 | |
Davide Pesavento | 288141a | 2024-02-13 17:30:35 -0500 | [diff] [blame] | 60 | } // namespace nlsr::tests |