Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 2 | /** |
Spyridon Mastorakis | 429634f | 2015-02-19 17:35:33 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2015 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 | |
Alexander Afanasyev | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 22 | #include "interest.hpp" |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 23 | #include "interest-filter.hpp" |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 24 | #include "data.hpp" |
| 25 | #include "security/signature-sha256-with-rsa.hpp" |
Yingdi Yu | bf6a281 | 2014-06-17 15:32:11 -0700 | [diff] [blame] | 26 | #include "security/digest-sha256.hpp" |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 27 | #include "security/key-chain.hpp" |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 28 | #include "encoding/buffer-stream.hpp" |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 30 | #include "boost-test.hpp" |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 31 | |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 32 | namespace ndn { |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 33 | namespace tests { |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 34 | |
| 35 | BOOST_AUTO_TEST_SUITE(TestInterest) |
| 36 | |
| 37 | const uint8_t Interest1[] = { |
Alexander Afanasyev | 117f5ef | 2015-06-03 15:07:24 -0700 | [diff] [blame] | 38 | 0x05, 0x59, // NDN Interest |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 39 | 0x07, 0x14, // Name |
| 40 | 0x08, 0x5, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 41 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 42 | 0x08, 0x3, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 43 | 0x6e, 0x64, 0x6e, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 44 | 0x08, 0x6, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 45 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 46 | 0x09, 0x37, // Selectors |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 47 | 0x0d, 0x1, 0x1, // MinSuffix |
| 48 | 0x0e, 0x1, 0x1, // MaxSuffix |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 49 | 0x1c, 0x16, // KeyLocator |
| 50 | 0x07, 0x14, // Name |
| 51 | 0x08, 0x04, |
| 52 | 0x74, 0x65, 0x73, 0x74, |
| 53 | 0x08, 0x03, |
| 54 | 0x6b, 0x65, 0x79, |
| 55 | 0x08, 0x07, |
| 56 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 57 | 0x10, 0x14, // Exclude |
| 58 | 0x08, 0x4, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 59 | 0x61, 0x6c, 0x65, 0x78, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 60 | 0x08, 0x4, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 61 | 0x78, 0x78, 0x78, 0x78, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 62 | 0x13, 0x0, // Any |
| 63 | 0x08, 0x4, // NameComponent |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 64 | 0x79, 0x79, 0x79, 0x79, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 65 | 0x11, 0x1, // ChildSelector |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 66 | 0x1, |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 67 | 0x0a, 0x4, // Nonce |
| 68 | 0x1, 0x0, 0x0, 0x00, |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 69 | 0x0c, // InterestLifetime |
| 70 | 0x2, 0x3, 0xe8 |
| 71 | }; |
| 72 | |
| 73 | const uint8_t Interest2[] = { |
Alexander Afanasyev | 117f5ef | 2015-06-03 15:07:24 -0700 | [diff] [blame] | 74 | 0x05, 0x59, // NDN Interest |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 75 | 0x07, 0x14, // Name |
| 76 | 0x08, 0x5, // NameComponent |
| 77 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 78 | 0x08, 0x3, // NameComponent |
| 79 | 0x6e, 0x64, 0x6e, |
| 80 | 0x08, 0x6, // NameComponent |
| 81 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 82 | 0x09, 0x37, // Selectors |
| 83 | 0x0d, 0x1, 0x1, // MinSuffix |
| 84 | 0x0e, 0x1, 0x1, // MaxSuffix |
| 85 | 0x1c, 0x16, // KeyLocator |
| 86 | 0x07, 0x14, // Name |
| 87 | 0x08, 0x04, |
| 88 | 0x74, 0x65, 0x73, 0x74, |
| 89 | 0x08, 0x03, |
| 90 | 0x6b, 0x65, 0x79, |
| 91 | 0x08, 0x07, |
| 92 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 93 | 0x10, 0x14, // Exclude |
| 94 | 0x08, 0x4, // NameComponent |
| 95 | 0x61, 0x6c, 0x65, 0x78, |
| 96 | 0x08, 0x4, // NameComponent |
| 97 | 0x78, 0x78, 0x78, 0x78, |
| 98 | 0x13, 0x0, // Any |
| 99 | 0x08, 0x4, // NameComponent |
| 100 | 0x79, 0x79, 0x79, 0x79, |
| 101 | 0x11, 0x1, // ChildSelector |
| 102 | 0x1, |
| 103 | 0x0a, 0x4, // Nonce |
| 104 | 0x2, 0x0, 0x0, 0x00, |
Alexander Afanasyev | 4b45628 | 2014-02-13 00:34:34 -0800 | [diff] [blame] | 105 | 0x0c, // InterestLifetime |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 106 | 0x2, 0x3, 0xe8 |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 107 | }; |
| 108 | |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 109 | const uint8_t InterestWithLink[] = { |
| 110 | 0x05, 0xfb, // Interest |
| 111 | 0x07, 0x14, // Name |
| 112 | 0x08, 0x5, // NameComponent |
| 113 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 114 | 0x08, 0x3, // NameComponent |
| 115 | 0x6e, 0x64, 0x6e, |
| 116 | 0x08, 0x6, // NameComponent |
| 117 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 118 | 0x0a, 0x4, // Nonce |
| 119 | 0x1, 0x0, 0x0, 0x00, |
| 120 | 0x06, 0xda, // Data |
| 121 | 0x07, 0x14, // Name |
| 122 | 0x08, 0x05, |
| 123 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 124 | 0x08, 0x03, |
| 125 | 0x6e, 0x64, 0x6e, |
| 126 | 0x08, 0x06, |
| 127 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 128 | 0x14, 0x07, // MetaInfo |
| 129 | 0x18, 0x01, // ContentType |
| 130 | 0x01, |
| 131 | 0x19, 0x02, // FreshnessPeriod |
| 132 | 0x27, 0x10, |
| 133 | 0x15, 0x1a, // Content |
| 134 | 0x1f, 0x0c, // LinkDelegation |
| 135 | 0x1e, 0x01, // LinkPreference |
| 136 | 0x0a, |
| 137 | 0x07, 0x07, // Name |
| 138 | 0x08, 0x05, |
| 139 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 140 | 0x1f, 0x0a, // LinkDelegation |
| 141 | 0x1e, 0x01, // LinkPreference |
| 142 | 0x14, |
| 143 | 0x07, 0x05, // Name |
| 144 | 0x08, 0x03, |
| 145 | 0x6e, 0x64, 0x6e, |
| 146 | 0x16, 0x1b, // SignatureInfo |
| 147 | 0x1b, 0x01, // SignatureType |
| 148 | 0x01, |
| 149 | 0x1c, 0x16, // KeyLocator |
| 150 | 0x07, 0x14, // Name |
| 151 | 0x08, 0x04, |
| 152 | 0x74, 0x65, 0x73, 0x74, |
| 153 | 0x08, 0x03, |
| 154 | 0x6b, 0x65, 0x79, |
| 155 | 0x08, 0x07, |
| 156 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 157 | 0x17, 0x80, // SignatureValue |
| 158 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 159 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 160 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 161 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 162 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 163 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 164 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 165 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 166 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 167 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, |
| 168 | 0x20, 0x01, // SelectedDelegation |
| 169 | 0x00 |
| 170 | }; |
| 171 | |
| 172 | const uint8_t InterestWithLinkMissingContentType[] = { |
| 173 | 0x05, 0xf8, // Interest |
| 174 | 0x07, 0x14, // Name |
| 175 | 0x08, 0x5, // NameComponent |
| 176 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 177 | 0x08, 0x3, // NameComponent |
| 178 | 0x6e, 0x64, 0x6e, |
| 179 | 0x08, 0x6, // NameComponent |
| 180 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 181 | 0x0a, 0x4, // Nonce |
| 182 | 0x1, 0x0, 0x0, 0x00, |
| 183 | 0x06, 0xd7, // Data |
| 184 | 0x07, 0x14, // Name |
| 185 | 0x08, 0x05, |
| 186 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 187 | 0x08, 0x03, |
| 188 | 0x6e, 0x64, 0x6e, |
| 189 | 0x08, 0x06, |
| 190 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 191 | 0x14, 0x04, // MetaInfo |
| 192 | 0x19, 0x02, // FreshnessPeriod |
| 193 | 0x27, 0x10, |
| 194 | 0x15, 0x1a, // Content |
| 195 | 0x1f, 0x0c, // LinkDelegation |
| 196 | 0x1e, 0x01, // LinkPreference |
| 197 | 0x0a, |
| 198 | 0x07, 0x07, // Name |
| 199 | 0x08, 0x05, |
| 200 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 201 | 0x1f, 0x0a, // LinkDelegation |
| 202 | 0x1e, 0x01, // LinkPreference |
| 203 | 0x14, |
| 204 | 0x07, 0x05, // Name |
| 205 | 0x08, 0x03, |
| 206 | 0x6e, 0x64, 0x6e, |
| 207 | 0x16, 0x1b, // SignatureInfo |
| 208 | 0x1b, 0x01, // SignatureType |
| 209 | 0x01, |
| 210 | 0x1c, 0x16, // KeyLocator |
| 211 | 0x07, 0x14, // Name |
| 212 | 0x08, 0x04, |
| 213 | 0x74, 0x65, 0x73, 0x74, |
| 214 | 0x08, 0x03, |
| 215 | 0x6b, 0x65, 0x79, |
| 216 | 0x08, 0x07, |
| 217 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 218 | 0x17, 0x80, // SignatureValue |
| 219 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 220 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 221 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 222 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 223 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 224 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 225 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 226 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 227 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 228 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, |
| 229 | 0x20, 0x01, // SelectedDelegation |
| 230 | 0x00 |
| 231 | }; |
| 232 | |
| 233 | const uint8_t InterestWithLinkNoMetaInfo[] = { |
| 234 | 0x05, 0xf2, // Interest |
| 235 | 0x07, 0x14, // Name |
| 236 | 0x08, 0x5, // NameComponent |
| 237 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 238 | 0x08, 0x3, // NameComponent |
| 239 | 0x6e, 0x64, 0x6e, |
| 240 | 0x08, 0x6, // NameComponent |
| 241 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 242 | 0x0a, 0x4, // Nonce |
| 243 | 0x1, 0x0, 0x0, 0x00, |
| 244 | 0x06, 0xd1, // Data |
| 245 | 0x07, 0x14, // Name |
| 246 | 0x08, 0x05, |
| 247 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 248 | 0x08, 0x03, |
| 249 | 0x6e, 0x64, 0x6e, |
| 250 | 0x08, 0x06, |
| 251 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 252 | 0x15, 0x1a, // Content |
| 253 | 0x1f, 0x0c, // LinkDelegation |
| 254 | 0x1e, 0x01, // LinkPreference |
| 255 | 0x0a, |
| 256 | 0x07, 0x07, // Name |
| 257 | 0x08, 0x05, |
| 258 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 259 | 0x1f, 0x0a, // LinkPreference |
| 260 | 0x1e, 0x01, // LinkPreference |
| 261 | 0x14, |
| 262 | 0x07, 0x05, // Name |
| 263 | 0x08, 0x03, |
| 264 | 0x6e, 0x64, 0x6e, |
| 265 | 0x16, 0x1b, // SignatureInfo |
| 266 | 0x1b, 0x01, // SignatureType |
| 267 | 0x01, |
| 268 | 0x1c, 0x16, // KeyLocator |
| 269 | 0x07, 0x14, // Name |
| 270 | 0x08, 0x04, |
| 271 | 0x74, 0x65, 0x73, 0x74, |
| 272 | 0x08, 0x03, |
| 273 | 0x6b, 0x65, 0x79, |
| 274 | 0x08, 0x07, |
| 275 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 276 | 0x17, 0x80, // SignatureValue |
| 277 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 278 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 279 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 280 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 281 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 282 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 283 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 284 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 285 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 286 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, |
| 287 | 0x20, 0x01, // SelectedDelegation |
| 288 | 0x00 |
| 289 | }; |
| 290 | |
| 291 | const uint8_t InterestWithLinkWrongContentType[] = { |
| 292 | 0x05, 0xfb, // Interest |
| 293 | 0x07, 0x14, // Name |
| 294 | 0x08, 0x5, // NameComponent |
| 295 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 296 | 0x08, 0x3, // NameComponent |
| 297 | 0x6e, 0x64, 0x6e, |
| 298 | 0x08, 0x6, // NameComponent |
| 299 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 300 | 0x0a, 0x4, // Nonce |
| 301 | 0x1, 0x0, 0x0, 0x00, |
| 302 | 0x06, 0xda, // Data |
| 303 | 0x07, 0x14, // Name |
| 304 | 0x08, 0x05, |
| 305 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 306 | 0x08, 0x03, |
| 307 | 0x6e, 0x64, 0x6e, |
| 308 | 0x08, 0x06, |
| 309 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 310 | 0x14, 0x07, // MetaInfo |
| 311 | 0x18, 0x01, // ContentType |
| 312 | 0x00, |
| 313 | 0x19, 0x02, // FreshnessPeriod |
| 314 | 0x27, 0x10, |
| 315 | 0x15, 0x1a, // Content |
| 316 | 0x1f, 0x0c, // LinkDelegation |
| 317 | 0x1e, 0x01, // LinkPreference |
| 318 | 0x0a, |
| 319 | 0x07, 0x07, // Name |
| 320 | 0x08, 0x05, |
| 321 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 322 | 0x1f, 0x0a, // LinkDelegation |
| 323 | 0x1e, 0x01, // LinkPreference |
| 324 | 0x14, |
| 325 | 0x07, 0x05, // Name |
| 326 | 0x08, 0x03, |
| 327 | 0x6e, 0x64, 0x6e, |
| 328 | 0x16, 0x1b, // SignatureInfo |
| 329 | 0x1b, 0x01, // SignatureType |
| 330 | 0x01, |
| 331 | 0x1c, 0x16, // KeyLocator |
| 332 | 0x07, 0x14, // Name |
| 333 | 0x08, 0x04, |
| 334 | 0x74, 0x65, 0x73, 0x74, |
| 335 | 0x08, 0x03, |
| 336 | 0x6b, 0x65, 0x79, |
| 337 | 0x08, 0x07, |
| 338 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 339 | 0x17, 0x80, // SignatureValue |
| 340 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 341 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 342 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 343 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 344 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 345 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 346 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 347 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 348 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 349 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, |
| 350 | 0x20, 0x01, // SelectedDelegation |
| 351 | 0x00 |
| 352 | }; |
| 353 | |
| 354 | const uint8_t InterestWithSelectedDelegationButNoLink[] = { |
| 355 | 0x05, 0x1f, // Interest |
| 356 | 0x07, 0x14, // Name |
| 357 | 0x08, 0x5, // NameComponent |
| 358 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 359 | 0x08, 0x3, // NameComponent |
| 360 | 0x6e, 0x64, 0x6e, |
| 361 | 0x08, 0x6, // NameComponent |
| 362 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 363 | 0x0a, 0x4, // Nonce |
| 364 | 0x1, 0x0, 0x0, 0x00, |
| 365 | 0x20, 0x01, // SelectedDelegation |
| 366 | 0x00 |
| 367 | }; |
| 368 | |
| 369 | const uint8_t InterestWithLinkNotNonIntegerSelectedDelegation[] = { |
| 370 | 0x05, 0xfb, // Interest |
| 371 | 0x07, 0x14, // Name |
| 372 | 0x08, 0x5, // NameComponent |
| 373 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 374 | 0x08, 0x3, // NameComponent |
| 375 | 0x6e, 0x64, 0x6e, |
| 376 | 0x08, 0x6, // NameComponent |
| 377 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 378 | 0x0a, 0x4, // Nonce |
| 379 | 0x1, 0x0, 0x0, 0x00, |
| 380 | 0x06, 0xda, // Data |
| 381 | 0x07, 0x14, // Name |
| 382 | 0x08, 0x05, |
| 383 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 384 | 0x08, 0x03, |
| 385 | 0x6e, 0x64, 0x6e, |
| 386 | 0x08, 0x06, |
| 387 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 388 | 0x14, 0x07, // MetaInfo |
| 389 | 0x18, 0x01, // ContentType |
| 390 | 0x01, |
| 391 | 0x19, 0x02, // FreshnessPeriod |
| 392 | 0x27, 0x10, |
| 393 | 0x15, 0x1a, // Content |
| 394 | 0x1f, 0x0c, // LinkDelegation |
| 395 | 0x1e, 0x01, // LinkPreference |
| 396 | 0x0a, |
| 397 | 0x07, 0x07, // Name |
| 398 | 0x08, 0x05, |
| 399 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 400 | 0x1f, 0x0a, // LinkDelegation |
| 401 | 0x1e, 0x01, // LinkPreference |
| 402 | 0x14, |
| 403 | 0x07, 0x05, // Name |
| 404 | 0x08, 0x03, |
| 405 | 0x6e, 0x64, 0x6e, |
| 406 | 0x16, 0x1b, // SignatureInfo |
| 407 | 0x1b, 0x01, // SignatureType |
| 408 | 0x01, |
| 409 | 0x1c, 0x16, // KeyLocator |
| 410 | 0x07, 0x14, // Name |
| 411 | 0x08, 0x04, |
| 412 | 0x74, 0x65, 0x73, 0x74, |
| 413 | 0x08, 0x03, |
| 414 | 0x6b, 0x65, 0x79, |
| 415 | 0x08, 0x07, |
| 416 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 417 | 0x17, 0x78, // SignatureValue |
| 418 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 419 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 420 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 421 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 422 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 423 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 424 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 425 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 426 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 427 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, |
| 428 | 0x20, 0x03, // SelectedDelegation |
| 429 | 0xAA, 0xAA, 0xAA |
| 430 | }; |
| 431 | |
| 432 | const uint8_t InterestWithLinkNonDecreasingOrder[] = { |
| 433 | 0x05, 0xfb, // Interest |
| 434 | 0x07, 0x14, // Name |
| 435 | 0x08, 0x5, // NameComponent |
| 436 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 437 | 0x08, 0x3, // NameComponent |
| 438 | 0x6e, 0x64, 0x6e, |
| 439 | 0x08, 0x6, // NameComponent |
| 440 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 441 | 0x0a, 0x4, // Nonce |
| 442 | 0x1, 0x0, 0x0, 0x00, |
| 443 | 0x06, 0xda, // Data |
| 444 | 0x07, 0x14, // Name |
| 445 | 0x08, 0x05, |
| 446 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 447 | 0x08, 0x03, |
| 448 | 0x6e, 0x64, 0x6e, |
| 449 | 0x08, 0x06, |
| 450 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 451 | 0x14, 0x07, // MetaInfo |
| 452 | 0x18, 0x01, // ContentType |
| 453 | 0x01, |
| 454 | 0x19, 0x02, // FreshnessPeriod |
| 455 | 0x27, 0x10, |
| 456 | 0x15, 0x1a, // Content |
| 457 | 0x1f, 0x0c, // LinkDelegation |
| 458 | 0x1e, 0x01, // LinkPreference |
| 459 | 0x14, |
| 460 | 0x07, 0x07, // Name |
| 461 | 0x08, 0x05, |
| 462 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 463 | 0x1f, 0x0a, // LinkDelegation |
| 464 | 0x1e, 0x01, // LinkPreference |
| 465 | 0x0a, |
| 466 | 0x07, 0x05, // Name |
| 467 | 0x08, 0x03, |
| 468 | 0x6e, 0x64, 0x6e, |
| 469 | 0x16, 0x1b, // SignatureInfo |
| 470 | 0x1b, 0x01, // SignatureType |
| 471 | 0x01, |
| 472 | 0x1c, 0x16, // KeyLocator |
| 473 | 0x07, 0x14, // Name |
| 474 | 0x08, 0x04, |
| 475 | 0x74, 0x65, 0x73, 0x74, |
| 476 | 0x08, 0x03, |
| 477 | 0x6b, 0x65, 0x79, |
| 478 | 0x08, 0x07, |
| 479 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 480 | 0x17, 0x80, // SignatureValue |
| 481 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 482 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 483 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 484 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 485 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 486 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 487 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 488 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 489 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 490 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1, |
| 491 | 0x20, 0x01, // SelectedDelegation |
| 492 | 0x01 |
| 493 | }; |
| 494 | |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 495 | const uint8_t InterestWithLocalControlHeader[] = { |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 496 | 0x50, 0x25, 0x51, 0x01, 0x0a, |
| 497 | 0x05, 0x20, 0x07, 0x14, 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, |
| 498 | 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x09, 0x02, 0x12, 0x00, 0x0a, 0x04, |
| 499 | 0x01, 0x00, 0x00, 0x00 |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 500 | }; |
| 501 | |
| 502 | const uint8_t InterestWithoutLocalControlHeader[] = { |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 503 | 0x05, 0x20, 0x07, 0x14, 0x08, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x08, 0x03, 0x6e, 0x64, |
| 504 | 0x6e, 0x08, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x09, 0x02, 0x12, 0x00, 0x0a, 0x04, |
| 505 | 0x01, 0x00, 0x00, 0x00 |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 506 | }; |
| 507 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 508 | BOOST_AUTO_TEST_CASE(InterestEqualityChecks) |
| 509 | { |
| 510 | // Interest ::= INTEREST-TYPE TLV-LENGTH |
| 511 | // Name |
| 512 | // Selectors? |
| 513 | // Nonce |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 514 | // InterestLifetime? |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 515 | // Link? |
| 516 | // SelectedDelegation? |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 517 | |
| 518 | Interest a; |
| 519 | Interest b; |
| 520 | |
| 521 | // if nonce is not set, it will be set to a random value |
| 522 | a.setNonce(1); |
| 523 | b.setNonce(1); |
| 524 | |
| 525 | BOOST_CHECK_EQUAL(a == b, true); |
| 526 | BOOST_CHECK_EQUAL(a != b, false); |
| 527 | |
| 528 | // check comparison on Name |
| 529 | a.setName("ndn:/A"); |
| 530 | BOOST_CHECK_EQUAL(a == b, false); |
| 531 | BOOST_CHECK_EQUAL(a != b, true); |
| 532 | |
| 533 | b.setName("ndn:/B"); |
| 534 | BOOST_CHECK_EQUAL(a == b, false); |
| 535 | BOOST_CHECK_EQUAL(a != b, true); |
| 536 | |
| 537 | b.setName("ndn:/A"); |
| 538 | BOOST_CHECK_EQUAL(a == b, true); |
| 539 | BOOST_CHECK_EQUAL(a != b, false); |
| 540 | |
| 541 | // check comparison on Selectors |
| 542 | a.setChildSelector(1); |
| 543 | BOOST_CHECK_EQUAL(a == b, false); |
| 544 | BOOST_CHECK_EQUAL(a != b, true); |
| 545 | |
| 546 | b.setChildSelector(1); |
| 547 | BOOST_CHECK_EQUAL(a == b, true); |
| 548 | BOOST_CHECK_EQUAL(a != b, false); |
| 549 | |
| 550 | // check comparison on Nonce |
| 551 | a.setNonce(100); |
| 552 | BOOST_CHECK_EQUAL(a == b, false); |
| 553 | BOOST_CHECK_EQUAL(a != b, true); |
| 554 | |
| 555 | b.setNonce(100); |
| 556 | BOOST_CHECK_EQUAL(a == b, true); |
| 557 | BOOST_CHECK_EQUAL(a != b, false); |
| 558 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 559 | // check comparison on InterestLifetime |
| 560 | a.setInterestLifetime(time::seconds(10)); |
| 561 | BOOST_CHECK_EQUAL(a == b, false); |
| 562 | BOOST_CHECK_EQUAL(a != b, true); |
| 563 | |
| 564 | b.setInterestLifetime(time::seconds(10)); |
| 565 | BOOST_CHECK_EQUAL(a == b, true); |
| 566 | BOOST_CHECK_EQUAL(a != b, false); |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 567 | |
| 568 | // Link object |
| 569 | Link link("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 570 | KeyChain keyChain; |
| 571 | keyChain.sign(link); |
| 572 | Block wire = link.wireEncode(); |
| 573 | |
| 574 | a.setLink(wire); |
| 575 | BOOST_CHECK_EQUAL(a == b, false); |
| 576 | BOOST_CHECK_EQUAL(a != b, true); |
| 577 | |
| 578 | b.setLink(wire); |
| 579 | BOOST_CHECK_EQUAL(a == b, true); |
| 580 | BOOST_CHECK_EQUAL(a != b, false); |
| 581 | |
| 582 | // Selected Delegation |
| 583 | BOOST_CHECK_EQUAL(a.hasSelectedDelegation(), false); |
| 584 | BOOST_CHECK_EQUAL(b.hasSelectedDelegation(), false); |
| 585 | |
| 586 | a.setSelectedDelegation(Name("test2")); |
| 587 | BOOST_CHECK_EQUAL(a == b, false); |
| 588 | BOOST_CHECK_EQUAL(a != b, true); |
| 589 | |
| 590 | b.setSelectedDelegation(Name("test2")); |
| 591 | BOOST_CHECK_EQUAL(a == b, true); |
| 592 | BOOST_CHECK_EQUAL(a != b, false); |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | BOOST_AUTO_TEST_CASE(SelectorsEqualityChecks) |
| 596 | { |
| 597 | // Selectors ::= SELECTORS-TYPE TLV-LENGTH |
| 598 | // MinSuffixComponents? |
| 599 | // MaxSuffixComponents? |
| 600 | // PublisherPublicKeyLocator? |
| 601 | // Exclude? |
| 602 | // ChildSelector? |
| 603 | // MustBeFresh? |
| 604 | |
| 605 | Selectors a; |
| 606 | Selectors b; |
| 607 | BOOST_CHECK_EQUAL(a == b, true); |
| 608 | BOOST_CHECK_EQUAL(a != b, false); |
| 609 | |
| 610 | // MinSuffixComponents |
| 611 | a.setMinSuffixComponents(1); |
| 612 | BOOST_CHECK_EQUAL(a == b, false); |
| 613 | BOOST_CHECK_EQUAL(a != b, true); |
| 614 | |
| 615 | b.setMinSuffixComponents(2); |
| 616 | BOOST_CHECK_EQUAL(a == b, false); |
| 617 | BOOST_CHECK_EQUAL(a != b, true); |
| 618 | |
| 619 | b.setMinSuffixComponents(1); |
| 620 | BOOST_CHECK_EQUAL(a == b, true); |
| 621 | BOOST_CHECK_EQUAL(a != b, false); |
| 622 | |
| 623 | // MaxSuffixComponents |
| 624 | a.setMaxSuffixComponents(10); |
| 625 | BOOST_CHECK_EQUAL(a == b, false); |
| 626 | BOOST_CHECK_EQUAL(a != b, true); |
| 627 | |
| 628 | b.setMaxSuffixComponents(10); |
| 629 | BOOST_CHECK_EQUAL(a == b, true); |
| 630 | BOOST_CHECK_EQUAL(a != b, false); |
| 631 | |
| 632 | // PublisherPublicKeyLocator |
| 633 | a.setPublisherPublicKeyLocator(KeyLocator("/key/Locator/name")); |
| 634 | BOOST_CHECK_EQUAL(a == b, false); |
| 635 | BOOST_CHECK_EQUAL(a != b, true); |
| 636 | |
| 637 | b.setPublisherPublicKeyLocator(KeyLocator("/key/Locator/name")); |
| 638 | BOOST_CHECK_EQUAL(a == b, true); |
| 639 | BOOST_CHECK_EQUAL(a != b, false); |
| 640 | |
| 641 | // Exclude |
| 642 | a.setExclude(Exclude().excludeOne(name::Component("exclude"))); |
| 643 | BOOST_CHECK_EQUAL(a == b, false); |
| 644 | BOOST_CHECK_EQUAL(a != b, true); |
| 645 | |
| 646 | b.setExclude(Exclude().excludeOne(name::Component("exclude"))); |
| 647 | BOOST_CHECK_EQUAL(a == b, true); |
| 648 | BOOST_CHECK_EQUAL(a != b, false); |
| 649 | |
| 650 | // ChildSelector |
| 651 | a.setChildSelector(1); |
| 652 | BOOST_CHECK_EQUAL(a == b, false); |
| 653 | BOOST_CHECK_EQUAL(a != b, true); |
| 654 | |
| 655 | b.setChildSelector(1); |
| 656 | BOOST_CHECK_EQUAL(a == b, true); |
| 657 | BOOST_CHECK_EQUAL(a != b, false); |
| 658 | |
| 659 | // MustBeFresh |
| 660 | a.setMustBeFresh(true); |
| 661 | BOOST_CHECK_EQUAL(a == b, false); |
| 662 | BOOST_CHECK_EQUAL(a != b, true); |
| 663 | |
| 664 | b.setMustBeFresh(true); |
| 665 | BOOST_CHECK_EQUAL(a == b, true); |
| 666 | BOOST_CHECK_EQUAL(a != b, false); |
| 667 | } |
| 668 | |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 669 | BOOST_AUTO_TEST_CASE(LinkObject) |
| 670 | { |
| 671 | Link link1("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 672 | KeyChain keyChain; |
| 673 | keyChain.sign(link1); |
| 674 | Block wire = link1.wireEncode(); |
| 675 | |
| 676 | Interest a; |
| 677 | BOOST_REQUIRE_NO_THROW(a.setLink(wire)); |
| 678 | |
| 679 | BOOST_REQUIRE_NO_THROW(a.getLink()); |
| 680 | |
| 681 | Link link2 = a.getLink(); |
| 682 | Name name = link2.getName(); |
| 683 | BOOST_CHECK_EQUAL(Name("test"), name); |
| 684 | BOOST_CHECK_EQUAL(a.hasLink(), true); |
| 685 | Link::DelegationSet delegations; |
| 686 | delegations = link2.getDelegations(); |
| 687 | |
| 688 | auto i = delegations.begin(); |
| 689 | BOOST_CHECK_EQUAL(std::get<0>(*i), 10); |
| 690 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test1")); |
| 691 | ++i; |
| 692 | BOOST_CHECK_EQUAL(std::get<0>(*i), 20); |
| 693 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test2")); |
| 694 | ++i; |
| 695 | BOOST_CHECK_EQUAL(std::get<0>(*i), 100); |
| 696 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test3")); |
| 697 | |
| 698 | a.unsetLink(); |
| 699 | BOOST_CHECK_EQUAL(a.hasLink(), false); |
| 700 | } |
| 701 | |
| 702 | BOOST_AUTO_TEST_CASE(SelectedDelegationChecks) |
| 703 | { |
| 704 | Link link("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 705 | KeyChain keyChain; |
| 706 | keyChain.sign(link); |
| 707 | Block wire = link.wireEncode(); |
| 708 | |
| 709 | Interest a; |
| 710 | a.setLink(wire); |
| 711 | BOOST_CHECK_EQUAL(a.hasSelectedDelegation(), false); |
| 712 | |
| 713 | BOOST_REQUIRE_NO_THROW(a.setSelectedDelegation(Name("test2"))); |
| 714 | BOOST_CHECK_EQUAL(a.getSelectedDelegation(), Name("test2")); |
| 715 | |
| 716 | BOOST_REQUIRE_NO_THROW(a.setSelectedDelegation(uint32_t(2))); |
| 717 | BOOST_CHECK_EQUAL(a.getSelectedDelegation(), Name("test3")); |
| 718 | |
| 719 | a.unsetSelectedDelegation(); |
| 720 | BOOST_CHECK_EQUAL(a.hasSelectedDelegation(), false); |
| 721 | } |
| 722 | |
| 723 | BOOST_AUTO_TEST_CASE(EncodeDecodeWithLink) |
| 724 | { |
| 725 | Link link1("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 726 | KeyChain keyChain; |
| 727 | keyChain.sign(link1); |
| 728 | Block wire = link1.wireEncode(); |
| 729 | |
| 730 | Interest a; |
| 731 | a.setName("/Test/Encode/Decode/With/Link"); |
| 732 | a.setChildSelector(1); |
| 733 | a.setNonce(100); |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 734 | a.setInterestLifetime(time::seconds(10)); |
| 735 | a.setLink(wire); |
| 736 | |
| 737 | Block interestBlock = a.wireEncode(); |
| 738 | Interest b(interestBlock); |
| 739 | |
| 740 | BOOST_CHECK_EQUAL(a == b, true); |
| 741 | |
| 742 | Link link2 = b.getLink(); |
| 743 | Link::DelegationSet delegations; |
| 744 | delegations = link2.getDelegations(); |
| 745 | |
| 746 | auto i = delegations.begin(); |
| 747 | BOOST_CHECK_EQUAL(std::get<0>(*i), 10); |
| 748 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test1")); |
| 749 | ++i; |
| 750 | BOOST_CHECK_EQUAL(std::get<0>(*i), 20); |
| 751 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test2")); |
| 752 | ++i; |
| 753 | BOOST_CHECK_EQUAL(std::get<0>(*i), 100); |
| 754 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test3")); |
| 755 | |
| 756 | } |
| 757 | |
| 758 | BOOST_AUTO_TEST_CASE(DecodeInterestWithLink) |
| 759 | { |
| 760 | Block interestBlock(InterestWithLink, sizeof(InterestWithLink)); |
| 761 | |
| 762 | ndn::Interest i; |
| 763 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
| 764 | Link link = i.getLink(); |
| 765 | BOOST_CHECK_EQUAL(link.getName(), Name("/local/ndn/prefix")); |
| 766 | Link::DelegationSet delegations = link.getDelegations(); |
| 767 | |
| 768 | auto it = delegations.begin(); |
| 769 | BOOST_CHECK_EQUAL(std::get<0>(*it), 10); |
| 770 | BOOST_CHECK_EQUAL(std::get<1>(*it), Name("local")); |
| 771 | ++it; |
| 772 | BOOST_CHECK_EQUAL(std::get<0>(*it), 20); |
| 773 | BOOST_CHECK_EQUAL(std::get<1>(*it), Name("ndn")); |
| 774 | |
| 775 | BOOST_REQUIRE_NO_THROW(i.getSelectedDelegation()); |
| 776 | BOOST_CHECK_EQUAL(i.getSelectedDelegation(), Name("local")); |
| 777 | } |
| 778 | |
| 779 | BOOST_AUTO_TEST_CASE(DecodeInterestWithLinkNonDecreasingOrder) |
| 780 | { |
| 781 | Block interestBlock(InterestWithLinkNonDecreasingOrder, |
| 782 | sizeof(InterestWithLinkNonDecreasingOrder)); |
| 783 | |
| 784 | ndn::Interest i; |
| 785 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
| 786 | BOOST_REQUIRE_NO_THROW(i.getSelectedDelegation()); |
| 787 | BOOST_CHECK_EQUAL(i.getSelectedDelegation(), Name("ndn")); |
| 788 | } |
| 789 | |
| 790 | BOOST_AUTO_TEST_CASE(LinkObjectMissingContentType) |
| 791 | { |
| 792 | Block interestBlock(InterestWithLinkMissingContentType, |
| 793 | sizeof(InterestWithLinkMissingContentType)); |
| 794 | |
| 795 | ndn::Interest i; |
| 796 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
| 797 | BOOST_REQUIRE_THROW(i.getLink(), Link::Error); |
| 798 | } |
| 799 | |
| 800 | BOOST_AUTO_TEST_CASE(LinkObjectNoMetaInfo) |
| 801 | { |
| 802 | Block interestBlock(InterestWithLinkNoMetaInfo, |
| 803 | sizeof(InterestWithLinkNoMetaInfo)); |
| 804 | |
| 805 | ndn::Interest i; |
| 806 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
| 807 | BOOST_REQUIRE_THROW(i.getLink(), Block::Error); |
| 808 | } |
| 809 | |
| 810 | BOOST_AUTO_TEST_CASE(LinkObjectWrongContentType) |
| 811 | { |
| 812 | Block interestBlock(InterestWithLinkWrongContentType, |
| 813 | sizeof(InterestWithLinkWrongContentType)); |
| 814 | |
| 815 | ndn::Interest i; |
| 816 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
| 817 | BOOST_REQUIRE_THROW(i.getLink(), Link::Error); |
| 818 | } |
| 819 | |
| 820 | BOOST_AUTO_TEST_CASE(InterestContainingSelectedDelegationButNoLink) |
| 821 | { |
| 822 | Block interestBlock(InterestWithSelectedDelegationButNoLink, |
| 823 | sizeof(InterestWithSelectedDelegationButNoLink)); |
| 824 | |
| 825 | ndn::Interest i; |
| 826 | BOOST_REQUIRE_THROW(i.wireDecode(interestBlock), Interest::Error); |
| 827 | } |
| 828 | |
| 829 | BOOST_AUTO_TEST_CASE(SelectedDelegationIsNotNonNegativeInteger) |
| 830 | { |
| 831 | Block interestBlock(InterestWithLinkNotNonIntegerSelectedDelegation, |
| 832 | sizeof(InterestWithLinkNotNonIntegerSelectedDelegation)); |
| 833 | |
| 834 | ndn::Interest i; |
| 835 | BOOST_REQUIRE_THROW(i.wireDecode(interestBlock), tlv::Error); |
| 836 | } |
| 837 | |
| 838 | BOOST_AUTO_TEST_CASE(SelectedDelegationEqualToDelegationCount) |
| 839 | { |
| 840 | Link link1("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 841 | KeyChain keyChain; |
| 842 | keyChain.sign(link1); |
| 843 | Block wire = link1.wireEncode(); |
| 844 | |
| 845 | Interest a; |
| 846 | a.setName("/Test/Encode/Decode/With/Link"); |
| 847 | a.setChildSelector(1); |
| 848 | a.setNonce(100); |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 849 | a.setInterestLifetime(time::seconds(10)); |
| 850 | a.setLink(wire); |
| 851 | BOOST_REQUIRE_THROW(a.setSelectedDelegation(3), Interest::Error); |
| 852 | } |
| 853 | |
| 854 | BOOST_AUTO_TEST_CASE(SelectedDelegationGreaterThanDelegationCount) |
| 855 | { |
| 856 | Link link1("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 857 | KeyChain keyChain; |
| 858 | keyChain.sign(link1); |
| 859 | Block wire = link1.wireEncode(); |
| 860 | |
| 861 | Interest a; |
| 862 | a.setName("/Test/Encode/Decode/With/Link"); |
| 863 | a.setChildSelector(1); |
| 864 | a.setNonce(100); |
Spyridon Mastorakis | c8188b3 | 2015-04-18 18:33:38 -0700 | [diff] [blame] | 865 | a.setInterestLifetime(time::seconds(10)); |
| 866 | a.setLink(wire); |
| 867 | BOOST_REQUIRE_THROW(a.setSelectedDelegation(4), Interest::Error); |
| 868 | } |
| 869 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 870 | BOOST_AUTO_TEST_CASE(Decode) |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 871 | { |
| 872 | Block interestBlock(Interest1, sizeof(Interest1)); |
Alexander Afanasyev | 636e9f1 | 2014-01-07 12:01:03 -0800 | [diff] [blame] | 873 | |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 874 | ndn::Interest i; |
Alexander Afanasyev | 049f8f7 | 2013-12-26 19:07:15 -0800 | [diff] [blame] | 875 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 876 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 877 | BOOST_CHECK_EQUAL(i.getName().toUri(), "/local/ndn/prefix"); |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 878 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds(1000)); |
| 879 | BOOST_CHECK_EQUAL(i.getMinSuffixComponents(), 1); |
| 880 | BOOST_CHECK_EQUAL(i.getMaxSuffixComponents(), 1); |
| 881 | BOOST_CHECK_EQUAL(i.getPublisherPublicKeyLocator().getType(), |
| 882 | static_cast<uint32_t>(KeyLocator::KeyLocator_Name)); |
| 883 | BOOST_CHECK_EQUAL(i.getPublisherPublicKeyLocator().getName(), "ndn:/test/key/locator"); |
| 884 | BOOST_CHECK_EQUAL(i.getChildSelector(), 1); |
| 885 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), false); |
| 886 | BOOST_CHECK_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy"); |
| 887 | BOOST_CHECK_EQUAL(i.getNonce(), 1U); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 888 | } |
| 889 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 890 | BOOST_AUTO_TEST_CASE(DecodeFromStream) |
Alexander Afanasyev | 6835ad8 | 2014-02-12 10:07:20 -0800 | [diff] [blame] | 891 | { |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 892 | boost::iostreams::stream<boost::iostreams::array_source> is( |
| 893 | reinterpret_cast<const char *>(Interest1), sizeof(Interest1)); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 894 | |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame] | 895 | Block interestBlock = Block::fromStream(is); |
Alexander Afanasyev | 6835ad8 | 2014-02-12 10:07:20 -0800 | [diff] [blame] | 896 | |
| 897 | ndn::Interest i; |
| 898 | BOOST_REQUIRE_NO_THROW(i.wireDecode(interestBlock)); |
| 899 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 900 | BOOST_CHECK_EQUAL(i.getName().toUri(), "/local/ndn/prefix"); |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 901 | BOOST_CHECK_EQUAL(i.getInterestLifetime(), time::milliseconds(1000)); |
| 902 | BOOST_CHECK_EQUAL(i.getMinSuffixComponents(), 1); |
| 903 | BOOST_CHECK_EQUAL(i.getMaxSuffixComponents(), 1); |
| 904 | BOOST_CHECK_EQUAL(i.getChildSelector(), 1); |
| 905 | BOOST_CHECK_EQUAL(i.getMustBeFresh(), false); |
| 906 | BOOST_CHECK_EQUAL(i.getExclude().toUri(), "alex,xxxx,*,yyyy"); |
| 907 | BOOST_CHECK_EQUAL(i.getNonce(), 1U); |
Alexander Afanasyev | 6835ad8 | 2014-02-12 10:07:20 -0800 | [diff] [blame] | 908 | } |
| 909 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 910 | BOOST_AUTO_TEST_CASE(Encode) |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 911 | { |
| 912 | ndn::Interest i(ndn::Name("/local/ndn/prefix")); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 913 | i.setInterestLifetime(time::milliseconds(1000)); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 914 | i.setMinSuffixComponents(1); |
| 915 | i.setMaxSuffixComponents(1); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 916 | i.setPublisherPublicKeyLocator(KeyLocator("ndn:/test/key/locator")); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 917 | i.setChildSelector(1); |
| 918 | i.setMustBeFresh(false); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 919 | Exclude exclude; |
| 920 | exclude |
Alexander Afanasyev | 52eb20d | 2014-02-06 18:25:54 -0800 | [diff] [blame] | 921 | .excludeOne(name::Component("alex")) |
| 922 | .excludeRange(name::Component("xxxx"), name::Component("yyyy")); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 923 | i.setExclude(exclude); |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 924 | i.setNonce(1); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 925 | |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 926 | BOOST_CHECK_EQUAL(i.hasWire(), false); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 927 | const Block &wire = i.wireEncode(); |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 928 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
Alexander Afanasyev | 809805d | 2014-02-17 17:20:33 -0800 | [diff] [blame] | 929 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 930 | BOOST_CHECK_EQUAL_COLLECTIONS(Interest1, Interest1 + sizeof(Interest1), |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 931 | wire.begin(), wire.end()); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 932 | |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 933 | const uint8_t* originalWire = wire.wire(); |
| 934 | i.setNonce(2); |
| 935 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
| 936 | BOOST_CHECK_EQUAL(originalWire, i.wireEncode().wire()); |
| 937 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
| 938 | |
| 939 | BOOST_CHECK_EQUAL_COLLECTIONS(Interest2, Interest2 + sizeof(Interest2), |
| 940 | wire.begin(), wire.end()); |
Alexander Afanasyev | a0c5f83 | 2014-06-19 13:27:56 -0700 | [diff] [blame] | 941 | |
| 942 | std::ostringstream strStream; |
| 943 | BOOST_CHECK_NO_THROW(strStream << i); |
| 944 | |
| 945 | BOOST_CHECK_EQUAL(strStream.str(), |
| 946 | "/local/ndn/prefix?" |
| 947 | "ndn.MinSuffixComponents=1&ndn.MaxSuffixComponents=1&" |
Alexander Afanasyev | 117f5ef | 2015-06-03 15:07:24 -0700 | [diff] [blame] | 948 | "ndn.ChildSelector=1&" |
Alexander Afanasyev | a0c5f83 | 2014-06-19 13:27:56 -0700 | [diff] [blame] | 949 | "ndn.InterestLifetime=1000&" |
| 950 | "ndn.Nonce=2&ndn.Exclude=alex,xxxx,*,yyyy"); |
Alexander Afanasyev | c393217 | 2014-07-10 18:53:56 -0700 | [diff] [blame] | 951 | |
| 952 | i.refreshNonce(); |
| 953 | BOOST_CHECK_EQUAL(i.hasWire(), true); |
| 954 | BOOST_CHECK_EQUAL(originalWire, i.wireEncode().wire()); |
| 955 | BOOST_CHECK_NE(i.getNonce(), 2); |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 956 | } |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 957 | |
| 958 | BOOST_AUTO_TEST_CASE(EncodeWithLocalHeader) |
| 959 | { |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 960 | ndn::Interest interest(ndn::Name("/local/ndn/prefix")); |
| 961 | interest.setMustBeFresh(true); |
| 962 | interest.setIncomingFaceId(10); |
| 963 | interest.setNonce(1); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 964 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 965 | BOOST_CHECK(!interest.hasWire()); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 966 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 967 | Block headerBlock = |
| 968 | interest.getLocalControlHeader() |
| 969 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 970 | nfd::LocalControlHeader::ENCODE_NEXT_HOP); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 971 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 972 | BOOST_CHECK(interest.hasWire()); |
| 973 | BOOST_CHECK(headerBlock.hasWire()); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 974 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 975 | BOOST_CHECK_NE(headerBlock.wire(), interest.wireEncode().wire()); |
| 976 | BOOST_CHECK_NE(headerBlock.size(), interest.wireEncode().size()); |
| 977 | BOOST_CHECK_EQUAL(headerBlock.size(), 5); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 978 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 979 | BOOST_CHECK_EQUAL_COLLECTIONS(InterestWithLocalControlHeader, |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 980 | InterestWithLocalControlHeader + 5, |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 981 | headerBlock.begin(), headerBlock.end()); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 982 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 983 | interest.setNonce(1000); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 984 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 985 | Block updatedHeaderBlock = |
| 986 | interest.getLocalControlHeader() |
| 987 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 988 | nfd::LocalControlHeader::ENCODE_NEXT_HOP); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 989 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 990 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 991 | // only length should have changed |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 992 | BOOST_CHECK_EQUAL_COLLECTIONS(updatedHeaderBlock.begin() + 2, updatedHeaderBlock.end(), |
| 993 | headerBlock.begin() + 2, headerBlock.end()); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 994 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 995 | // updating IncomingFaceId that keeps the length |
| 996 | interest.setIncomingFaceId(100); |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 997 | updatedHeaderBlock = |
| 998 | interest.getLocalControlHeader() |
| 999 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 1000 | nfd::LocalControlHeader::ENCODE_NEXT_HOP); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1001 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5); |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 1002 | BOOST_CHECK_NE(*(updatedHeaderBlock.begin() + 4), *(headerBlock.begin() + 4)); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1003 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1004 | // updating IncomingFaceId that increases the length by 2 |
| 1005 | interest.setIncomingFaceId(1000); |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1006 | updatedHeaderBlock = |
| 1007 | interest.getLocalControlHeader() |
| 1008 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 1009 | nfd::LocalControlHeader::ENCODE_NEXT_HOP); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1010 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 6); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1011 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1012 | // adding NextHopId |
| 1013 | interest.setNextHopFaceId(1); |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1014 | updatedHeaderBlock = |
| 1015 | interest.getLocalControlHeader() |
| 1016 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 1017 | nfd::LocalControlHeader::ENCODE_NEXT_HOP); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1018 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 9); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1019 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1020 | // masking IncomingFaceId |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1021 | updatedHeaderBlock = interest.getLocalControlHeader() |
| 1022 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NEXT_HOP); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1023 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 5); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1024 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1025 | // masking NextHopId |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1026 | updatedHeaderBlock = |
| 1027 | interest.getLocalControlHeader() |
| 1028 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1029 | BOOST_CHECK_EQUAL(updatedHeaderBlock.size(), 6); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1030 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1031 | // masking everything |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1032 | BOOST_CHECK_THROW(interest.getLocalControlHeader() |
| 1033 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NONE), |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1034 | nfd::LocalControlHeader::Error); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1035 | } |
| 1036 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1037 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 1038 | BOOST_AUTO_TEST_CASE(DecodeWithLocalHeader) |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1039 | { |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1040 | Block wireBlock(InterestWithLocalControlHeader, sizeof(InterestWithLocalControlHeader)); |
| 1041 | const Block& payload = nfd::LocalControlHeader::getPayload(wireBlock); |
| 1042 | BOOST_REQUIRE_NE(&payload, &wireBlock); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 1043 | |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 1044 | BOOST_CHECK_EQUAL(payload.type(), static_cast<uint32_t>(tlv::Interest)); |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 1045 | BOOST_CHECK_EQUAL(wireBlock.type(), static_cast<uint32_t>(tlv::nfd::LocalControlHeader)); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 1046 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1047 | Interest interest(payload); |
| 1048 | BOOST_CHECK(!interest.getLocalControlHeader().hasIncomingFaceId()); |
| 1049 | BOOST_CHECK(!interest.getLocalControlHeader().hasNextHopFaceId()); |
| 1050 | |
| 1051 | BOOST_REQUIRE_NO_THROW(interest.getLocalControlHeader().wireDecode(wireBlock)); |
| 1052 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1053 | BOOST_CHECK_EQUAL( |
| 1054 | interest.getLocalControlHeader() |
| 1055 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 1056 | nfd::LocalControlHeader::ENCODE_NEXT_HOP).size(), |
| 1057 | 5); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 1058 | |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1059 | BOOST_CHECK_EQUAL(interest.getIncomingFaceId(), 10); |
| 1060 | BOOST_CHECK(!interest.getLocalControlHeader().hasNextHopFaceId()); |
| 1061 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1062 | BOOST_CHECK_THROW(interest.getLocalControlHeader() |
| 1063 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NONE), |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1064 | nfd::LocalControlHeader::Error); |
| 1065 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1066 | BOOST_CHECK_THROW(interest.getLocalControlHeader() |
| 1067 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_NEXT_HOP), |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1068 | nfd::LocalControlHeader::Error); |
| 1069 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1070 | BOOST_CHECK_NO_THROW( |
| 1071 | interest.getLocalControlHeader() |
| 1072 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID)); |
| 1073 | BOOST_CHECK_NO_THROW( |
| 1074 | interest.getLocalControlHeader() |
| 1075 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 1076 | nfd::LocalControlHeader::ENCODE_NEXT_HOP)); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 1077 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1078 | BOOST_CHECK_NE( |
| 1079 | (void*)interest.getLocalControlHeader() |
| 1080 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 1081 | nfd::LocalControlHeader::ENCODE_NEXT_HOP) |
| 1082 | .wire(), |
| 1083 | (void*)wireBlock.wire()); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1084 | |
Jiewen Tan | c759a20 | 2015-01-29 23:31:09 -0800 | [diff] [blame] | 1085 | BOOST_CHECK_EQUAL(interest.getLocalControlHeader() |
| 1086 | .wireEncode(interest, nfd::LocalControlHeader::ENCODE_INCOMING_FACE_ID | |
| 1087 | nfd::LocalControlHeader::ENCODE_NEXT_HOP).size(), |
| 1088 | 5); |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1089 | } |
| 1090 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 1091 | BOOST_AUTO_TEST_CASE(DecodeWithoutLocalHeader) |
Alexander Afanasyev | 5964fb7 | 2014-02-18 12:42:45 -0800 | [diff] [blame] | 1092 | { |
| 1093 | Block wireBlock(InterestWithoutLocalControlHeader, sizeof(InterestWithoutLocalControlHeader)); |
| 1094 | const Block& payload = nfd::LocalControlHeader::getPayload(wireBlock); |
| 1095 | BOOST_CHECK_EQUAL(&payload, &wireBlock); |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 1096 | } |
| 1097 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1098 | BOOST_AUTO_TEST_CASE(MatchesData) |
| 1099 | { |
| 1100 | Interest interest; |
| 1101 | interest.setName("ndn:/A") |
| 1102 | .setMinSuffixComponents(2) |
| 1103 | .setMaxSuffixComponents(2) |
| 1104 | .setPublisherPublicKeyLocator(KeyLocator("ndn:/B")) |
| 1105 | .setExclude(Exclude().excludeBefore(name::Component("C"))); |
| 1106 | |
| 1107 | Data data("ndn:/A/D"); |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 1108 | SignatureSha256WithRsa signature(KeyLocator("ndn:/B")); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1109 | data.setSignature(signature); |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1110 | data.wireEncode(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1111 | BOOST_CHECK_EQUAL(interest.matchesData(data), true); |
| 1112 | |
| 1113 | Data data1 = data; |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1114 | data1.setName("ndn:/A"); // violates MinSuffixComponents |
| 1115 | data1.wireEncode(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1116 | BOOST_CHECK_EQUAL(interest.matchesData(data1), false); |
| 1117 | |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1118 | interest.setMinSuffixComponents(1); |
| 1119 | BOOST_CHECK_EQUAL(interest.matchesData(data1), true); |
| 1120 | interest.setMinSuffixComponents(2); |
| 1121 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1122 | Data data2 = data; |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1123 | data2.setName("ndn:/A/E/F"); // violates MaxSuffixComponents |
| 1124 | data2.wireEncode(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1125 | BOOST_CHECK_EQUAL(interest.matchesData(data2), false); |
| 1126 | |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1127 | interest.setMaxSuffixComponents(3); |
| 1128 | BOOST_CHECK_EQUAL(interest.matchesData(data2), true); |
| 1129 | interest.setMaxSuffixComponents(2); |
| 1130 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1131 | Data data3 = data; |
Yingdi Yu | 4a55705 | 2014-07-09 16:40:37 -0700 | [diff] [blame] | 1132 | SignatureSha256WithRsa signature3(KeyLocator("ndn:/G")); // violates PublisherPublicKeyLocator |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1133 | data3.setSignature(signature3); |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1134 | data3.wireEncode(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1135 | BOOST_CHECK_EQUAL(interest.matchesData(data3), false); |
| 1136 | |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1137 | interest.setPublisherPublicKeyLocator(KeyLocator("ndn:/G")); |
| 1138 | BOOST_CHECK_EQUAL(interest.matchesData(data3), true); |
| 1139 | interest.setPublisherPublicKeyLocator(KeyLocator("ndn:/B")); |
| 1140 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1141 | Data data4 = data; |
Yingdi Yu | bf6a281 | 2014-06-17 15:32:11 -0700 | [diff] [blame] | 1142 | DigestSha256 signature4; // violates PublisherPublicKeyLocator |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1143 | data4.setSignature(signature4); |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1144 | data4.wireEncode(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1145 | BOOST_CHECK_EQUAL(interest.matchesData(data4), false); |
| 1146 | |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1147 | interest.setPublisherPublicKeyLocator(KeyLocator()); |
| 1148 | BOOST_CHECK_EQUAL(interest.matchesData(data4), true); |
| 1149 | interest.setPublisherPublicKeyLocator(KeyLocator("ndn:/B")); |
| 1150 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1151 | Data data5 = data; |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1152 | data5.setName("ndn:/A/C"); // violates Exclude |
| 1153 | data5.wireEncode(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1154 | BOOST_CHECK_EQUAL(interest.matchesData(data5), false); |
| 1155 | |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1156 | interest.setExclude(Exclude().excludeBefore(name::Component("A"))); |
| 1157 | BOOST_CHECK_EQUAL(interest.matchesData(data5), true); |
| 1158 | interest.setExclude(Exclude().excludeBefore(name::Component("C"))); |
| 1159 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1160 | Data data6 = data; |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1161 | data6.setName("ndn:/H/I"); // violates Name |
| 1162 | data6.wireEncode(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1163 | BOOST_CHECK_EQUAL(interest.matchesData(data6), false); |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1164 | |
| 1165 | Data data7 = data; |
| 1166 | data7.setName("ndn:/A/B"); |
| 1167 | data7.wireEncode(); |
| 1168 | |
| 1169 | interest = Interest() |
Alexander Afanasyev | 56860f5 | 2014-11-07 11:51:17 -0800 | [diff] [blame] | 1170 | .setName("/A/B/sha256digest=D548DECEFC4B880720DC9257A8D815E9DF4465E63742EE55C29133055DAA67C2"); |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 1171 | BOOST_CHECK_EQUAL(interest.matchesData(data7), true); |
| 1172 | |
| 1173 | interest = Interest() |
| 1174 | .setName("/A/B/%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00" |
| 1175 | "%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00"); |
| 1176 | BOOST_CHECK_EQUAL(interest.matchesData(data7), false); // violates implicit digest |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 1177 | } |
| 1178 | |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 1179 | BOOST_AUTO_TEST_CASE(InterestFilterMatching) |
| 1180 | { |
| 1181 | BOOST_CHECK_EQUAL(InterestFilter("/a").doesMatch("/a/b"), true); |
| 1182 | BOOST_CHECK_EQUAL(InterestFilter("/a/b").doesMatch("/a/b"), true); |
| 1183 | BOOST_CHECK_EQUAL(InterestFilter("/a/b/c").doesMatch("/a/b"), false); |
| 1184 | |
| 1185 | BOOST_CHECK_EQUAL(InterestFilter("/a", "<b>").doesMatch("/a/b"), true); |
| 1186 | BOOST_CHECK_EQUAL(InterestFilter("/a/b", "<b>").doesMatch("/a/b"), false); |
| 1187 | |
| 1188 | BOOST_CHECK_EQUAL(InterestFilter("/a/b", "<b>").doesMatch("/a/b/c/b"), false); |
| 1189 | BOOST_CHECK_EQUAL(InterestFilter("/a/b", "<>*<b>").doesMatch("/a/b/c/b"), true); |
| 1190 | |
| 1191 | BOOST_CHECK_EQUAL(InterestFilter("/a", "<b>").doesMatch("/a/b/c/d"), false); |
| 1192 | BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>*").doesMatch("/a/b/c/d"), true); |
| 1193 | BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>*").doesMatch("/a/b"), true); |
| 1194 | BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>+").doesMatch("/a/b"), false); |
| 1195 | BOOST_CHECK_EQUAL(InterestFilter("/a", "<b><>+").doesMatch("/a/b/c"), true); |
| 1196 | } |
| 1197 | |
Alexander Afanasyev | 5fa9e9a | 2013-12-24 19:45:07 -0800 | [diff] [blame] | 1198 | BOOST_AUTO_TEST_SUITE_END() |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 1199 | |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 1200 | } // namespace tests |
Alexander Afanasyev | 0abb2da | 2014-01-30 18:07:57 -0800 | [diff] [blame] | 1201 | } // namespace ndn |