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