Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 2 | /* |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013-2022 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 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. |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 20 | */ |
| 21 | |
Davide Pesavento | 7e78064 | 2018-11-24 15:51:34 -0500 | [diff] [blame] | 22 | #include "ndn-cxx/interest.hpp" |
| 23 | #include "ndn-cxx/data.hpp" |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 24 | |
Davide Pesavento | 4c1ad4c | 2020-11-16 21:12:02 -0500 | [diff] [blame] | 25 | #include "tests/test-common.hpp" |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 26 | |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 27 | namespace ndn { |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 28 | namespace tests { |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 29 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 30 | BOOST_AUTO_TEST_SUITE(TestInterest) |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 31 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 32 | class DisableAutoCheckParametersDigest |
| 33 | { |
| 34 | public: |
| 35 | DisableAutoCheckParametersDigest() |
| 36 | : m_saved(Interest::getAutoCheckParametersDigest()) |
| 37 | { |
| 38 | Interest::setAutoCheckParametersDigest(false); |
| 39 | } |
| 40 | |
| 41 | ~DisableAutoCheckParametersDigest() |
| 42 | { |
| 43 | Interest::setAutoCheckParametersDigest(m_saved); |
| 44 | } |
| 45 | |
| 46 | private: |
| 47 | bool m_saved; |
| 48 | }; |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 49 | |
| 50 | BOOST_AUTO_TEST_CASE(DefaultConstructor) |
| 51 | { |
| 52 | Interest i; |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 53 | BOOST_CHECK_EQUAL(i.hasWire(), false); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 54 | BOOST_CHECK_EQUAL(i.getName(), "/"); |
Davide Pesavento | 478d338 | 2021-03-17 12:46:08 -0400 | [diff] [blame] | 55 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), false); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 56 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), false); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 57 | BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); |
| 58 | BOOST_CHECK_EQUAL(i.hasNonce(), false); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 59 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 60 | BOOST_CHECK(i.getHopLimit() == nullopt); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 61 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); |
| 62 | BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); |
| 63 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 64 | BOOST_CHECK(i.getSignatureInfo() == nullopt); |
| 65 | BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); |
| 66 | BOOST_CHECK_EQUAL(i.isSigned(), false); |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 67 | } |
| 68 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 69 | BOOST_AUTO_TEST_SUITE(Encode) |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 70 | |
| 71 | BOOST_AUTO_TEST_CASE(Basic) |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 72 | { |
| 73 | const uint8_t WIRE[] = { |
| 74 | 0x05, 0x1c, // Interest |
| 75 | 0x07, 0x14, // Name |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 76 | 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, // GenericNameComponent |
| 77 | 0x08, 0x03, 0x6e, 0x64, 0x6e, // GenericNameComponent |
| 78 | 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, // GenericNameComponent |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 79 | 0x0a, 0x04, // Nonce |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 80 | 0x01, 0x02, 0x03, 0x04, |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 81 | }; |
| 82 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 83 | Interest i1; |
| 84 | i1.setName("/local/ndn/prefix"); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 85 | i1.setNonce(0x01020304); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 86 | BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true); |
| 87 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 88 | Block wire1 = i1.wireEncode(); |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 89 | BOOST_TEST(wire1 == WIRE, boost::test_tools::per_element()); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 90 | |
| 91 | Interest i2(wire1); |
| 92 | BOOST_CHECK_EQUAL(i2.getName(), "/local/ndn/prefix"); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 93 | BOOST_CHECK_EQUAL(i2.getCanBePrefix(), false); |
| 94 | BOOST_CHECK_EQUAL(i2.getMustBeFresh(), false); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 95 | BOOST_CHECK_EQUAL(i2.getForwardingHint().empty(), true); |
Davide Pesavento | 835f027 | 2019-09-21 13:18:24 -0400 | [diff] [blame] | 96 | BOOST_CHECK_EQUAL(i2.hasNonce(), true); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 97 | BOOST_CHECK_EQUAL(i2.getNonce(), 0x01020304); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 98 | BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 99 | BOOST_CHECK(i2.getHopLimit() == nullopt); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 100 | BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), false); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 101 | BOOST_CHECK_EQUAL(i2.getApplicationParameters().isValid(), false); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 102 | BOOST_CHECK(i2.getSignatureInfo() == nullopt); |
| 103 | BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false); |
| 104 | BOOST_CHECK_EQUAL(i2.isSigned(), false); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 107 | BOOST_AUTO_TEST_CASE(WithParameters) |
| 108 | { |
| 109 | const uint8_t WIRE[] = { |
| 110 | 0x05, 0x44, // Interest |
| 111 | 0x07, 0x36, // Name |
| 112 | 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, // GenericNameComponent |
| 113 | 0x08, 0x03, 0x6e, 0x64, 0x6e, // GenericNameComponent |
| 114 | 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, // GenericNameComponent |
| 115 | 0x02, 0x20, // ParametersSha256DigestComponent |
| 116 | 0xff, 0x91, 0x00, 0xe0, 0x4e, 0xaa, 0xdc, 0xf3, 0x06, 0x74, 0xd9, 0x80, |
| 117 | 0x26, 0xa0, 0x51, 0xba, 0x25, 0xf5, 0x6b, 0x69, 0xbf, 0xa0, 0x26, 0xdc, |
| 118 | 0xcc, 0xd7, 0x2c, 0x6e, 0xa0, 0xf7, 0x31, 0x5a, |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 119 | 0x0a, 0x04, // Nonce |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 120 | 0x00, 0x00, 0x00, 0x01, |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 121 | 0x24, 0x04, // ApplicationParameters |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 122 | 0xc0, 0xc1, 0xc2, 0xc3 |
| 123 | }; |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 124 | |
| 125 | Interest i1; |
| 126 | i1.setName("/local/ndn/prefix"); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 127 | i1.setNonce(0x1); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 128 | i1.setApplicationParameters("2404C0C1C2C3"_block); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 129 | BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true); |
| 130 | |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 131 | Block wire1 = i1.wireEncode(); |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 132 | BOOST_TEST(wire1 == WIRE, boost::test_tools::per_element()); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 133 | |
| 134 | Interest i2(wire1); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 135 | BOOST_CHECK_EQUAL(i2.getName(), |
| 136 | "/local/ndn/prefix/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a"); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 137 | BOOST_CHECK_EQUAL(i2.getCanBePrefix(), false); |
| 138 | BOOST_CHECK_EQUAL(i2.getMustBeFresh(), false); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 139 | BOOST_CHECK_EQUAL(i2.getForwardingHint().empty(), true); |
Davide Pesavento | 835f027 | 2019-09-21 13:18:24 -0400 | [diff] [blame] | 140 | BOOST_CHECK_EQUAL(i2.hasNonce(), true); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 141 | BOOST_CHECK_EQUAL(i2.getNonce(), 0x1); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 142 | BOOST_CHECK_EQUAL(i2.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 143 | BOOST_CHECK(i2.getHopLimit() == nullopt); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 144 | BOOST_CHECK_EQUAL(i2.hasApplicationParameters(), true); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 145 | BOOST_CHECK_EQUAL(i2.getApplicationParameters(), "2404C0C1C2C3"_block); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 146 | BOOST_CHECK(i2.getSignatureInfo() == nullopt); |
| 147 | BOOST_CHECK_EQUAL(i2.getSignatureValue().isValid(), false); |
| 148 | BOOST_CHECK_EQUAL(i2.isSigned(), false); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 151 | BOOST_AUTO_TEST_CASE(Full) |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 152 | { |
| 153 | const uint8_t WIRE[] = { |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 154 | 0x05, 0x56, // Interest |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 155 | 0x07, 0x36, // Name |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 156 | 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, // GenericNameComponent |
| 157 | 0x08, 0x03, 0x6e, 0x64, 0x6e, // GenericNameComponent |
| 158 | 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, // GenericNameComponent |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 159 | 0x02, 0x20, // ParametersSha256DigestComponent |
| 160 | 0xff, 0x91, 0x00, 0xe0, 0x4e, 0xaa, 0xdc, 0xf3, 0x06, 0x74, 0xd9, 0x80, |
| 161 | 0x26, 0xa0, 0x51, 0xba, 0x25, 0xf5, 0x6b, 0x69, 0xbf, 0xa0, 0x26, 0xdc, |
| 162 | 0xcc, 0xd7, 0x2c, 0x6e, 0xa0, 0xf7, 0x31, 0x5a, |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 163 | 0x21, 0x00, // CanBePrefix |
| 164 | 0x12, 0x00, // MustBeFresh |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 165 | 0x1e, 0x05, // ForwardingHint |
| 166 | 0x07, 0x03, 0x08, 0x01, 0x48, |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 167 | 0x0a, 0x04, // Nonce |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 168 | 0x4c, 0x1e, 0xcb, 0x4a, |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 169 | 0x0c, 0x02, // InterestLifetime |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 170 | 0x76, 0xa1, |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 171 | 0x22, 0x01, // HopLimit |
| 172 | 0xdc, |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 173 | 0x24, 0x04, // ApplicationParameters |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 174 | 0xc0, 0xc1, 0xc2, 0xc3 |
| 175 | }; |
| 176 | |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 177 | Interest i1; |
| 178 | i1.setName("/local/ndn/prefix"); |
| 179 | i1.setMustBeFresh(true); |
| 180 | i1.setCanBePrefix(true); |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 181 | i1.setForwardingHint({"/H"}); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 182 | i1.setNonce(0x4c1ecb4a); |
| 183 | i1.setInterestLifetime(30369_ms); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 184 | i1.setHopLimit(220); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 185 | i1.setApplicationParameters("2404C0C1C2C3"_block); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 186 | BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true); |
| 187 | |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 188 | Block wire1 = i1.wireEncode(); |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 189 | BOOST_TEST(wire1 == WIRE, boost::test_tools::per_element()); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 190 | |
| 191 | Interest i2(wire1); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 192 | BOOST_CHECK_EQUAL(i2.getName(), |
| 193 | "/local/ndn/prefix/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a"); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 194 | BOOST_CHECK_EQUAL(i2.getCanBePrefix(), true); |
| 195 | BOOST_CHECK_EQUAL(i2.getMustBeFresh(), true); |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 196 | BOOST_TEST(i2.getForwardingHint() == std::vector<Name>({"/H"}), boost::test_tools::per_element()); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 197 | BOOST_CHECK_EQUAL(i2.hasNonce(), true); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 198 | BOOST_CHECK_EQUAL(i2.getNonce(), 0x4c1ecb4a); |
| 199 | BOOST_CHECK_EQUAL(i2.getInterestLifetime(), 30369_ms); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 200 | BOOST_CHECK_EQUAL(*i2.getHopLimit(), 220); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 201 | BOOST_CHECK_EQUAL(i2.getApplicationParameters(), "2404C0C1C2C3"_block); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 202 | } |
| 203 | |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 204 | BOOST_AUTO_TEST_CASE(Signed) |
| 205 | { |
| 206 | const uint8_t WIRE[] = { |
| 207 | 0x05, 0x77, // Interest |
| 208 | 0x07, 0x36, // Name |
| 209 | 0x08, 0x05, // GenericNameComponent |
| 210 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 211 | 0x08, 0x03, // GenericNameComponent |
| 212 | 0x6e, 0x64, 0x6e, |
| 213 | 0x08, 0x06, // GenericNameComponent |
| 214 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 215 | 0x02, 0x20, // ParametersSha256DigestComponent |
| 216 | 0x6f, 0x29, 0x58, 0x60, 0x53, 0xee, 0x9f, 0xcc, |
| 217 | 0xd8, 0xa4, 0x22, 0x12, 0x29, 0x25, 0x28, 0x7c, |
| 218 | 0x0a, 0x18, 0x43, 0x5f, 0x40, 0x74, 0xc4, 0x0a, |
| 219 | 0xbb, 0x0d, 0x5b, 0x30, 0xe4, 0xaa, 0x62, 0x20, |
| 220 | 0x12, 0x00, // MustBeFresh |
| 221 | 0x0a, 0x04, // Nonce |
| 222 | 0x4c, 0x1e, 0xcb, 0x4a, |
| 223 | 0x24, 0x04, // ApplicationParameters |
| 224 | 0xc0, 0xc1, 0xc2, 0xc3, |
| 225 | 0x2c, 0x0d, // InterestSignatureInfo |
| 226 | 0x1b, 0x01, // SignatureType |
| 227 | 0x00, |
| 228 | 0x26, 0x08, // SignatureNonce |
| 229 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 230 | 0x2e, 0x20, // InterestSignatureValue |
| 231 | 0x12, 0x47, 0x1a, 0xe0, 0xf8, 0x72, 0x3a, 0xc1, |
| 232 | 0x15, 0x6c, 0x37, 0x0a, 0x38, 0x71, 0x1e, 0xbe, |
| 233 | 0xbf, 0x28, 0x17, 0xde, 0x9b, 0x2d, 0xd9, 0x4e, |
| 234 | 0x9b, 0x7e, 0x62, 0xf1, 0x17, 0xb8, 0x76, 0xc1, |
| 235 | }; |
| 236 | |
| 237 | SignatureInfo si(tlv::DigestSha256); |
| 238 | std::vector<uint8_t> nonce{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; |
| 239 | si.setNonce(nonce); |
| 240 | Block sv("2E20 12471AE0F8723AC1156C370A38711EBEBF2817DE9B2DD94E9B7E62F117B876C1"_block); |
| 241 | |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 242 | Interest i1(Block{WIRE}); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 243 | BOOST_CHECK_EQUAL(i1.getName(), |
| 244 | "/local/ndn/prefix/params-sha256=6f29586053ee9fccd8a422122925287c0a18435f4074c40abb0d5b30e4aa6220"); |
| 245 | BOOST_CHECK_EQUAL(i1.getCanBePrefix(), false); |
| 246 | BOOST_CHECK_EQUAL(i1.getMustBeFresh(), true); |
| 247 | BOOST_CHECK_EQUAL(i1.hasNonce(), true); |
| 248 | BOOST_CHECK_EQUAL(i1.getNonce(), 0x4c1ecb4a); |
| 249 | BOOST_CHECK_EQUAL(i1.getSignatureInfo()->getSignatureType(), tlv::DigestSha256); |
| 250 | BOOST_CHECK(i1.getSignatureInfo()->getNonce() == nonce); |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 251 | BOOST_TEST(i1.getSignatureValue() == sv, boost::test_tools::per_element()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 252 | BOOST_CHECK_EQUAL(i1.getApplicationParameters(), "2404C0C1C2C3"_block); |
| 253 | BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true); |
| 254 | |
| 255 | // Reset wire |
| 256 | BOOST_CHECK_EQUAL(i1.hasWire(), true); |
| 257 | i1.setCanBePrefix(true); |
| 258 | i1.setCanBePrefix(false); |
| 259 | BOOST_CHECK_EQUAL(i1.hasWire(), false); |
| 260 | |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 261 | BOOST_TEST(i1.wireEncode() == WIRE, boost::test_tools::per_element()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 262 | |
| 263 | Interest i2("/local/ndn/prefix"); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 264 | i2.setMustBeFresh(true); |
| 265 | i2.setNonce(0x4c1ecb4a); |
| 266 | i2.setApplicationParameters("2404C0C1C2C3"_block); |
| 267 | i2.setSignatureInfo(si); |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 268 | i2.setSignatureValue(sv.value_bytes()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 269 | BOOST_CHECK_EQUAL(i2.isParametersDigestValid(), true); |
| 270 | |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 271 | BOOST_TEST(i2.wireEncode() == WIRE, boost::test_tools::per_element()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | BOOST_AUTO_TEST_CASE(SignedApplicationElements) |
| 275 | { |
| 276 | const uint8_t WIRE[] = { |
| 277 | 0x05, 0x8f, // Interest |
| 278 | 0x07, 0x36, // Name |
| 279 | 0x08, 0x05, // GenericNameComponent |
| 280 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 281 | 0x08, 0x03, // GenericNameComponent |
| 282 | 0x6e, 0x64, 0x6e, |
| 283 | 0x08, 0x06, // GenericNameComponent |
| 284 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 285 | 0x02, 0x20, // ParametersSha256DigestComponent |
| 286 | 0xbc, 0x36, 0x30, 0xa4, 0xd6, 0x5e, 0x0d, 0xb5, |
| 287 | 0x48, 0x3d, 0xfa, 0x0d, 0x28, 0xb3, 0x31, 0x2f, |
| 288 | 0xca, 0xc1, 0xd4, 0x41, 0xec, 0x89, 0x61, 0xd4, |
| 289 | 0x17, 0x5e, 0x61, 0x75, 0x17, 0x78, 0x10, 0x8e, |
| 290 | 0x12, 0x00, // MustBeFresh |
| 291 | 0x0a, 0x04, // Nonce |
| 292 | 0x4c, 0x1e, 0xcb, 0x4a, |
| 293 | 0x24, 0x04, // ApplicationParameters |
| 294 | 0xc0, 0xc1, 0xc2, 0xc3, |
| 295 | 0xfd, 0x01, 0xfe, 0x08, // Application-specific element (Type 510) |
| 296 | 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, |
| 297 | 0x2c, 0x0d, // InterestSignatureInfo |
| 298 | 0x1b, 0x01, // SignatureType |
| 299 | 0x00, |
| 300 | 0x26, 0x08, // SignatureNonce |
| 301 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 302 | 0x2e, 0x20, // InterestSignatureValue |
| 303 | 0x12, 0x47, 0x1a, 0xe0, 0xf8, 0x72, 0x3a, 0xc1, |
| 304 | 0x15, 0x6c, 0x37, 0x0a, 0x38, 0x71, 0x1e, 0xbe, |
| 305 | 0xbf, 0x28, 0x17, 0xde, 0x9b, 0x2d, 0xd9, 0x4e, |
| 306 | 0x9b, 0x7e, 0x62, 0xf1, 0x17, 0xb8, 0x76, 0xc1, |
| 307 | 0xfd, 0x02, 0x00, 0x08, // Application-specific element (Type 512) |
| 308 | 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 |
| 309 | }; |
| 310 | |
| 311 | SignatureInfo si(tlv::DigestSha256); |
| 312 | std::vector<uint8_t> nonce{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08}; |
| 313 | si.setNonce(nonce); |
| 314 | Block sv("2E20 12471AE0F8723AC1156C370A38711EBEBF2817DE9B2DD94E9B7E62F117B876C1"_block); |
| 315 | |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 316 | Interest i1(Block{WIRE}); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 317 | BOOST_CHECK_EQUAL(i1.getName(), |
| 318 | "/local/ndn/prefix/params-sha256=bc3630a4d65e0db5483dfa0d28b3312fcac1d441ec8961d4175e61751778108e"); |
| 319 | BOOST_CHECK_EQUAL(i1.getCanBePrefix(), false); |
| 320 | BOOST_CHECK_EQUAL(i1.getMustBeFresh(), true); |
| 321 | BOOST_CHECK_EQUAL(i1.hasNonce(), true); |
| 322 | BOOST_CHECK_EQUAL(i1.getNonce(), 0x4c1ecb4a); |
| 323 | BOOST_CHECK_EQUAL(i1.getSignatureInfo()->getSignatureType(), tlv::DigestSha256); |
| 324 | BOOST_CHECK(i1.getSignatureInfo()->getNonce() == nonce); |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 325 | BOOST_TEST(i1.getSignatureValue() == sv, boost::test_tools::per_element()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 326 | BOOST_CHECK_EQUAL(i1.getApplicationParameters(), "2404C0C1C2C3"_block); |
| 327 | BOOST_CHECK_EQUAL(i1.isParametersDigestValid(), true); |
| 328 | |
| 329 | // Reset wire |
| 330 | BOOST_CHECK_EQUAL(i1.hasWire(), true); |
| 331 | i1.setCanBePrefix(true); |
| 332 | i1.setCanBePrefix(false); |
| 333 | BOOST_CHECK_EQUAL(i1.hasWire(), false); |
| 334 | |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 335 | BOOST_TEST(i1.wireEncode() == WIRE, boost::test_tools::per_element()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 336 | } |
| 337 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 338 | BOOST_AUTO_TEST_CASE(MissingApplicationParameters) |
| 339 | { |
| 340 | Interest i; |
| 341 | i.setName(Name("/A").appendParametersSha256DigestPlaceholder()); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 342 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), false); |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 343 | BOOST_CHECK_EXCEPTION(i.wireEncode(), tlv::Error, [] (const auto& e) { |
| 344 | return e.what() == "Interest without parameters must not have a ParametersSha256DigestComponent"s; |
| 345 | }); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 346 | } |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 347 | |
| 348 | BOOST_AUTO_TEST_CASE(MissingParametersSha256DigestComponent) |
| 349 | { |
| 350 | // there's no way to create an Interest that fails this check via programmatic construction, |
| 351 | // so we have to decode an invalid Interest and force reencoding |
| 352 | |
| 353 | DisableAutoCheckParametersDigest disabler; |
| 354 | Interest i("050F 0703(080149) 0A04F000F000 2402CAFE"_block); |
| 355 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), false); |
| 356 | BOOST_CHECK_NO_THROW(i.wireEncode()); // this succeeds because it uses the cached wire encoding |
| 357 | |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 358 | // trigger reencoding |
| 359 | i.setNonce(42); |
| 360 | // now the check fails while attempting to reencode |
| 361 | BOOST_CHECK_EXCEPTION(i.wireEncode(), tlv::Error, [] (const auto& e) { |
| 362 | return e.what() == "Interest with parameters must have a ParametersSha256DigestComponent"s; |
| 363 | }); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 364 | } |
| 365 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 366 | BOOST_AUTO_TEST_SUITE_END() // Encode |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 367 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 368 | class DecodeFixture |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 369 | { |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 370 | protected: |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 371 | DecodeFixture() |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 372 | { |
| 373 | // initialize all elements to non-empty, to verify wireDecode clears them |
| 374 | i.setName("/A"); |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 375 | i.setForwardingHint({"/F"}); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 376 | i.setNonce(0x03d645a8); |
| 377 | i.setInterestLifetime(18554_ms); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 378 | i.setHopLimit(64); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 379 | i.setApplicationParameters("2404A0A1A2A3"_block); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 380 | } |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 381 | |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 382 | protected: |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 383 | Interest i; |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 384 | }; |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 385 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 386 | BOOST_FIXTURE_TEST_SUITE(Decode, DecodeFixture) |
| 387 | |
| 388 | BOOST_AUTO_TEST_CASE(NotAnInterest) |
| 389 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 390 | BOOST_CHECK_EXCEPTION(i.wireDecode("4202CAFE"_block), tlv::Error, [] (const auto& e) { |
| 391 | return e.what() == "Expecting Interest element, but TLV has type 66"s; |
| 392 | }); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 393 | } |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 394 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 395 | BOOST_AUTO_TEST_CASE(NameOnly) |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 396 | { |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 397 | i.wireDecode("0505 0703(080149)"_block); |
Davide Pesavento | 835f027 | 2019-09-21 13:18:24 -0400 | [diff] [blame] | 398 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 399 | BOOST_CHECK_EQUAL(i.getName(), "/I"); |
| 400 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), false); |
| 401 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), false); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 402 | BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); |
Davide Pesavento | 835f027 | 2019-09-21 13:18:24 -0400 | [diff] [blame] | 403 | BOOST_CHECK_EQUAL(i.hasNonce(), false); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 404 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 405 | BOOST_CHECK(i.getHopLimit() == nullopt); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 406 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); |
| 407 | BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 408 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 409 | // modify then re-encode |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 410 | i.setNonce(0x957c6554); |
Davide Pesavento | 835f027 | 2019-09-21 13:18:24 -0400 | [diff] [blame] | 411 | BOOST_CHECK_EQUAL(i.hasWire(), false); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 412 | BOOST_CHECK_EQUAL(i.wireEncode(), "050B 0703(080149) 0A04957C6554"_block); |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 413 | } |
| 414 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 415 | BOOST_AUTO_TEST_CASE(NameCanBePrefix) |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 416 | { |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 417 | i.wireDecode("0507 0703(080149) 2100"_block); |
Davide Pesavento | 835f027 | 2019-09-21 13:18:24 -0400 | [diff] [blame] | 418 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 419 | BOOST_CHECK_EQUAL(i.getName(), "/I"); |
| 420 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), true); |
| 421 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), false); |
| 422 | BOOST_CHECK_EQUAL(i.getForwardingHint().empty(), true); |
Davide Pesavento | 835f027 | 2019-09-21 13:18:24 -0400 | [diff] [blame] | 423 | BOOST_CHECK_EQUAL(i.hasNonce(), false); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 424 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 425 | BOOST_CHECK(i.getHopLimit() == nullopt); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 426 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); |
| 427 | BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); |
| 428 | } |
| 429 | |
| 430 | BOOST_AUTO_TEST_CASE(FullWithoutParameters) |
| 431 | { |
| 432 | i.wireDecode("0531 0703(080149) " |
| 433 | "FC00 2100 FC00 1200 FC00 1E0B(1F09 1E023E15 0703080148) " |
| 434 | "FC00 0A044ACB1E4C FC00 0C0276A1 FC00 2201D6 FC00"_block); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 435 | BOOST_CHECK_EQUAL(i.getName(), "/I"); |
| 436 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), true); |
| 437 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), true); |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 438 | BOOST_TEST(i.getForwardingHint() == std::vector<Name>({"/H"}), boost::test_tools::per_element()); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 439 | BOOST_CHECK_EQUAL(i.hasNonce(), true); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 440 | BOOST_CHECK_EQUAL(i.getNonce(), 0x4acb1e4c); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 441 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), 30369_ms); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 442 | BOOST_CHECK_EQUAL(*i.getHopLimit(), 214); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 443 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); |
| 444 | BOOST_CHECK_EQUAL(i.getApplicationParameters().isValid(), false); |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 445 | |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 446 | // encode without modification: retain original wire encoding |
Junxiao Shi | 8b753a2 | 2018-10-24 01:51:40 +0000 | [diff] [blame] | 447 | BOOST_CHECK_EQUAL(i.wireEncode().value_size(), 49); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 448 | |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 449 | // modify then re-encode: |
| 450 | // * unrecognized elements are discarded; |
| 451 | // * ForwardingHint is re-encoded as a sequence of Names |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 452 | i.setName("/J"); |
Junxiao Shi | 72c0c64 | 2018-04-20 15:41:09 +0000 | [diff] [blame] | 453 | BOOST_CHECK_EQUAL(i.wireEncode(), |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 454 | "051D 0703(08014A) " |
| 455 | "2100 1200 1E05(0703080148) " |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 456 | "0A044ACB1E4C 0C0276A1 2201D6"_block); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | BOOST_AUTO_TEST_CASE(FullWithParameters) |
| 460 | { |
| 461 | i.wireDecode("055B 0725(080149 0220F16DB273F40436A852063F864D5072B01EAD53151F5A688EA1560492BEBEDD05) " |
| 462 | "FC00 2100 FC00 1200 FC00 1E0B(1F09 1E023E15 0703080148) " |
| 463 | "FC00 0A044ACB1E4C FC00 0C0276A1 FC00 2201D6 FC00 2404C0C1C2C3 FC00"_block); |
| 464 | BOOST_CHECK_EQUAL(i.getName(), |
| 465 | "/I/params-sha256=f16db273f40436a852063f864d5072b01ead53151f5a688ea1560492bebedd05"); |
| 466 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), true); |
| 467 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), true); |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 468 | BOOST_TEST(i.getForwardingHint() == std::vector<Name>({"/H"}), boost::test_tools::per_element()); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 469 | BOOST_CHECK_EQUAL(i.hasNonce(), true); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 470 | BOOST_CHECK_EQUAL(i.getNonce(), 0x4acb1e4c); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 471 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), 30369_ms); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 472 | BOOST_CHECK_EQUAL(*i.getHopLimit(), 214); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 473 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), true); |
| 474 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2404C0C1C2C3"_block); |
| 475 | |
| 476 | // encode without modification: retain original wire encoding |
| 477 | BOOST_CHECK_EQUAL(i.wireEncode().value_size(), 91); |
| 478 | |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 479 | // modify then re-encode: |
| 480 | // * unrecognized elements after ApplicationParameters are preserved, the rest are discarded; |
| 481 | // * ForwardingHint is re-encoded as a sequence of Names |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 482 | i.setName("/J"); |
| 483 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 484 | BOOST_CHECK_EQUAL(i.wireEncode(), |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 485 | "0547 0725(08014A 0220F16DB273F40436A852063F864D5072B01EAD53151F5A688EA1560492BEBEDD05) " |
| 486 | "2100 1200 1E05(0703080148) " |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 487 | "0A044ACB1E4C 0C0276A1 2201D6 2404C0C1C2C3 FC00"_block); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 488 | |
| 489 | // modify ApplicationParameters: unrecognized elements are preserved |
| 490 | i.setApplicationParameters("2402CAFE"_block); |
| 491 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 492 | BOOST_CHECK_EQUAL(i.wireEncode(), |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 493 | "0545 0725(08014A 02205FDA67967EE302FC457E41B7D3D51BA6A9379574D193FD88F64954BF16C2927A) " |
| 494 | "2100 1200 1E05(0703080148) " |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 495 | "0A044ACB1E4C 0C0276A1 2201D6 2402CAFE FC00"_block); |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 496 | } |
| 497 | |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 498 | BOOST_AUTO_TEST_CASE(CriticalElementOutOfOrder) |
| 499 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 500 | BOOST_CHECK_EXCEPTION(i.wireDecode( |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 501 | "0529 2100 0703080149 1200 1E0B(1F09 1E023E15 0703080148) " |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 502 | "0A044ACB1E4C 0C0276A1 2201D6 2404C0C1C2C3"_block), |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 503 | tlv::Error, |
| 504 | [] (const auto& e) { return e.what() == "Name element is missing or out of order"s; }); |
| 505 | BOOST_CHECK_EXCEPTION(i.wireDecode( |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 506 | "0529 0703080149 1200 2100 1E0B(1F09 1E023E15 0703080148) " |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 507 | "0A044ACB1E4C 0C0276A1 2201D6 2404C0C1C2C3"_block), |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 508 | tlv::Error, |
| 509 | [] (const auto& e) { return e.what() == "CanBePrefix element is out of order"s; }); |
| 510 | BOOST_CHECK_EXCEPTION(i.wireDecode( |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 511 | "0529 0703080149 2100 1E0B(1F09 1E023E15 0703080148) 1200 " |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 512 | "0A044ACB1E4C 0C0276A1 2201D6 2404C0C1C2C3"_block), |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 513 | tlv::Error, |
| 514 | [] (const auto& e) { return e.what() == "MustBeFresh element is out of order"s; }); |
| 515 | BOOST_CHECK_EXCEPTION(i.wireDecode( |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 516 | "0529 0703080149 2100 1200 0A044ACB1E4C " |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 517 | "1E0B(1F09 1E023E15 0703080148) 0C0276A1 2201D6 2404C0C1C2C3"_block), |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 518 | tlv::Error, |
| 519 | [] (const auto& e) { return e.what() == "ForwardingHint element is out of order"s; }); |
| 520 | BOOST_CHECK_EXCEPTION(i.wireDecode( |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 521 | "0529 0703080149 2100 1200 1E0B(1F09 1E023E15 0703080148) " |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 522 | "0C0276A1 0A044ACB1E4C 2201D6 2404C0C1C2C3"_block), |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 523 | tlv::Error, |
| 524 | [] (const auto& e) { return e.what() == "Nonce element is out of order"s; }); |
| 525 | BOOST_CHECK_EXCEPTION(i.wireDecode( |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 526 | "0529 0703080149 2100 1200 1E0B(1F09 1E023E15 0703080148) " |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 527 | "0A044ACB1E4C 2201D6 0C0276A1 2404C0C1C2C3"_block), |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 528 | tlv::Error, |
| 529 | [] (const auto& e) { return e.what() == "InterestLifetime element is out of order"s; }); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 530 | } |
| 531 | |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 532 | BOOST_AUTO_TEST_CASE(NonCriticalElementOutOfOrder) |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 533 | { |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 534 | // duplicate HopLimit |
| 535 | i.wireDecode("0536 0725(080149 0220FF9100E04EAADCF30674D98026A051BA25F56B69BFA026DCCCD72C6EA0F7315A)" |
| 536 | "2201D6 2200 2404C0C1C2C3 22020101"_block); |
| 537 | BOOST_CHECK_EQUAL(i.getName(), |
| 538 | "/I/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a"); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 539 | BOOST_CHECK_EQUAL(*i.getHopLimit(), 214); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 540 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), true); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 541 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2404C0C1C2C3"_block); |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 542 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 543 | // duplicate ApplicationParameters |
| 544 | i.wireDecode("0541 0725(080149 0220FF9100E04EAADCF30674D98026A051BA25F56B69BFA026DCCCD72C6EA0F7315A)" |
| 545 | "2100 1200 0A044ACB1E4C 0C0276A1 2201D6 2404C0C1C2C3 2401EE"_block); |
| 546 | BOOST_CHECK_EQUAL(i.getName(), |
| 547 | "/I/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a"); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 548 | BOOST_CHECK_EQUAL(*i.getHopLimit(), 214); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 549 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), true); |
| 550 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2404C0C1C2C3"_block); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 551 | } |
| 552 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 553 | BOOST_AUTO_TEST_CASE(MissingName) |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 554 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 555 | BOOST_CHECK_EXCEPTION(i.wireDecode("0500"_block), tlv::Error, |
| 556 | [] (const auto& e) { return e.what() == "Name element is missing or out of order"s; }); |
| 557 | BOOST_CHECK_EXCEPTION(i.wireDecode("0502 1200"_block), tlv::Error, |
| 558 | [] (const auto& e) { return e.what() == "Name element is missing or out of order"s; }); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 559 | } |
| 560 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 561 | BOOST_AUTO_TEST_CASE(BadName) |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 562 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 563 | BOOST_CHECK_EXCEPTION(i.wireDecode("0502 0700"_block), tlv::Error, |
| 564 | [] (const auto& e) { return e.what() == "Name has zero name components"s; }); |
| 565 | BOOST_CHECK_EXCEPTION(i.wireDecode("054C 074A(080149" |
| 566 | "02200000000000000000000000000000000000000000000000000000000000000000" |
| 567 | "080132" |
| 568 | "02200000000000000000000000000000000000000000000000000000000000000000)"_block), |
| 569 | tlv::Error, |
| 570 | [] (const auto& e) { return e.what() == "Name has more than one ParametersSha256DigestComponent"s; }); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | BOOST_AUTO_TEST_CASE(BadCanBePrefix) |
| 574 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 575 | BOOST_CHECK_EXCEPTION(i.wireDecode("0508 0703080149 210102"_block), tlv::Error, |
| 576 | [] (const auto& e) { return e.what() == "CanBePrefix element has non-zero TLV-LENGTH"s; }); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | BOOST_AUTO_TEST_CASE(BadMustBeFresh) |
| 580 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 581 | BOOST_CHECK_EXCEPTION(i.wireDecode("0508 0703080149 120102"_block), tlv::Error, |
| 582 | [] (const auto& e) { return e.what() == "MustBeFresh element has non-zero TLV-LENGTH"s; }); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | BOOST_AUTO_TEST_CASE(BadNonce) |
| 586 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 587 | BOOST_CHECK_EXCEPTION(i.wireDecode("0507 0703080149 0A00"_block), tlv::Error, |
| 588 | [] (const auto& e) { return e.what() == "Nonce element is malformed"s; }); |
| 589 | BOOST_CHECK_EXCEPTION(i.wireDecode("050A 0703080149 0A0304C263"_block), tlv::Error, |
| 590 | [] (const auto& e) { return e.what() == "Nonce element is malformed"s; }); |
| 591 | BOOST_CHECK_EXCEPTION(i.wireDecode("050C 0703080149 0A05EFA420B262"_block), tlv::Error, |
| 592 | [] (const auto& e) { return e.what() == "Nonce element is malformed"s; }); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 593 | } |
| 594 | |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 595 | BOOST_AUTO_TEST_CASE(BadHopLimit) |
| 596 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 597 | BOOST_CHECK_EXCEPTION(i.wireDecode("0507 0703080149 2200"_block), tlv::Error, |
| 598 | [] (const auto& e) { return e.what() == "HopLimit element is malformed"s; }); |
| 599 | BOOST_CHECK_EXCEPTION(i.wireDecode("0509 0703080149 22021356"_block), tlv::Error, |
| 600 | [] (const auto& e) { return e.what() == "HopLimit element is malformed"s; }); |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 601 | } |
| 602 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 603 | BOOST_AUTO_TEST_CASE(BadParametersDigest) |
| 604 | { |
| 605 | // ApplicationParameters without ParametersSha256DigestComponent |
| 606 | Block b1("0509 0703(080149) 2402CAFE"_block); |
| 607 | // ParametersSha256DigestComponent without ApplicationParameters |
| 608 | Block b2("0527 0725(080149 0220E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855)"_block); |
| 609 | // digest mismatch |
| 610 | Block b3("052B 0725(080149 02200000000000000000000000000000000000000000000000000000000000000000) " |
| 611 | "2402CAFE"_block); |
| 612 | |
| 613 | BOOST_CHECK_THROW(i.wireDecode(b1), tlv::Error); |
| 614 | BOOST_CHECK_THROW(i.wireDecode(b2), tlv::Error); |
| 615 | BOOST_CHECK_THROW(i.wireDecode(b3), tlv::Error); |
| 616 | |
| 617 | DisableAutoCheckParametersDigest disabler; |
| 618 | BOOST_CHECK_NO_THROW(i.wireDecode(b1)); |
| 619 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), false); |
| 620 | BOOST_CHECK_NO_THROW(i.wireDecode(b2)); |
| 621 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), false); |
| 622 | BOOST_CHECK_NO_THROW(i.wireDecode(b3)); |
| 623 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), false); |
| 624 | } |
| 625 | |
Junxiao Shi | 8b753a2 | 2018-10-24 01:51:40 +0000 | [diff] [blame] | 626 | BOOST_AUTO_TEST_CASE(UnrecognizedNonCriticalElementBeforeName) |
| 627 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 628 | BOOST_CHECK_EXCEPTION(i.wireDecode("0507 FC00 0703080149"_block), tlv::Error, |
| 629 | [] (const auto& e) { return e.what() == "Name element is missing or out of order"s; }); |
Junxiao Shi | 8b753a2 | 2018-10-24 01:51:40 +0000 | [diff] [blame] | 630 | } |
| 631 | |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 632 | BOOST_AUTO_TEST_CASE(UnrecognizedCriticalElement) |
| 633 | { |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 634 | BOOST_CHECK_EXCEPTION(i.wireDecode("0507 0703080149 FB00"_block), tlv::Error, |
| 635 | [] (const auto& e) { return e.what() == "Unrecognized element of critical type 251"s; }); |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 636 | // v0.2 packet with Selectors |
Davide Pesavento | 905d40f | 2020-06-09 21:33:25 -0400 | [diff] [blame] | 637 | BOOST_CHECK_EXCEPTION(i.wireDecode("0510 0703080149 09030D0101 0A0401000000"_block), tlv::Error, |
| 638 | [] (const auto& e) { return e.what() == "Unrecognized element of critical type 9"s; }); |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 639 | } |
| 640 | |
Davide Pesavento | 0e0b389 | 2019-07-30 21:05:05 -0400 | [diff] [blame] | 641 | BOOST_AUTO_TEST_SUITE_END() // Decode |
Junxiao Shi | 6efa3b7 | 2018-04-14 15:54:08 +0000 | [diff] [blame] | 642 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 643 | BOOST_AUTO_TEST_CASE(MatchesData) |
| 644 | { |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 645 | auto interest = makeInterest("/A"); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 646 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 647 | auto data = makeData("/A"); |
| 648 | BOOST_CHECK_EQUAL(interest->matchesData(*data), true); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 649 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 650 | data->setName("/A/D"); |
| 651 | BOOST_CHECK_EQUAL(interest->matchesData(*data), false); // violates CanBePrefix |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 652 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 653 | interest->setCanBePrefix(true); |
| 654 | BOOST_CHECK_EQUAL(interest->matchesData(*data), true); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 655 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 656 | interest->setMustBeFresh(true); |
| 657 | BOOST_CHECK_EQUAL(interest->matchesData(*data), false); // violates MustBeFresh |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 658 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 659 | data->setFreshnessPeriod(1_s); |
| 660 | BOOST_CHECK_EQUAL(interest->matchesData(*data), true); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 661 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 662 | data->setName("/H/I"); |
| 663 | BOOST_CHECK_EQUAL(interest->matchesData(*data), false); // Name does not match |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 664 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 665 | data->wireEncode(); |
| 666 | interest = makeInterest(data->getFullName()); |
| 667 | BOOST_CHECK_EQUAL(interest->matchesData(*data), true); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 668 | |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 669 | setNameComponent(*interest, -1, |
| 670 | name::Component::fromEscapedString("sha256digest=00000000000000000000000000" |
| 671 | "00000000000000000000000000000000000000")); |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 672 | BOOST_CHECK_EQUAL(interest->matchesData(*data), false); // violates implicit digest |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(MatchesInterest, 1) |
| 676 | BOOST_AUTO_TEST_CASE(MatchesInterest) |
| 677 | { |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 678 | Interest interest; |
| 679 | interest.setName("/A") |
| 680 | .setCanBePrefix(true) |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 681 | .setMustBeFresh(true) |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 682 | .setForwardingHint({"/H"}) |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 683 | .setNonce(2228) |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 684 | .setInterestLifetime(5_s) |
| 685 | .setHopLimit(90); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 686 | |
| 687 | Interest other; |
| 688 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), false); |
| 689 | |
| 690 | other.setName(interest.getName()); |
| 691 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), false); |
| 692 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 693 | other.setCanBePrefix(interest.getCanBePrefix()); |
| 694 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), false); |
| 695 | |
| 696 | other.setMustBeFresh(interest.getMustBeFresh()); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 697 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), false); // will match until #3162 implemented |
| 698 | |
Junxiao Shi | e4603e1 | 2022-01-05 19:12:25 +0000 | [diff] [blame] | 699 | auto fh = interest.getForwardingHint(); |
| 700 | other.setForwardingHint(std::vector<Name>(fh.begin(), fh.end())); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 701 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), true); |
| 702 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 703 | other.setNonce(9336); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 704 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), true); |
| 705 | |
Junxiao Shi | 2ad2fbe | 2019-05-24 03:11:05 +0000 | [diff] [blame] | 706 | other.setInterestLifetime(3_s); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 707 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), true); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 708 | |
| 709 | other.setHopLimit(31); |
| 710 | BOOST_CHECK_EQUAL(interest.matchesInterest(other), true); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 711 | } |
| 712 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 713 | BOOST_AUTO_TEST_CASE(SetName) |
| 714 | { |
| 715 | Interest i; |
| 716 | BOOST_CHECK_EQUAL(i.getName(), "/"); |
| 717 | i.setName("/A/B"); |
| 718 | BOOST_CHECK_EQUAL(i.getName(), "/A/B"); |
| 719 | i.setName("/I/params-sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); |
| 720 | BOOST_CHECK_EQUAL(i.getName(), |
| 721 | "/I/params-sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); |
| 722 | BOOST_CHECK_THROW(i.setName("/I" |
| 723 | "/params-sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" |
| 724 | "/params-sha256=0000000000000000000000000000000000000000000000000000000000000000"), |
| 725 | std::invalid_argument); |
| 726 | } |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 727 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 728 | BOOST_AUTO_TEST_CASE(SetCanBePrefix) |
Junxiao Shi | 8d3f834 | 2018-04-04 12:46:37 +0000 | [diff] [blame] | 729 | { |
| 730 | Interest i; |
Junxiao Shi | 8d3f834 | 2018-04-04 12:46:37 +0000 | [diff] [blame] | 731 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), false); |
Junxiao Shi | 8d3f834 | 2018-04-04 12:46:37 +0000 | [diff] [blame] | 732 | i.setCanBePrefix(true); |
| 733 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), true); |
Davide Pesavento | 478d338 | 2021-03-17 12:46:08 -0400 | [diff] [blame] | 734 | i.setCanBePrefix(false); |
| 735 | BOOST_CHECK_EQUAL(i.getCanBePrefix(), false); |
Junxiao Shi | 8d3f834 | 2018-04-04 12:46:37 +0000 | [diff] [blame] | 736 | } |
| 737 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 738 | BOOST_AUTO_TEST_CASE(SetMustBeFresh) |
Junxiao Shi | 8d3f834 | 2018-04-04 12:46:37 +0000 | [diff] [blame] | 739 | { |
| 740 | Interest i; |
| 741 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), false); |
| 742 | i.setMustBeFresh(true); |
| 743 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), true); |
Junxiao Shi | 8d3f834 | 2018-04-04 12:46:37 +0000 | [diff] [blame] | 744 | i.setMustBeFresh(false); |
| 745 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), false); |
Junxiao Shi | 8d3f834 | 2018-04-04 12:46:37 +0000 | [diff] [blame] | 746 | } |
| 747 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 748 | BOOST_AUTO_TEST_CASE(GetNonce) |
| 749 | { |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 750 | unique_ptr<Interest> i1, i2; |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 751 | Interest::Nonce nonce1(0), nonce2(0); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 752 | |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 753 | // getNonce automatically assigns a random Nonce. |
| 754 | // It's possible to assign the same Nonce to two Interest, but it's unlikely to get 100 pairs of |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 755 | // identical Nonces in a row. |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 756 | int nIterations = 0; |
| 757 | do { |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 758 | i1 = make_unique<Interest>(); |
| 759 | nonce1 = i1->getNonce(); |
| 760 | i2 = make_unique<Interest>(); |
| 761 | nonce2 = i2->getNonce(); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 762 | } |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 763 | while (nonce1 == nonce2 && ++nIterations < 100); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 764 | |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 765 | BOOST_CHECK_NE(nonce1, nonce2); |
| 766 | BOOST_CHECK(i1->hasNonce()); |
| 767 | BOOST_CHECK(i2->hasNonce()); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 768 | |
| 769 | // Once a Nonce is assigned, it should not change. |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 770 | BOOST_CHECK_EQUAL(i1->getNonce(), nonce1); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 771 | BOOST_CHECK_EQUAL(i2->getNonce(), nonce2); |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | BOOST_AUTO_TEST_CASE(SetNonce) |
| 775 | { |
| 776 | Interest i1("/A"); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 777 | BOOST_CHECK(!i1.hasNonce()); |
| 778 | |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 779 | i1.setNonce(1); |
| 780 | i1.wireEncode(); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 781 | BOOST_CHECK(i1.hasNonce()); |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 782 | BOOST_CHECK_EQUAL(i1.getNonce(), 1); |
| 783 | |
| 784 | Interest i2(i1); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 785 | BOOST_CHECK(i2.hasNonce()); |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 786 | BOOST_CHECK_EQUAL(i2.getNonce(), 1); |
| 787 | |
| 788 | i2.setNonce(2); |
| 789 | BOOST_CHECK_EQUAL(i2.getNonce(), 2); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 790 | BOOST_CHECK_EQUAL(i1.getNonce(), 1); // should not affect i1's Nonce (Bug #4168) |
| 791 | |
| 792 | i2.setNonce(nullopt); |
| 793 | BOOST_CHECK(!i2.hasNonce()); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | BOOST_AUTO_TEST_CASE(RefreshNonce) |
| 797 | { |
| 798 | Interest i; |
| 799 | BOOST_CHECK(!i.hasNonce()); |
| 800 | i.refreshNonce(); |
| 801 | BOOST_CHECK(!i.hasNonce()); |
| 802 | |
| 803 | i.setNonce(1); |
| 804 | BOOST_CHECK(i.hasNonce()); |
| 805 | i.refreshNonce(); |
| 806 | BOOST_CHECK(i.hasNonce()); |
| 807 | BOOST_CHECK_NE(i.getNonce(), 1); |
| 808 | } |
| 809 | |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 810 | BOOST_AUTO_TEST_CASE(NonceConversions) |
| 811 | { |
| 812 | Interest i; |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 813 | |
| 814 | // 4-arg constructor |
| 815 | Interest::Nonce n1(1, 2, 3, 4); |
| 816 | i.setNonce(n1); |
| 817 | BOOST_CHECK_EQUAL(i.getNonce(), 0x01020304); |
| 818 | |
| 819 | // 4-arg constructor + assignment |
| 820 | n1 = {0xf, 0xe, 0xd, 0xc}; |
| 821 | i.setNonce(n1); |
| 822 | BOOST_CHECK_EQUAL(i.getNonce(), 0x0f0e0d0c); |
| 823 | |
| 824 | // 1-arg constructor + assignment (implicit conversion) |
| 825 | Interest::Nonce n2; |
| 826 | n2 = 42; |
| 827 | BOOST_CHECK_NE(n1, n2); |
| 828 | i.setNonce(n2); |
| 829 | n2 = 21; // should not affect i's Nonce |
| 830 | BOOST_CHECK_EQUAL(i.getNonce(), 42); |
| 831 | BOOST_CHECK_EQUAL(i.toUri(), "/?Nonce=0000002a"); // stored in big-endian |
| 832 | } |
| 833 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 834 | BOOST_AUTO_TEST_CASE(SetInterestLifetime) |
| 835 | { |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 836 | BOOST_CHECK_THROW(Interest("/A", -1_ms), std::invalid_argument); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 837 | BOOST_CHECK_NO_THROW(Interest("/A", 0_ms)); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 838 | |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 839 | Interest i; |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 840 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | fccb2dc | 2019-02-09 01:02:35 -0500 | [diff] [blame] | 841 | BOOST_CHECK_THROW(i.setInterestLifetime(-1_ms), std::invalid_argument); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 842 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), DEFAULT_INTEREST_LIFETIME); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 843 | i.setInterestLifetime(0_ms); |
| 844 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), 0_ms); |
| 845 | i.setInterestLifetime(1_ms); |
| 846 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), 1_ms); |
Davide Pesavento | 2b0cc7b | 2019-07-14 16:50:04 -0400 | [diff] [blame] | 847 | |
| 848 | i = Interest("/B", 15_s); |
| 849 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), 15_s); |
| 850 | } |
| 851 | |
| 852 | BOOST_AUTO_TEST_CASE(SetHopLimit) |
| 853 | { |
| 854 | Interest i; |
| 855 | BOOST_CHECK(i.getHopLimit() == nullopt); |
| 856 | i.setHopLimit(42); |
| 857 | BOOST_CHECK(i.getHopLimit() == 42); |
| 858 | i.setHopLimit(nullopt); |
| 859 | BOOST_CHECK(i.getHopLimit() == nullopt); |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 860 | } |
| 861 | |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 862 | BOOST_AUTO_TEST_CASE(SetApplicationParameters) |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 863 | { |
| 864 | const uint8_t PARAMETERS1[] = {0xc1}; |
| 865 | const uint8_t PARAMETERS2[] = {0xc2}; |
| 866 | |
| 867 | Interest i; |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 868 | BOOST_CHECK(!i.hasApplicationParameters()); |
| 869 | i.setApplicationParameters("2400"_block); |
| 870 | BOOST_CHECK(i.hasApplicationParameters()); |
| 871 | i.unsetApplicationParameters(); |
| 872 | BOOST_CHECK(!i.hasApplicationParameters()); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 873 | |
Davide Pesavento | 3891244 | 2019-04-06 22:03:39 -0400 | [diff] [blame] | 874 | // Block overload |
Davide Pesavento | 3891244 | 2019-04-06 22:03:39 -0400 | [diff] [blame] | 875 | i.setApplicationParameters("2401C0"_block); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 876 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2401C0"_block); |
Davide Pesavento | 3891244 | 2019-04-06 22:03:39 -0400 | [diff] [blame] | 877 | i.setApplicationParameters("8001C1"_block); |
Davide Pesavento | 9c19a39 | 2019-04-06 15:07:54 -0400 | [diff] [blame] | 878 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "24038001C1"_block); |
Davide Pesavento | 81bd696 | 2020-06-17 16:03:23 -0400 | [diff] [blame] | 879 | BOOST_CHECK_THROW(i.setApplicationParameters(Block{}), std::invalid_argument); |
Davide Pesavento | 3891244 | 2019-04-06 22:03:39 -0400 | [diff] [blame] | 880 | |
Davide Pesavento | a3d809e | 2022-02-06 11:55:02 -0500 | [diff] [blame] | 881 | // span overload |
| 882 | i.setApplicationParameters(PARAMETERS1); |
Davide Pesavento | 3891244 | 2019-04-06 22:03:39 -0400 | [diff] [blame] | 883 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2401C1"_block); |
Davide Pesavento | a3d809e | 2022-02-06 11:55:02 -0500 | [diff] [blame] | 884 | i.setApplicationParameters(span<uint8_t>{}); |
Davide Pesavento | 3891244 | 2019-04-06 22:03:39 -0400 | [diff] [blame] | 885 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2400"_block); |
Davide Pesavento | df8fd8a | 2022-02-21 20:04:21 -0500 | [diff] [blame] | 886 | |
Davide Pesavento | 3891244 | 2019-04-06 22:03:39 -0400 | [diff] [blame] | 887 | // ConstBufferPtr overload |
| 888 | i.setApplicationParameters(make_shared<Buffer>(PARAMETERS2, sizeof(PARAMETERS2))); |
| 889 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2401C2"_block); |
| 890 | i.setApplicationParameters(make_shared<Buffer>()); |
| 891 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2400"_block); |
| 892 | BOOST_CHECK_THROW(i.setApplicationParameters(nullptr), std::invalid_argument); |
Arthi Padmanabhan | b38664e | 2018-07-18 11:13:12 -0700 | [diff] [blame] | 893 | } |
| 894 | |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 895 | BOOST_AUTO_TEST_CASE(SetSignature) |
| 896 | { |
| 897 | Interest i; |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 898 | |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 899 | Block sv1("2E04 01020304"_block); |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 900 | BOOST_CHECK_EXCEPTION(i.setSignatureValue(sv1.value_bytes()), tlv::Error, [] (const auto& e) { |
| 901 | return e.what() == "InterestSignatureInfo must be present to set InterestSignatureValue"s; |
| 902 | }); |
| 903 | |
| 904 | BOOST_CHECK(i.getSignatureInfo() == nullopt); |
| 905 | BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); |
| 906 | BOOST_CHECK_EQUAL(i.isSigned(), false); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 907 | |
| 908 | // Simple set/get case for InterestSignatureInfo (no prior set) |
| 909 | SignatureInfo si1(tlv::SignatureSha256WithEcdsa); |
| 910 | i.setSignatureInfo(si1); |
| 911 | BOOST_CHECK(i.getSignatureInfo() == si1); |
| 912 | BOOST_CHECK_EQUAL(i.isSigned(), false); |
| 913 | |
| 914 | // Simple set/get case for InterestSignatureValue (no prior set) |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 915 | auto svBuffer1 = make_shared<Buffer>(sv1.value_begin(), sv1.value_end()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 916 | i.setSignatureValue(svBuffer1); |
| 917 | BOOST_CHECK_EQUAL(i.getSignatureValue(), sv1); |
| 918 | BOOST_CHECK_EQUAL(i.isSigned(), true); |
| 919 | |
| 920 | // Throws because attempting to set InterestSignatureValue to nullptr |
| 921 | BOOST_CHECK_THROW(i.setSignatureValue(nullptr), std::invalid_argument); |
| 922 | BOOST_CHECK_EQUAL(i.getSignatureValue(), sv1); |
| 923 | BOOST_CHECK_EQUAL(i.isSigned(), true); |
| 924 | |
| 925 | // Ensure that wire is not reset if specified InterestSignatureInfo is same |
| 926 | i.wireEncode(); |
| 927 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
| 928 | i.setSignatureInfo(si1); |
| 929 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
| 930 | BOOST_CHECK(i.getSignatureInfo() == si1); |
| 931 | BOOST_CHECK_EQUAL(i.getSignatureValue(), sv1); |
| 932 | BOOST_CHECK_EQUAL(i.isSigned(), true); |
| 933 | |
| 934 | // Ensure that wire is reset if specified InterestSignatureInfo is different |
| 935 | i.wireEncode(); |
| 936 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
| 937 | SignatureInfo si2(tlv::SignatureSha256WithRsa); |
| 938 | i.setSignatureInfo(si2); |
| 939 | BOOST_CHECK_EQUAL(i.hasWire(), false); |
| 940 | BOOST_CHECK(i.getSignatureInfo() == si2); |
| 941 | BOOST_CHECK_EQUAL(i.getSignatureValue(), sv1); |
| 942 | BOOST_CHECK_EQUAL(i.isSigned(), true); |
| 943 | |
| 944 | // Ensure that wire is not reset if specified InterestSignatureValue is same |
| 945 | i.wireEncode(); |
| 946 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 947 | i.setSignatureValue(sv1.value_bytes()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 948 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
| 949 | BOOST_CHECK(i.getSignatureInfo() == si2); |
| 950 | BOOST_CHECK_EQUAL(i.getSignatureValue(), sv1); |
| 951 | BOOST_CHECK_EQUAL(i.isSigned(), true); |
| 952 | |
| 953 | // Ensure that wire is reset if specified InterestSignatureValue is different |
| 954 | i.wireEncode(); |
| 955 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 956 | const uint8_t sv2[] = {0x99, 0x88, 0x77, 0x66}; |
| 957 | i.setSignatureValue(sv2); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 958 | BOOST_CHECK_EQUAL(i.hasWire(), false); |
| 959 | BOOST_CHECK(i.getSignatureInfo() == si2); |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 960 | BOOST_TEST(i.getSignatureValue().value_bytes() == sv2, boost::test_tools::per_element()); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 961 | BOOST_CHECK_EQUAL(i.isSigned(), true); |
| 962 | } |
| 963 | |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 964 | BOOST_AUTO_TEST_CASE(ParametersSha256DigestComponent) |
| 965 | { |
| 966 | Interest i("/I"); |
| 967 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 968 | |
| 969 | i.setApplicationParameters("2404C0C1C2C3"_block); // auto-appends ParametersSha256DigestComponent |
| 970 | BOOST_CHECK_EQUAL(i.getName(), |
| 971 | "/I/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a"); |
| 972 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 973 | |
Davide Pesavento | a3d809e | 2022-02-06 11:55:02 -0500 | [diff] [blame] | 974 | i.setApplicationParameters(span<uint8_t>{}); // updates ParametersSha256DigestComponent |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 975 | BOOST_CHECK_EQUAL(i.getName(), |
| 976 | "/I/params-sha256=33b67cb5385ceddad93d0ee960679041613bed34b8b4a5e6362fe7539ba2d3ce"); |
| 977 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), true); |
| 978 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 979 | |
| 980 | i.unsetApplicationParameters(); // removes ParametersSha256DigestComponent |
| 981 | BOOST_CHECK_EQUAL(i.getName(), "/I"); |
| 982 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 983 | |
| 984 | i.setName(Name("/P").appendParametersSha256DigestPlaceholder().append("Q")); |
| 985 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), false); |
| 986 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), false); |
| 987 | |
| 988 | i.unsetApplicationParameters(); // removes ParametersSha256DigestComponent |
| 989 | BOOST_CHECK_EQUAL(i.getName(), "/P/Q"); |
| 990 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 991 | |
| 992 | i.setName(Name("/P").appendParametersSha256DigestPlaceholder().append("Q")); |
| 993 | i.setApplicationParameters("2404C0C1C2C3"_block); // updates ParametersSha256DigestComponent |
| 994 | BOOST_CHECK_EQUAL(i.getName(), |
| 995 | "/P/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a/Q"); |
| 996 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 997 | |
| 998 | i.setName("/A/B/C"); // auto-appends ParametersSha256DigestComponent |
| 999 | BOOST_CHECK_EQUAL(i.getName(), |
| 1000 | "/A/B/C/params-sha256=ff9100e04eaadcf30674d98026a051ba25f56b69bfa026dcccd72c6ea0f7315a"); |
| 1001 | BOOST_CHECK_EQUAL(i.hasApplicationParameters(), true); |
| 1002 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 1003 | |
| 1004 | SignatureInfo si(tlv::SignatureSha256WithEcdsa); |
| 1005 | i.setSignatureInfo(si); // updates ParametersSha256DigestComponent |
| 1006 | BOOST_CHECK_EQUAL(i.getName(), |
| 1007 | "/A/B/C/params-sha256=6400cae1730c15fd7854b26be05794d53685423c94bc61e59c49bd640d646ae8"); |
| 1008 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 1009 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2404 C0C1C2C3"_block); |
| 1010 | BOOST_CHECK(i.getSignatureInfo() == si); |
| 1011 | |
| 1012 | i.unsetApplicationParameters(); // removes ParametersSha256DigestComponent and InterestSignatureInfo |
| 1013 | BOOST_CHECK(i.getSignatureInfo() == nullopt); |
| 1014 | BOOST_CHECK_EQUAL(i.getSignatureValue().isValid(), false); |
| 1015 | BOOST_CHECK_EQUAL(i.getName(), "/A/B/C"); |
| 1016 | |
| 1017 | i.setSignatureInfo(si); // auto-adds an empty ApplicationParameters element |
| 1018 | BOOST_CHECK_EQUAL(i.getName(), |
| 1019 | "/A/B/C/params-sha256=d2ac0eb1f60f60ab206fb80bf1d0f73cfef353bbec43ba6ea626117f671ca3bb"); |
| 1020 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 1021 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2400"_block); |
| 1022 | BOOST_CHECK(i.getSignatureInfo() == si); |
| 1023 | |
| 1024 | Block sv("2E04 01020304"_block); |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 1025 | i.setSignatureValue(sv.value_bytes()); // updates ParametersDigestSha256Component |
Eric Newberry | 6e262f0 | 2020-05-29 23:11:25 -0700 | [diff] [blame] | 1026 | BOOST_CHECK_EQUAL(i.getName(), |
| 1027 | "/A/B/C/params-sha256=f649845ef944638390d1c689e2f0618ea02e471eff236110cbeb822d5932d342"); |
| 1028 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 1029 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2400"_block); |
| 1030 | BOOST_CHECK(i.getSignatureInfo() == si); |
| 1031 | BOOST_CHECK_EQUAL(i.getSignatureValue(), sv); |
| 1032 | |
| 1033 | i.setApplicationParameters("2404C0C1C2C3"_block); // updates ParametersSha256DigestComponent |
| 1034 | BOOST_CHECK_EQUAL(i.getName(), |
| 1035 | "/A/B/C/params-sha256=c5d7e567e6b251ddf36f7a6dbed95235b2d4a0b36215bb0f3cc403ac64ad0284"); |
| 1036 | BOOST_CHECK_EQUAL(i.isParametersDigestValid(), true); |
| 1037 | BOOST_CHECK_EQUAL(i.getApplicationParameters(), "2404 C0C1C2C3"_block); |
| 1038 | BOOST_CHECK(i.getSignatureInfo() == si); |
| 1039 | BOOST_CHECK_EQUAL(i.getSignatureValue(), sv); |
Davide Pesavento | adc9aa2 | 2019-06-30 19:00:20 -0400 | [diff] [blame] | 1040 | } |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 1041 | |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1042 | BOOST_AUTO_TEST_CASE(ExtractSignedRanges) |
| 1043 | { |
| 1044 | Interest i1; |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1045 | BOOST_CHECK_EXCEPTION(i1.extractSignedRanges(), tlv::Error, [] (const auto& e) { |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1046 | return e.what() == "Name has zero name components"s; |
| 1047 | }); |
| 1048 | i1.setName("/test/prefix"); |
| 1049 | i1.setNonce(0x01020304); |
| 1050 | SignatureInfo sigInfo(tlv::DigestSha256); |
| 1051 | i1.setSignatureInfo(sigInfo); |
| 1052 | |
| 1053 | // Test with previously unsigned Interest (no InterestSignatureValue) |
| 1054 | auto ranges1 = i1.extractSignedRanges(); |
| 1055 | BOOST_REQUIRE_EQUAL(ranges1.size(), 2); |
| 1056 | const Block& wire1 = i1.wireEncode(); |
| 1057 | // Ensure Name range captured properly |
| 1058 | Block nameWithoutDigest1 = i1.getName().getPrefix(-1).wireEncode(); |
Davide Pesavento | 765abc9 | 2021-12-27 00:44:04 -0500 | [diff] [blame] | 1059 | BOOST_CHECK_EQUAL_COLLECTIONS(ranges1.front().begin(), ranges1.front().end(), |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1060 | nameWithoutDigest1.value_begin(), nameWithoutDigest1.value_end()); |
| 1061 | // Ensure parameters range captured properly |
| 1062 | const auto& appParamsWire1 = wire1.find(tlv::ApplicationParameters); |
| 1063 | BOOST_REQUIRE(appParamsWire1 != wire1.elements_end()); |
Davide Pesavento | 765abc9 | 2021-12-27 00:44:04 -0500 | [diff] [blame] | 1064 | BOOST_CHECK_EQUAL_COLLECTIONS(ranges1.back().begin(), ranges1.back().end(), |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1065 | appParamsWire1->begin(), wire1.end()); |
| 1066 | |
| 1067 | // Test with Interest with existing InterestSignatureValue |
Davide Pesavento | 487e3d3 | 2022-05-05 18:06:23 -0400 | [diff] [blame] | 1068 | i1.setSignatureValue(std::make_shared<Buffer>()); |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1069 | auto ranges2 = i1.extractSignedRanges(); |
| 1070 | BOOST_REQUIRE_EQUAL(ranges2.size(), 2); |
| 1071 | const auto& wire2 = i1.wireEncode(); |
| 1072 | // Ensure Name range captured properly |
| 1073 | Block nameWithoutDigest2 = i1.getName().getPrefix(-1).wireEncode(); |
Davide Pesavento | 765abc9 | 2021-12-27 00:44:04 -0500 | [diff] [blame] | 1074 | BOOST_CHECK_EQUAL_COLLECTIONS(ranges2.front().begin(), ranges2.front().end(), |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1075 | nameWithoutDigest2.value_begin(), nameWithoutDigest2.value_end()); |
| 1076 | // Ensure parameters range captured properly |
| 1077 | const auto& appParamsWire2 = wire2.find(tlv::ApplicationParameters); |
| 1078 | BOOST_REQUIRE(appParamsWire2 != wire2.elements_end()); |
| 1079 | const auto& sigValueWire2 = wire2.find(tlv::InterestSignatureValue); |
| 1080 | BOOST_REQUIRE(sigValueWire2 != wire2.elements_end()); |
Davide Pesavento | 765abc9 | 2021-12-27 00:44:04 -0500 | [diff] [blame] | 1081 | BOOST_CHECK_EQUAL_COLLECTIONS(ranges2.back().begin(), ranges2.back().end(), |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1082 | appParamsWire2->begin(), sigValueWire2->begin()); |
| 1083 | |
| 1084 | // Test with decoded Interest |
| 1085 | const uint8_t WIRE[] = { |
| 1086 | 0x05, 0x6f, // Interest |
| 1087 | 0x07, 0x2e, // Name |
| 1088 | 0x08, 0x04, // GenericNameComponent |
| 1089 | 0x61, 0x62, 0x63, 0x64, |
| 1090 | 0x08, 0x04, // GenericNameComponent |
| 1091 | 0x65, 0x66, 0x67, 0x68, |
| 1092 | 0x02, 0x20, // ParametersSha256DigestComponent |
| 1093 | 0x6f, 0x29, 0x58, 0x60, 0x53, 0xee, 0x9f, 0xcc, |
| 1094 | 0xd8, 0xa4, 0x22, 0x12, 0x29, 0x25, 0x28, 0x7c, |
| 1095 | 0x0a, 0x18, 0x43, 0x5f, 0x40, 0x74, 0xc4, 0x0a, |
| 1096 | 0xbb, 0x0d, 0x5b, 0x30, 0xe4, 0xaa, 0x62, 0x20, |
| 1097 | 0x12, 0x00, // MustBeFresh |
| 1098 | 0x0a, 0x04, // Nonce |
| 1099 | 0x4c, 0x1e, 0xcb, 0x4a, |
| 1100 | 0x24, 0x04, // ApplicationParameters |
| 1101 | 0xc0, 0xc1, 0xc2, 0xc3, |
| 1102 | 0x2c, 0x0d, // InterestSignatureInfo |
| 1103 | 0x1b, 0x01, // SignatureType |
| 1104 | 0x00, |
| 1105 | 0x26, 0x08, // SignatureNonce |
| 1106 | 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, |
| 1107 | 0x2e, 0x20, // InterestSignatureValue |
| 1108 | 0x12, 0x47, 0x1a, 0xe0, 0xf8, 0x72, 0x3a, 0xc1, |
| 1109 | 0x15, 0x6c, 0x37, 0x0a, 0x38, 0x71, 0x1e, 0xbe, |
| 1110 | 0xbf, 0x28, 0x17, 0xde, 0x9b, 0x2d, 0xd9, 0x4e, |
| 1111 | 0x9b, 0x7e, 0x62, 0xf1, 0x17, 0xb8, 0x76, 0xc1, |
| 1112 | }; |
Davide Pesavento | fbea4fc | 2022-02-08 07:26:04 -0500 | [diff] [blame] | 1113 | Block wire3(WIRE); |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1114 | Interest i2(wire3); |
| 1115 | auto ranges3 = i2.extractSignedRanges(); |
| 1116 | BOOST_REQUIRE_EQUAL(ranges3.size(), 2); |
| 1117 | // Ensure Name range captured properly |
Davide Pesavento | 765abc9 | 2021-12-27 00:44:04 -0500 | [diff] [blame] | 1118 | BOOST_CHECK_EQUAL_COLLECTIONS(ranges3.front().begin(), ranges3.front().end(), &WIRE[4], &WIRE[16]); |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1119 | // Ensure parameters range captured properly |
Davide Pesavento | 765abc9 | 2021-12-27 00:44:04 -0500 | [diff] [blame] | 1120 | BOOST_CHECK_EQUAL_COLLECTIONS(ranges3.back().begin(), ranges3.back().end(), &WIRE[58], &WIRE[79]); |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1121 | |
| 1122 | // Test failure with missing ParametersSha256DigestComponent |
| 1123 | Interest i3("/a"); |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1124 | BOOST_CHECK_EXCEPTION(i3.extractSignedRanges(), tlv::Error, [] (const auto& e) { |
| 1125 | return e.what() == "Interest Name must end with a ParametersSha256DigestComponent"s; |
| 1126 | }); |
| 1127 | |
| 1128 | // Test failure with missing InterestSignatureInfo |
Davide Pesavento | a3d809e | 2022-02-06 11:55:02 -0500 | [diff] [blame] | 1129 | i3.setApplicationParameters(span<uint8_t>{}); |
Eric Newberry | b74bbda | 2020-06-18 19:33:58 -0700 | [diff] [blame] | 1130 | BOOST_CHECK_EXCEPTION(i3.extractSignedRanges(), tlv::Error, [] (const auto& e) { |
| 1131 | return e.what() == "Interest missing InterestSignatureInfo"s; |
| 1132 | }); |
| 1133 | } |
| 1134 | |
Davide Pesavento | 2fdb274 | 2019-07-31 23:03:35 -0400 | [diff] [blame] | 1135 | BOOST_AUTO_TEST_CASE(ToUri) |
| 1136 | { |
| 1137 | Interest i; |
Davide Pesavento | 2fdb274 | 2019-07-31 23:03:35 -0400 | [diff] [blame] | 1138 | BOOST_CHECK_EQUAL(i.toUri(), "/"); |
| 1139 | |
| 1140 | i.setName("/foo"); |
| 1141 | BOOST_CHECK_EQUAL(i.toUri(), "/foo"); |
| 1142 | |
| 1143 | i.setCanBePrefix(true); |
| 1144 | BOOST_CHECK_EQUAL(i.toUri(), "/foo?CanBePrefix"); |
| 1145 | |
| 1146 | i.setMustBeFresh(true); |
| 1147 | BOOST_CHECK_EQUAL(i.toUri(), "/foo?CanBePrefix&MustBeFresh"); |
| 1148 | |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 1149 | i.setNonce(0xa1b2c3); |
| 1150 | BOOST_CHECK_EQUAL(i.toUri(), "/foo?CanBePrefix&MustBeFresh&Nonce=00a1b2c3"); |
Davide Pesavento | 2fdb274 | 2019-07-31 23:03:35 -0400 | [diff] [blame] | 1151 | |
| 1152 | i.setInterestLifetime(2_s); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 1153 | BOOST_CHECK_EQUAL(i.toUri(), "/foo?CanBePrefix&MustBeFresh&Nonce=00a1b2c3&Lifetime=2000"); |
Davide Pesavento | 2fdb274 | 2019-07-31 23:03:35 -0400 | [diff] [blame] | 1154 | |
| 1155 | i.setHopLimit(18); |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 1156 | BOOST_CHECK_EQUAL(i.toUri(), "/foo?CanBePrefix&MustBeFresh&Nonce=00a1b2c3&Lifetime=2000&HopLimit=18"); |
Davide Pesavento | 2fdb274 | 2019-07-31 23:03:35 -0400 | [diff] [blame] | 1157 | |
| 1158 | i.setCanBePrefix(false); |
| 1159 | i.setMustBeFresh(false); |
| 1160 | i.setHopLimit(nullopt); |
| 1161 | i.setApplicationParameters("2402CAFE"_block); |
| 1162 | BOOST_CHECK_EQUAL(i.toUri(), |
| 1163 | "/foo/params-sha256=8621f5e8321f04104640c8d02877d7c5142cad6e203c5effda1783b1a0e476d6" |
Davide Pesavento | 5353394 | 2020-03-04 23:10:06 -0500 | [diff] [blame] | 1164 | "?Nonce=00a1b2c3&Lifetime=2000"); |
Davide Pesavento | 2fdb274 | 2019-07-31 23:03:35 -0400 | [diff] [blame] | 1165 | } |
| 1166 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 1167 | BOOST_AUTO_TEST_SUITE_END() // TestInterest |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 1168 | |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 1169 | } // namespace tests |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 1170 | } // namespace ndn |