Spyridon Mastorakis | 3b54e85 | 2015-04-07 08:03:25 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2015 Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 20 | */ |
| 21 | |
| 22 | #include "link.hpp" |
| 23 | #include "security/key-chain.hpp" |
| 24 | #include "security/cryptopp.hpp" |
| 25 | #include "encoding/buffer-stream.hpp" |
| 26 | |
| 27 | #include "boost-test.hpp" |
| 28 | |
| 29 | namespace ndn { |
| 30 | namespace tests { |
| 31 | |
| 32 | const uint8_t LinkTest[] = { |
| 33 | 0x06, 0xda, // Data |
| 34 | 0x07, 0x14, // Name |
| 35 | 0x08, 0x05, |
| 36 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 37 | 0x08, 0x03, |
| 38 | 0x6e, 0x64, 0x6e, |
| 39 | 0x08, 0x06, |
| 40 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 41 | 0x14, 0x07, // MetaInfo |
| 42 | 0x18, 0x01, // ContentType |
| 43 | 0x01, |
| 44 | 0x19, 0x02, // FreshnessPeriod |
| 45 | 0x27, 0x10, |
| 46 | 0x15, 0x1a, // Content |
| 47 | 0x1f, 0x0c, // LinkDelegation |
| 48 | 0x1e, 0x01, // LinkPreference |
| 49 | 0x0a, |
| 50 | 0x07, 0x07, // Name |
| 51 | 0x08, 0x05, |
| 52 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 53 | 0x1f, 0x0a, // LinkDelegation |
| 54 | 0x1e, 0x01, // LinkPreference |
| 55 | 0x14, |
| 56 | 0x07, 0x05, // Name |
| 57 | 0x08, 0x03, |
| 58 | 0x6e, 0x64, 0x6e, |
| 59 | 0x16, 0x1b, // SignatureInfo |
| 60 | 0x1b, 0x01, // SignatureType |
| 61 | 0x01, |
| 62 | 0x1c, 0x16, // KeyLocator |
| 63 | 0x07, 0x14, // Name |
| 64 | 0x08, 0x04, |
| 65 | 0x74, 0x65, 0x73, 0x74, |
| 66 | 0x08, 0x03, |
| 67 | 0x6b, 0x65, 0x79, |
| 68 | 0x08, 0x07, |
| 69 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 70 | 0x17, 0x80, // SignatureValue |
| 71 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 72 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 73 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 74 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 75 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 76 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 77 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 78 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 79 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 80 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 |
| 81 | }; |
| 82 | |
| 83 | const uint8_t IncorrectContentTypeLink[] = { |
| 84 | 0x06, 0xda, // Data |
| 85 | 0x07, 0x14, // Name |
| 86 | 0x08, 0x05, |
| 87 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 88 | 0x08, 0x03, |
| 89 | 0x6e, 0x64, 0x6e, |
| 90 | 0x08, 0x06, |
| 91 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 92 | 0x14, 0x07, // MetaInfo |
| 93 | 0x18, 0x01, // ContentType |
| 94 | 0x02, |
| 95 | 0x19, 0x02, // FreshnessPeriod |
| 96 | 0x27, 0x10, |
| 97 | 0x15, 0x1a, // Content |
| 98 | 0x1f, 0x0c, // LinkDelegation |
| 99 | 0x1e, 0x01, // LinkPreference |
| 100 | 0x0a, |
| 101 | 0x07, 0x07, // Name |
| 102 | 0x08, 0x05, |
| 103 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 104 | 0x1f, 0x0a, // LinkDelegation |
| 105 | 0x1e, 0x01, // LinkPreference |
| 106 | 0x14, |
| 107 | 0x07, 0x05, // Name |
| 108 | 0x08, 0x03, |
| 109 | 0x6e, 0x64, 0x6e, |
| 110 | 0x16, 0x1b, // SignatureInfo |
| 111 | 0x1b, 0x01, // SignatureType |
| 112 | 0x01, |
| 113 | 0x1c, 0x16, // KeyLocator |
| 114 | 0x07, 0x14, // Name |
| 115 | 0x08, 0x04, |
| 116 | 0x74, 0x65, 0x73, 0x74, |
| 117 | 0x08, 0x03, |
| 118 | 0x6b, 0x65, 0x79, |
| 119 | 0x08, 0x07, |
| 120 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 121 | 0x17, 0x80, // SignatureValue |
| 122 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 123 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 124 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 125 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 126 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 127 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 128 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 129 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 130 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 131 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 |
| 132 | }; |
| 133 | |
| 134 | const uint8_t MissingPreferenceLink[] = { |
| 135 | 0x06, 0xd7, // Data |
| 136 | 0x07, 0x14, // Name |
| 137 | 0x08, 0x05, |
| 138 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 139 | 0x08, 0x03, |
| 140 | 0x6e, 0x64, 0x6e, |
| 141 | 0x08, 0x06, |
| 142 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 143 | 0x14, 0x07, // MetaInfo |
| 144 | 0x18, 0x01, // ContentType |
| 145 | 0x01, |
| 146 | 0x19, 0x02, // FreshnessPeriod |
| 147 | 0x27, 0x10, |
| 148 | 0x15, 0x17, // Content |
| 149 | 0x1f, 0x09, // LinkDelegation |
| 150 | 0x07, 0x07, // Name |
| 151 | 0x08, 0x05, |
| 152 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 153 | 0x1f, 0x0a, // LinkDelegation |
| 154 | 0x1e, 0x01, // LinkPreference |
| 155 | 0x14, |
| 156 | 0x07, 0x05, // Name |
| 157 | 0x08, 0x03, |
| 158 | 0x6e, 0x64, 0x6e, |
| 159 | 0x16, 0x1b, // SignatureInfo |
| 160 | 0x1b, 0x01, // SignatureType |
| 161 | 0x01, |
| 162 | 0x1c, 0x16, // KeyLocator |
| 163 | 0x07, 0x14, // Name |
| 164 | 0x08, 0x04, |
| 165 | 0x74, 0x65, 0x73, 0x74, |
| 166 | 0x08, 0x03, |
| 167 | 0x6b, 0x65, 0x79, |
| 168 | 0x08, 0x07, |
| 169 | 0x6c, 0x6f, 0x63, 0x61, 0x74, 0x6f, 0x72, |
| 170 | 0x17, 0x80, // SignatureValue |
| 171 | 0x2f, 0xd6, 0xf1, 0x6e, 0x80, 0x6f, 0x10, 0xbe, 0xb1, 0x6f, 0x3e, 0x31, 0xec, |
| 172 | 0xe3, 0xb9, 0xea, 0x83, 0x30, 0x40, 0x03, 0xfc, 0xa0, 0x13, 0xd9, 0xb3, 0xc6, |
| 173 | 0x25, 0x16, 0x2d, 0xa6, 0x58, 0x41, 0x69, 0x62, 0x56, 0xd8, 0xb3, 0x6a, 0x38, |
| 174 | 0x76, 0x56, 0xea, 0x61, 0xb2, 0x32, 0x70, 0x1c, 0xb6, 0x4d, 0x10, 0x1d, 0xdc, |
| 175 | 0x92, 0x8e, 0x52, 0xa5, 0x8a, 0x1d, 0xd9, 0x96, 0x5e, 0xc0, 0x62, 0x0b, 0xcf, |
| 176 | 0x3a, 0x9d, 0x7f, 0xca, 0xbe, 0xa1, 0x41, 0x71, 0x85, 0x7a, 0x8b, 0x5d, 0xa9, |
| 177 | 0x64, 0xd6, 0x66, 0xb4, 0xe9, 0x8d, 0x0c, 0x28, 0x43, 0xee, 0xa6, 0x64, 0xe8, |
| 178 | 0x55, 0xf6, 0x1c, 0x19, 0x0b, 0xef, 0x99, 0x25, 0x1e, 0xdc, 0x78, 0xb3, 0xa7, |
| 179 | 0xaa, 0x0d, 0x14, 0x58, 0x30, 0xe5, 0x37, 0x6a, 0x6d, 0xdb, 0x56, 0xac, 0xa3, |
| 180 | 0xfc, 0x90, 0x7a, 0xb8, 0x66, 0x9c, 0x0e, 0xf6, 0xb7, 0x64, 0xd1 |
| 181 | }; |
| 182 | |
| 183 | const uint8_t MissingNameLink[] = { |
| 184 | 0x06, 0xd1, // Data |
| 185 | 0x07, 0x14, // Name |
| 186 | 0x08, 0x05, |
| 187 | 0x6c, 0x6f, 0x63, 0x61, 0x6c, |
| 188 | 0x08, 0x03, |
| 189 | 0x6e, 0x64, 0x6e, |
| 190 | 0x08, 0x06, |
| 191 | 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, |
| 192 | 0x14, 0x07, // MetaInfo |
| 193 | 0x18, 0x01, // ContentType |
| 194 | 0x01, |
| 195 | 0x19, 0x02, // FreshnessPeriod |
| 196 | 0x27, 0x10, |
| 197 | 0x15, 0x11, // Content |
| 198 | 0x1f, 0x03, // LinkDelegation |
| 199 | 0x1e, 0x01, // LinkPreference |
| 200 | 0x0a, |
| 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 | }; |
| 230 | |
| 231 | BOOST_AUTO_TEST_SUITE(TestLink) |
| 232 | |
| 233 | BOOST_AUTO_TEST_CASE(PairParsingCheck) |
| 234 | { |
| 235 | Link link("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 236 | BOOST_CHECK_EQUAL(link.getDelegations().size(), static_cast<uint32_t>(3)); |
| 237 | } |
| 238 | |
| 239 | BOOST_AUTO_TEST_CASE(CheckInsertDelegation) |
| 240 | { |
| 241 | Link link("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 242 | |
| 243 | link.addDelegation(30, Name("test4")); |
| 244 | Link::DelegationSet delegations = link.getDelegations(); |
| 245 | int counter = 0; |
| 246 | for (auto i = delegations.begin(); i != delegations.end(); i++) { |
| 247 | counter++; |
| 248 | if (counter == 1) |
| 249 | { |
| 250 | BOOST_CHECK_EQUAL(std::get<0>(*i), 10); |
| 251 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test1")); |
| 252 | } |
| 253 | if (counter == 2) |
| 254 | { |
| 255 | BOOST_CHECK_EQUAL(std::get<0>(*i), 20); |
| 256 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test2")); |
| 257 | } |
| 258 | if (counter == 3) |
| 259 | { |
| 260 | BOOST_CHECK_EQUAL(std::get<0>(*i), 30); |
| 261 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test4")); |
| 262 | } |
| 263 | if (counter == 4) |
| 264 | { |
| 265 | BOOST_CHECK_EQUAL(std::get<0>(*i), 100); |
| 266 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test3")); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | BOOST_AUTO_TEST_CASE(CheckRemoveDelegation) |
| 272 | { |
| 273 | Link link("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 274 | |
| 275 | link.removeDelegation(Name("test2")); |
| 276 | Link::DelegationSet delegations = link.getDelegations(); |
| 277 | int counter = 0; |
| 278 | for (auto i = delegations.begin(); i != delegations.end(); i++) { |
| 279 | counter++; |
| 280 | if (counter == 1) |
| 281 | { |
| 282 | BOOST_CHECK_EQUAL(std::get<0>(*i), 10); |
| 283 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test1")); |
| 284 | } |
| 285 | if (counter == 2) |
| 286 | { |
| 287 | BOOST_CHECK_EQUAL(std::get<0>(*i), 100); |
| 288 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test3")); |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | BOOST_AUTO_TEST_CASE(CheckEncodeDecode) |
| 294 | { |
| 295 | Link link1("test", {{10, "/test1"}, {20, "/test2"}, {100, "/test3"}}); |
| 296 | KeyChain keyChain; |
| 297 | keyChain.sign(link1); |
| 298 | Block wire = link1.wireEncode(); |
| 299 | |
| 300 | Link link2; |
| 301 | link2.wireDecode(wire); |
| 302 | Name name = link2.getName(); |
| 303 | BOOST_CHECK_EQUAL(Name("test"), name); |
| 304 | |
| 305 | Link::DelegationSet delegations; |
| 306 | delegations = link2.getDelegations(); |
| 307 | int counter = 0; |
| 308 | for (auto i = delegations.begin(); i != delegations.end(); i++) { |
| 309 | counter++; |
| 310 | if (counter == 1) |
| 311 | { |
| 312 | BOOST_CHECK_EQUAL(std::get<0>(*i), 10); |
| 313 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test1")); |
| 314 | } |
| 315 | if (counter == 2) |
| 316 | { |
| 317 | BOOST_CHECK_EQUAL(std::get<0>(*i), 20); |
| 318 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test2")); |
| 319 | } |
| 320 | if (counter == 3) |
| 321 | { |
| 322 | BOOST_CHECK_EQUAL(std::get<0>(*i), 100); |
| 323 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test3")); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | Link link3(wire); |
| 328 | name = link3.getName(); |
| 329 | BOOST_CHECK_EQUAL(Name("test"), name); |
| 330 | |
| 331 | delegations = link3.getDelegations(); |
| 332 | counter = 0; |
| 333 | for (auto i = delegations.begin(); i != delegations.end(); i++) { |
| 334 | counter++; |
| 335 | if (counter == 1) |
| 336 | { |
| 337 | BOOST_CHECK_EQUAL(std::get<0>(*i), 10); |
| 338 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test1")); |
| 339 | } |
| 340 | if (counter == 2) |
| 341 | { |
| 342 | BOOST_CHECK_EQUAL(std::get<0>(*i), 20); |
| 343 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test2")); |
| 344 | } |
| 345 | if (counter == 3) |
| 346 | { |
| 347 | BOOST_CHECK_EQUAL(std::get<0>(*i), 100); |
| 348 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("test3")); |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | |
| 353 | BOOST_AUTO_TEST_CASE(Decode) |
| 354 | { |
| 355 | Block linkBlock(LinkTest, sizeof(LinkTest)); |
| 356 | Link link(linkBlock); |
| 357 | BOOST_CHECK_EQUAL(link.getName(), Name("/local/ndn/prefix")); |
| 358 | Link::DelegationSet delegations = link.getDelegations(); |
| 359 | int counter = 0; |
| 360 | |
| 361 | for (auto i = delegations.begin(); i != delegations.end(); i++) { |
| 362 | counter++; |
| 363 | if (counter == 1) |
| 364 | { |
| 365 | BOOST_CHECK_EQUAL(std::get<0>(*i), 10); |
| 366 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("local")); |
| 367 | } |
| 368 | if (counter == 2) |
| 369 | { |
| 370 | BOOST_CHECK_EQUAL(std::get<0>(*i), 20); |
| 371 | BOOST_CHECK_EQUAL(std::get<1>(*i), Name("ndn")); |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | BOOST_AUTO_TEST_CASE(IncorrectContentType) |
| 377 | { |
| 378 | Block linkBlock(IncorrectContentTypeLink, sizeof(IncorrectContentTypeLink)); |
| 379 | Link link; |
| 380 | BOOST_REQUIRE_THROW(link.wireDecode(linkBlock), Link::Error); |
| 381 | } |
| 382 | |
| 383 | BOOST_AUTO_TEST_CASE(MissingPreferenceEncoding) |
| 384 | { |
| 385 | Block linkBlock(MissingPreferenceLink, sizeof(MissingPreferenceLink)); |
| 386 | Link link; |
| 387 | BOOST_REQUIRE_THROW(link.wireDecode(linkBlock), Link::Error); |
| 388 | } |
| 389 | |
| 390 | BOOST_AUTO_TEST_CASE(MissingNameEncoding) |
| 391 | { |
| 392 | Block linkBlock(MissingNameLink, sizeof(MissingNameLink)); |
| 393 | Link link; |
| 394 | BOOST_REQUIRE_THROW(link.wireDecode(linkBlock), Link::Error); |
| 395 | } |
| 396 | |
| 397 | BOOST_AUTO_TEST_SUITE_END() |
| 398 | |
| 399 | } // namespace tests |
| 400 | } // namespace ndn |