Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014 Regents of the University of California, |
| 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology |
| 9 | * |
| 10 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 11 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 12 | * |
| 13 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 14 | * of the GNU General Public License as published by the Free Software Foundation, |
| 15 | * either version 3 of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 18 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 19 | * PURPOSE. See the GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along with |
| 22 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 23 | **/ |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 24 | |
| 25 | #include "mgmt/face-manager.hpp" |
| 26 | #include "mgmt/internal-face.hpp" |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 27 | #include "mgmt/face-status-publisher.hpp" |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 28 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 29 | #include "face/face.hpp" |
| 30 | #include "../face/dummy-face.hpp" |
| 31 | #include "fw/face-table.hpp" |
| 32 | #include "fw/forwarder.hpp" |
| 33 | |
| 34 | #include "common.hpp" |
| 35 | #include "tests/test-common.hpp" |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 36 | #include "validation-common.hpp" |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 37 | #include "face-status-publisher-common.hpp" |
| 38 | |
| 39 | #include <ndn-cpp-dev/encoding/tlv.hpp> |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 40 | #include <ndn-cpp-dev/management/nfd-face-event-notification.hpp> |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 41 | |
| 42 | namespace nfd { |
| 43 | namespace tests { |
| 44 | |
| 45 | NFD_LOG_INIT("FaceManagerTest"); |
| 46 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 47 | class FaceManagerTestFace : public DummyFace |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 48 | { |
| 49 | public: |
| 50 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 51 | FaceManagerTestFace() |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 52 | : m_closeFired(false) |
| 53 | { |
| 54 | |
| 55 | } |
| 56 | |
| 57 | virtual |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 58 | ~FaceManagerTestFace() |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 59 | { |
| 60 | |
| 61 | } |
| 62 | |
| 63 | virtual void |
| 64 | close() |
| 65 | { |
| 66 | m_closeFired = true; |
| 67 | } |
| 68 | |
| 69 | bool |
| 70 | didCloseFire() const |
| 71 | { |
| 72 | return m_closeFired; |
| 73 | } |
| 74 | |
| 75 | private: |
| 76 | bool m_closeFired; |
| 77 | }; |
| 78 | |
| 79 | class TestFaceTable : public FaceTable |
| 80 | { |
| 81 | public: |
| 82 | TestFaceTable(Forwarder& forwarder) |
| 83 | : FaceTable(forwarder), |
| 84 | m_addFired(false), |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 85 | m_getFired(false), |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 86 | m_dummy(make_shared<FaceManagerTestFace>()) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 87 | { |
| 88 | |
| 89 | } |
| 90 | |
| 91 | virtual |
| 92 | ~TestFaceTable() |
| 93 | { |
| 94 | |
| 95 | } |
| 96 | |
| 97 | virtual void |
| 98 | add(shared_ptr<Face> face) |
| 99 | { |
| 100 | m_addFired = true; |
| 101 | } |
| 102 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 103 | virtual shared_ptr<Face> |
| 104 | get(FaceId id) const |
| 105 | { |
| 106 | m_getFired = true; |
| 107 | return m_dummy; |
| 108 | } |
| 109 | |
| 110 | bool |
| 111 | didAddFire() const |
| 112 | { |
| 113 | return m_addFired; |
| 114 | } |
| 115 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 116 | bool |
| 117 | didGetFire() const |
| 118 | { |
| 119 | return m_getFired; |
| 120 | } |
| 121 | |
| 122 | void |
| 123 | reset() |
| 124 | { |
| 125 | m_addFired = false; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 126 | m_getFired = false; |
| 127 | } |
| 128 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 129 | shared_ptr<FaceManagerTestFace>& |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 130 | getDummyFace() |
| 131 | { |
| 132 | return m_dummy; |
| 133 | } |
| 134 | |
| 135 | private: |
| 136 | bool m_addFired; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 137 | mutable bool m_getFired; |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 138 | shared_ptr<FaceManagerTestFace> m_dummy; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 139 | }; |
| 140 | |
| 141 | |
| 142 | class TestFaceTableFixture : public BaseFixture |
| 143 | { |
| 144 | public: |
| 145 | TestFaceTableFixture() |
| 146 | : m_faceTable(m_forwarder) |
| 147 | { |
| 148 | |
| 149 | } |
| 150 | |
| 151 | virtual |
| 152 | ~TestFaceTableFixture() |
| 153 | { |
| 154 | |
| 155 | } |
| 156 | |
| 157 | protected: |
| 158 | Forwarder m_forwarder; |
| 159 | TestFaceTable m_faceTable; |
| 160 | }; |
| 161 | |
| 162 | class TestFaceManagerCommon |
| 163 | { |
| 164 | public: |
| 165 | TestFaceManagerCommon() |
| 166 | : m_face(make_shared<InternalFace>()), |
| 167 | m_callbackFired(false) |
| 168 | { |
| 169 | |
| 170 | } |
| 171 | |
| 172 | virtual |
| 173 | ~TestFaceManagerCommon() |
| 174 | { |
| 175 | |
| 176 | } |
| 177 | |
| 178 | shared_ptr<InternalFace>& |
| 179 | getFace() |
| 180 | { |
| 181 | return m_face; |
| 182 | } |
| 183 | |
| 184 | void |
| 185 | validateControlResponseCommon(const Data& response, |
| 186 | const Name& expectedName, |
| 187 | uint32_t expectedCode, |
| 188 | const std::string& expectedText, |
| 189 | ControlResponse& control) |
| 190 | { |
| 191 | m_callbackFired = true; |
| 192 | Block controlRaw = response.getContent().blockFromValue(); |
| 193 | |
| 194 | control.wireDecode(controlRaw); |
| 195 | |
| 196 | // NFD_LOG_DEBUG("received control response" |
| 197 | // << " Name: " << response.getName() |
| 198 | // << " code: " << control.getCode() |
| 199 | // << " text: " << control.getText()); |
| 200 | |
| 201 | BOOST_CHECK_EQUAL(response.getName(), expectedName); |
| 202 | BOOST_CHECK_EQUAL(control.getCode(), expectedCode); |
| 203 | BOOST_CHECK_EQUAL(control.getText(), expectedText); |
| 204 | } |
| 205 | |
| 206 | void |
| 207 | validateControlResponse(const Data& response, |
| 208 | const Name& expectedName, |
| 209 | uint32_t expectedCode, |
| 210 | const std::string& expectedText) |
| 211 | { |
| 212 | ControlResponse control; |
| 213 | validateControlResponseCommon(response, expectedName, |
| 214 | expectedCode, expectedText, control); |
| 215 | |
| 216 | if (!control.getBody().empty()) |
| 217 | { |
| 218 | BOOST_FAIL("found unexpected control response body"); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | void |
| 223 | validateControlResponse(const Data& response, |
| 224 | const Name& expectedName, |
| 225 | uint32_t expectedCode, |
| 226 | const std::string& expectedText, |
| 227 | const Block& expectedBody) |
| 228 | { |
| 229 | ControlResponse control; |
| 230 | validateControlResponseCommon(response, expectedName, |
| 231 | expectedCode, expectedText, control); |
| 232 | |
| 233 | BOOST_REQUIRE(!control.getBody().empty()); |
| 234 | BOOST_REQUIRE(control.getBody().value_size() == expectedBody.value_size()); |
| 235 | |
| 236 | BOOST_CHECK(memcmp(control.getBody().value(), expectedBody.value(), |
| 237 | expectedBody.value_size()) == 0); |
| 238 | |
| 239 | } |
| 240 | |
| 241 | bool |
| 242 | didCallbackFire() const |
| 243 | { |
| 244 | return m_callbackFired; |
| 245 | } |
| 246 | |
| 247 | void |
| 248 | resetCallbackFired() |
| 249 | { |
| 250 | m_callbackFired = false; |
| 251 | } |
| 252 | |
| 253 | protected: |
| 254 | shared_ptr<InternalFace> m_face; |
| 255 | |
| 256 | private: |
| 257 | bool m_callbackFired; |
| 258 | }; |
| 259 | |
| 260 | class FaceManagerFixture : public TestFaceTableFixture, public TestFaceManagerCommon |
| 261 | { |
| 262 | public: |
| 263 | FaceManagerFixture() |
| 264 | : m_manager(m_faceTable, m_face) |
| 265 | { |
| 266 | m_manager.setConfigFile(m_config); |
| 267 | } |
| 268 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 269 | virtual |
| 270 | ~FaceManagerFixture() |
| 271 | { |
| 272 | |
| 273 | } |
| 274 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 275 | void |
| 276 | parseConfig(const std::string configuration, bool isDryRun) |
| 277 | { |
| 278 | m_config.parse(configuration, isDryRun, "dummy-config"); |
| 279 | } |
| 280 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 281 | FaceManager& |
| 282 | getManager() |
| 283 | { |
| 284 | return m_manager; |
| 285 | } |
| 286 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 287 | void |
| 288 | addInterestRule(const std::string& regex, |
| 289 | ndn::IdentityCertificate& certificate) |
| 290 | { |
| 291 | m_manager.addInterestRule(regex, certificate); |
| 292 | } |
| 293 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 294 | bool |
| 295 | didFaceTableAddFire() const |
| 296 | { |
| 297 | return m_faceTable.didAddFire(); |
| 298 | } |
| 299 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 300 | bool |
| 301 | didFaceTableGetFire() const |
| 302 | { |
| 303 | return m_faceTable.didGetFire(); |
| 304 | } |
| 305 | |
| 306 | void |
| 307 | resetFaceTable() |
| 308 | { |
| 309 | m_faceTable.reset(); |
| 310 | } |
| 311 | |
| 312 | private: |
| 313 | FaceManager m_manager; |
| 314 | ConfigFile m_config; |
| 315 | }; |
| 316 | |
| 317 | BOOST_FIXTURE_TEST_SUITE(MgmtFaceManager, FaceManagerFixture) |
| 318 | |
| 319 | bool |
| 320 | isExpectedException(const ConfigFile::Error& error, const std::string& expectedMessage) |
| 321 | { |
| 322 | if (error.what() != expectedMessage) |
| 323 | { |
| 324 | NFD_LOG_ERROR("expected: " << expectedMessage << "\tgot: " << error.what()); |
| 325 | } |
| 326 | return error.what() == expectedMessage; |
| 327 | } |
| 328 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 329 | #ifdef HAVE_UNIX_SOCKETS |
| 330 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 331 | BOOST_AUTO_TEST_CASE(TestProcessSectionUnix) |
| 332 | { |
| 333 | const std::string CONFIG = |
| 334 | "face_system\n" |
| 335 | "{\n" |
| 336 | " unix\n" |
| 337 | " {\n" |
| 338 | " listen yes\n" |
| 339 | " path /tmp/nfd.sock\n" |
| 340 | " }\n" |
| 341 | "}\n"; |
| 342 | BOOST_TEST_CHECKPOINT("Calling parse"); |
| 343 | BOOST_CHECK_NO_THROW(parseConfig(CONFIG, false)); |
| 344 | } |
| 345 | |
| 346 | BOOST_AUTO_TEST_CASE(TestProcessSectionUnixDryRun) |
| 347 | { |
| 348 | const std::string CONFIG = |
| 349 | "face_system\n" |
| 350 | "{\n" |
| 351 | " unix\n" |
| 352 | " {\n" |
| 353 | " listen yes\n" |
| 354 | " path /var/run/nfd.sock\n" |
| 355 | " }\n" |
| 356 | "}\n"; |
| 357 | |
| 358 | BOOST_CHECK_NO_THROW(parseConfig(CONFIG, true)); |
| 359 | } |
| 360 | |
| 361 | BOOST_AUTO_TEST_CASE(TestProcessSectionUnixBadListen) |
| 362 | { |
| 363 | const std::string CONFIG = |
| 364 | "face_system\n" |
| 365 | "{\n" |
| 366 | " unix\n" |
| 367 | " {\n" |
| 368 | " listen hello\n" |
| 369 | " }\n" |
| 370 | "}\n"; |
| 371 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 372 | bind(&isExpectedException, _1, |
| 373 | "Invalid value for option \"listen\" in \"unix\" section")); |
| 374 | } |
| 375 | |
| 376 | BOOST_AUTO_TEST_CASE(TestProcessSectionUnixUnknownOption) |
| 377 | { |
| 378 | const std::string CONFIG = |
| 379 | "face_system\n" |
| 380 | "{\n" |
| 381 | " unix\n" |
| 382 | " {\n" |
| 383 | " hello\n" |
| 384 | " }\n" |
| 385 | "}\n"; |
| 386 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 387 | bind(&isExpectedException, _1, |
| 388 | "Unrecognized option \"hello\" in \"unix\" section")); |
| 389 | } |
| 390 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 391 | #endif // HAVE_UNIX_SOCKETS |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 392 | |
| 393 | |
| 394 | BOOST_AUTO_TEST_CASE(TestProcessSectionTcp) |
| 395 | { |
| 396 | const std::string CONFIG = |
| 397 | "face_system\n" |
| 398 | "{\n" |
| 399 | " tcp\n" |
| 400 | " {\n" |
| 401 | " listen yes\n" |
| 402 | " port 6363\n" |
Steve DiBenedetto | 9515287 | 2014-04-11 12:40:59 -0600 | [diff] [blame^] | 403 | " enable_v4 yes\n" |
| 404 | " enable_v6 yes\n" |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 405 | " }\n" |
| 406 | "}\n"; |
| 407 | try |
| 408 | { |
| 409 | parseConfig(CONFIG, false); |
| 410 | } |
| 411 | catch (const std::runtime_error& e) |
| 412 | { |
| 413 | const std::string reason = e.what(); |
| 414 | if (reason.find("Address in use") != std::string::npos) |
| 415 | { |
| 416 | BOOST_FAIL(reason); |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | BOOST_AUTO_TEST_CASE(TestProcessSectionTcpDryRun) |
| 422 | { |
| 423 | const std::string CONFIG = |
| 424 | "face_system\n" |
| 425 | "{\n" |
| 426 | " tcp\n" |
| 427 | " {\n" |
| 428 | " listen yes\n" |
| 429 | " port 6363\n" |
Steve DiBenedetto | 9515287 | 2014-04-11 12:40:59 -0600 | [diff] [blame^] | 430 | " enable_v4 yes\n" |
| 431 | " enable_v6 yes\n" |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 432 | " }\n" |
| 433 | "}\n"; |
| 434 | BOOST_CHECK_NO_THROW(parseConfig(CONFIG, true)); |
| 435 | } |
| 436 | |
| 437 | BOOST_AUTO_TEST_CASE(TestProcessSectionTcpBadListen) |
| 438 | { |
| 439 | const std::string CONFIG = |
| 440 | "face_system\n" |
| 441 | "{\n" |
| 442 | " tcp\n" |
| 443 | " {\n" |
| 444 | " listen hello\n" |
| 445 | " }\n" |
| 446 | "}\n"; |
| 447 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 448 | bind(&isExpectedException, _1, |
| 449 | "Invalid value for option \"listen\" in \"tcp\" section")); |
| 450 | } |
| 451 | |
Steve DiBenedetto | 9515287 | 2014-04-11 12:40:59 -0600 | [diff] [blame^] | 452 | BOOST_AUTO_TEST_CASE(TestProcessSectionTcpChannelsDisabled) |
| 453 | { |
| 454 | const std::string CONFIG = |
| 455 | "face_system\n" |
| 456 | "{\n" |
| 457 | " tcp\n" |
| 458 | " {\n" |
| 459 | " port 6363\n" |
| 460 | " enable_v4 no\n" |
| 461 | " enable_v6 no\n" |
| 462 | " }\n" |
| 463 | "}\n"; |
| 464 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 465 | bind(&isExpectedException, _1, |
| 466 | "IPv4 and IPv6 channels have been disabled." |
| 467 | " Remove \"tcp\" section to disable TCP channels or" |
| 468 | " re-enable at least one channel type.")); |
| 469 | } |
| 470 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 471 | BOOST_AUTO_TEST_CASE(TestProcessSectionTcpUnknownOption) |
| 472 | { |
| 473 | const std::string CONFIG = |
| 474 | "face_system\n" |
| 475 | "{\n" |
| 476 | " tcp\n" |
| 477 | " {\n" |
| 478 | " hello\n" |
| 479 | " }\n" |
| 480 | "}\n"; |
| 481 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 482 | bind(&isExpectedException, _1, |
| 483 | "Unrecognized option \"hello\" in \"tcp\" section")); |
| 484 | } |
| 485 | |
| 486 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdp) |
| 487 | { |
| 488 | const std::string CONFIG = |
| 489 | "face_system\n" |
| 490 | "{\n" |
| 491 | " udp\n" |
| 492 | " {\n" |
| 493 | " port 6363\n" |
Steve DiBenedetto | 9515287 | 2014-04-11 12:40:59 -0600 | [diff] [blame^] | 494 | " enable_v4 yes\n" |
| 495 | " enable_v6 yes\n" |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 496 | " idle_timeout 30\n" |
| 497 | " keep_alive_interval 25\n" |
| 498 | " mcast yes\n" |
| 499 | " mcast_port 56363\n" |
| 500 | " mcast_group 224.0.23.170\n" |
| 501 | " }\n" |
| 502 | "}\n"; |
| 503 | BOOST_CHECK_NO_THROW(parseConfig(CONFIG, false)); |
| 504 | } |
| 505 | |
| 506 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpDryRun) |
| 507 | { |
| 508 | const std::string CONFIG = |
| 509 | "face_system\n" |
| 510 | "{\n" |
| 511 | " udp\n" |
| 512 | " {\n" |
| 513 | " port 6363\n" |
| 514 | " idle_timeout 30\n" |
| 515 | " keep_alive_interval 25\n" |
| 516 | " mcast yes\n" |
| 517 | " mcast_port 56363\n" |
| 518 | " mcast_group 224.0.23.170\n" |
| 519 | " }\n" |
| 520 | "}\n"; |
| 521 | BOOST_CHECK_NO_THROW(parseConfig(CONFIG, true)); |
| 522 | } |
| 523 | |
| 524 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpBadIdleTimeout) |
| 525 | { |
| 526 | const std::string CONFIG = |
| 527 | "face_system\n" |
| 528 | "{\n" |
| 529 | " udp\n" |
| 530 | " {\n" |
| 531 | " idle_timeout hello\n" |
| 532 | " }\n" |
| 533 | "}\n"; |
| 534 | |
| 535 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 536 | bind(&isExpectedException, _1, |
| 537 | "Invalid value for option \"idle_timeout\" in \"udp\" section")); |
| 538 | } |
| 539 | |
| 540 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpBadMcast) |
| 541 | { |
| 542 | const std::string CONFIG = |
| 543 | "face_system\n" |
| 544 | "{\n" |
| 545 | " udp\n" |
| 546 | " {\n" |
| 547 | " mcast hello\n" |
| 548 | " }\n" |
| 549 | "}\n"; |
| 550 | |
| 551 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 552 | bind(&isExpectedException, _1, |
| 553 | "Invalid value for option \"mcast\" in \"udp\" section")); |
| 554 | } |
| 555 | |
| 556 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpBadMcastGroup) |
| 557 | { |
| 558 | const std::string CONFIG = |
| 559 | "face_system\n" |
| 560 | "{\n" |
| 561 | " udp\n" |
| 562 | " {\n" |
| 563 | " mcast no\n" |
| 564 | " mcast_port 50\n" |
| 565 | " mcast_group hello\n" |
| 566 | " }\n" |
| 567 | "}\n"; |
| 568 | |
| 569 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 570 | bind(&isExpectedException, _1, |
| 571 | "Invalid value for option \"mcast_group\" in \"udp\" section")); |
| 572 | } |
| 573 | |
| 574 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpBadMcastGroupV6) |
| 575 | { |
| 576 | const std::string CONFIG = |
| 577 | "face_system\n" |
| 578 | "{\n" |
| 579 | " udp\n" |
| 580 | " {\n" |
| 581 | " mcast no\n" |
| 582 | " mcast_port 50\n" |
| 583 | " mcast_group ::1\n" |
| 584 | " }\n" |
| 585 | "}\n"; |
| 586 | |
| 587 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 588 | bind(&isExpectedException, _1, |
| 589 | "Invalid value for option \"mcast_group\" in \"udp\" section")); |
| 590 | } |
| 591 | |
Steve DiBenedetto | 9515287 | 2014-04-11 12:40:59 -0600 | [diff] [blame^] | 592 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpChannelsDisabled) |
| 593 | { |
| 594 | const std::string CONFIG = |
| 595 | "face_system\n" |
| 596 | "{\n" |
| 597 | " udp\n" |
| 598 | " {\n" |
| 599 | " port 6363\n" |
| 600 | " enable_v4 no\n" |
| 601 | " enable_v6 no\n" |
| 602 | " idle_timeout 30\n" |
| 603 | " keep_alive_interval 25\n" |
| 604 | " mcast yes\n" |
| 605 | " mcast_port 56363\n" |
| 606 | " mcast_group 224.0.23.170\n" |
| 607 | " }\n" |
| 608 | "}\n"; |
| 609 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 610 | bind(&isExpectedException, _1, |
| 611 | "IPv4 and IPv6 channels have been disabled." |
| 612 | " Remove \"udp\" section to disable UDP channels or" |
| 613 | " re-enable at least one channel type.")); |
| 614 | } |
| 615 | |
| 616 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpConflictingMcast) |
| 617 | { |
| 618 | const std::string CONFIG = |
| 619 | "face_system\n" |
| 620 | "{\n" |
| 621 | " udp\n" |
| 622 | " {\n" |
| 623 | " port 6363\n" |
| 624 | " enable_v4 no\n" |
| 625 | " enable_v6 yes\n" |
| 626 | " idle_timeout 30\n" |
| 627 | " keep_alive_interval 25\n" |
| 628 | " mcast yes\n" |
| 629 | " mcast_port 56363\n" |
| 630 | " mcast_group 224.0.23.170\n" |
| 631 | " }\n" |
| 632 | "}\n"; |
| 633 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 634 | bind(&isExpectedException, _1, |
| 635 | "IPv4 multicast requested, but IPv4 channels" |
| 636 | " have been disabled (conflicting configuration options set)")); |
| 637 | } |
| 638 | |
| 639 | |
| 640 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 641 | BOOST_AUTO_TEST_CASE(TestProcessSectionUdpUnknownOption) |
| 642 | { |
| 643 | const std::string CONFIG = |
| 644 | "face_system\n" |
| 645 | "{\n" |
| 646 | " udp\n" |
| 647 | " {\n" |
| 648 | " hello\n" |
| 649 | " }\n" |
| 650 | "}\n"; |
| 651 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 652 | bind(&isExpectedException, _1, |
| 653 | "Unrecognized option \"hello\" in \"udp\" section")); |
| 654 | } |
| 655 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 656 | #ifdef HAVE_PCAP |
| 657 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 658 | BOOST_AUTO_TEST_CASE(TestProcessSectionEther) |
| 659 | { |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 660 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 661 | const std::string CONFIG = |
| 662 | "face_system\n" |
| 663 | "{\n" |
| 664 | " ether\n" |
| 665 | " {\n" |
| 666 | " mcast yes\n" |
| 667 | " mcast_group 01:00:5E:00:17:AA\n" |
| 668 | " }\n" |
| 669 | "}\n"; |
| 670 | |
| 671 | BOOST_CHECK_NO_THROW(parseConfig(CONFIG, false)); |
| 672 | } |
| 673 | |
| 674 | BOOST_AUTO_TEST_CASE(TestProcessSectionEtherDryRun) |
| 675 | { |
| 676 | const std::string CONFIG = |
| 677 | "face_system\n" |
| 678 | "{\n" |
| 679 | " ether\n" |
| 680 | " {\n" |
| 681 | " mcast yes\n" |
| 682 | " mcast_group 01:00:5E:00:17:AA\n" |
| 683 | " }\n" |
| 684 | "}\n"; |
| 685 | |
| 686 | BOOST_CHECK_NO_THROW(parseConfig(CONFIG, true)); |
| 687 | } |
| 688 | |
| 689 | BOOST_AUTO_TEST_CASE(TestProcessSectionEtherBadMcast) |
| 690 | { |
| 691 | const std::string CONFIG = |
| 692 | "face_system\n" |
| 693 | "{\n" |
| 694 | " ether\n" |
| 695 | " {\n" |
| 696 | " mcast hello\n" |
| 697 | " }\n" |
| 698 | "}\n"; |
| 699 | |
| 700 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 701 | bind(&isExpectedException, _1, |
| 702 | "Invalid value for option \"mcast\" in \"ether\" section")); |
| 703 | } |
| 704 | |
| 705 | BOOST_AUTO_TEST_CASE(TestProcessSectionEtherBadMcastGroup) |
| 706 | { |
| 707 | const std::string CONFIG = |
| 708 | "face_system\n" |
| 709 | "{\n" |
| 710 | " ether\n" |
| 711 | " {\n" |
| 712 | " mcast yes\n" |
| 713 | " mcast_group\n" |
| 714 | " }\n" |
| 715 | "}\n"; |
| 716 | |
| 717 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 718 | bind(&isExpectedException, _1, |
| 719 | "Invalid value for option \"mcast_group\" in \"ether\" section")); |
| 720 | } |
| 721 | |
| 722 | BOOST_AUTO_TEST_CASE(TestProcessSectionEtherUnknownOption) |
| 723 | { |
| 724 | const std::string CONFIG = |
| 725 | "face_system\n" |
| 726 | "{\n" |
| 727 | " ether\n" |
| 728 | " {\n" |
| 729 | " hello\n" |
| 730 | " }\n" |
| 731 | "}\n"; |
| 732 | BOOST_CHECK_EXCEPTION(parseConfig(CONFIG, false), ConfigFile::Error, |
| 733 | bind(&isExpectedException, _1, |
| 734 | "Unrecognized option \"hello\" in \"ether\" section")); |
| 735 | } |
| 736 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 737 | #endif |
| 738 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 739 | BOOST_AUTO_TEST_CASE(TestFireInterestFilter) |
| 740 | { |
| 741 | shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/faces")); |
| 742 | |
| 743 | getFace()->onReceiveData += |
| 744 | bind(&FaceManagerFixture::validateControlResponse, this, _1, |
| 745 | command->getName(), 400, "Malformed command"); |
| 746 | |
| 747 | getFace()->sendInterest(*command); |
Junxiao Shi | 16d1b7d | 2014-03-27 21:29:09 -0700 | [diff] [blame] | 748 | g_io.run_one(); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 749 | |
| 750 | BOOST_REQUIRE(didCallbackFire()); |
| 751 | } |
| 752 | |
| 753 | BOOST_AUTO_TEST_CASE(MalformedCommmand) |
| 754 | { |
| 755 | shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/faces")); |
| 756 | |
| 757 | getFace()->onReceiveData += |
| 758 | bind(&FaceManagerFixture::validateControlResponse, this, _1, |
| 759 | command->getName(), 400, "Malformed command"); |
| 760 | |
| 761 | getManager().onFaceRequest(*command); |
| 762 | |
| 763 | BOOST_REQUIRE(didCallbackFire()); |
| 764 | } |
| 765 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 766 | BOOST_AUTO_TEST_CASE(UnsignedCommand) |
| 767 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 768 | ControlParameters parameters; |
| 769 | parameters.setUri("tcp://127.0.0.1"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 770 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 771 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 772 | |
| 773 | Name commandName("/localhost/nfd/faces"); |
| 774 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 775 | commandName.append(encodedParameters); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 776 | |
| 777 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 778 | |
| 779 | getFace()->onReceiveData += |
| 780 | bind(&FaceManagerFixture::validateControlResponse, this, _1, |
| 781 | command->getName(), 401, "Signature required"); |
| 782 | |
| 783 | getManager().onFaceRequest(*command); |
| 784 | |
| 785 | BOOST_REQUIRE(didCallbackFire()); |
| 786 | } |
| 787 | |
| 788 | BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand, UnauthorizedCommandFixture<FaceManagerFixture>) |
| 789 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 790 | ControlParameters parameters; |
| 791 | parameters.setUri("tcp://127.0.0.1"); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 792 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 793 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 794 | |
| 795 | Name commandName("/localhost/nfd/faces"); |
| 796 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 797 | commandName.append(encodedParameters); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 798 | |
| 799 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 800 | generateCommand(*command); |
| 801 | |
| 802 | getFace()->onReceiveData += |
| 803 | bind(&FaceManagerFixture::validateControlResponse, this, _1, |
| 804 | command->getName(), 403, "Unauthorized command"); |
| 805 | |
| 806 | getManager().onFaceRequest(*command); |
| 807 | |
| 808 | BOOST_REQUIRE(didCallbackFire()); |
| 809 | } |
| 810 | |
| 811 | template <typename T> class AuthorizedCommandFixture : public CommandFixture<T> |
| 812 | { |
| 813 | public: |
| 814 | AuthorizedCommandFixture() |
| 815 | { |
| 816 | const std::string regex = "^<localhost><nfd><faces>"; |
| 817 | T::addInterestRule(regex, *CommandFixture<T>::m_certificate); |
| 818 | } |
| 819 | |
| 820 | virtual |
| 821 | ~AuthorizedCommandFixture() |
| 822 | { |
| 823 | |
| 824 | } |
| 825 | }; |
| 826 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 827 | BOOST_FIXTURE_TEST_CASE(UnsupportedCommand, AuthorizedCommandFixture<FaceManagerFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 828 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 829 | ControlParameters parameters; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 830 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 831 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 832 | |
| 833 | Name commandName("/localhost/nfd/faces"); |
| 834 | commandName.append("unsupported"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 835 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 836 | |
| 837 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 838 | generateCommand(*command); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 839 | |
| 840 | getFace()->onReceiveData += |
| 841 | bind(&FaceManagerFixture::validateControlResponse, this, _1, |
| 842 | command->getName(), 501, "Unsupported command"); |
| 843 | |
| 844 | getManager().onFaceRequest(*command); |
| 845 | |
| 846 | BOOST_REQUIRE(didCallbackFire()); |
| 847 | } |
| 848 | |
| 849 | class ValidatedFaceRequestFixture : public TestFaceTableFixture, |
| 850 | public TestFaceManagerCommon, |
| 851 | public FaceManager |
| 852 | { |
| 853 | public: |
| 854 | |
| 855 | ValidatedFaceRequestFixture() |
| 856 | : FaceManager(TestFaceTableFixture::m_faceTable, TestFaceManagerCommon::m_face), |
| 857 | m_createFaceFired(false), |
| 858 | m_destroyFaceFired(false) |
| 859 | { |
| 860 | |
| 861 | } |
| 862 | |
| 863 | virtual void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 864 | createFace(const Interest& request, |
| 865 | ControlParameters& parameters) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 866 | { |
| 867 | m_createFaceFired = true; |
| 868 | } |
| 869 | |
| 870 | virtual void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 871 | destroyFace(const Interest& request, |
| 872 | ControlParameters& parameters) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 873 | { |
| 874 | m_destroyFaceFired = true; |
| 875 | } |
| 876 | |
| 877 | virtual |
| 878 | ~ValidatedFaceRequestFixture() |
| 879 | { |
| 880 | |
| 881 | } |
| 882 | |
| 883 | bool |
| 884 | didCreateFaceFire() const |
| 885 | { |
| 886 | return m_createFaceFired; |
| 887 | } |
| 888 | |
| 889 | bool |
| 890 | didDestroyFaceFire() const |
| 891 | { |
| 892 | return m_destroyFaceFired; |
| 893 | } |
| 894 | |
| 895 | private: |
| 896 | bool m_createFaceFired; |
| 897 | bool m_destroyFaceFired; |
| 898 | }; |
| 899 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 900 | BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestBadOptionParse, |
| 901 | AuthorizedCommandFixture<ValidatedFaceRequestFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 902 | { |
| 903 | Name commandName("/localhost/nfd/faces"); |
| 904 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 905 | commandName.append("NotReallyParameters"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 906 | |
| 907 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 908 | generateCommand(*command); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 909 | |
| 910 | getFace()->onReceiveData += |
| 911 | bind(&ValidatedFaceRequestFixture::validateControlResponse, this, _1, |
| 912 | command->getName(), 400, "Malformed command"); |
| 913 | |
| 914 | onValidatedFaceRequest(command); |
| 915 | |
| 916 | BOOST_REQUIRE(didCallbackFire()); |
| 917 | } |
| 918 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 919 | BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestCreateFace, |
| 920 | AuthorizedCommandFixture<ValidatedFaceRequestFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 921 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 922 | ControlParameters parameters; |
| 923 | parameters.setUri("tcp://127.0.0.1"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 924 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 925 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 926 | |
| 927 | Name commandName("/localhost/nfd/faces"); |
| 928 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 929 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 930 | |
| 931 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 932 | generateCommand(*command); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 933 | |
| 934 | onValidatedFaceRequest(command); |
| 935 | BOOST_CHECK(didCreateFaceFire()); |
| 936 | } |
| 937 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 938 | BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestDestroyFace, |
| 939 | AuthorizedCommandFixture<ValidatedFaceRequestFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 940 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 941 | ControlParameters parameters; |
| 942 | parameters.setUri("tcp://127.0.0.1"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 943 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 944 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 945 | |
| 946 | Name commandName("/localhost/nfd/faces"); |
| 947 | commandName.append("destroy"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 948 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 949 | |
| 950 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 951 | generateCommand(*command); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 952 | |
| 953 | onValidatedFaceRequest(command); |
| 954 | BOOST_CHECK(didDestroyFaceFire()); |
| 955 | } |
| 956 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 957 | class FaceTableFixture |
| 958 | { |
| 959 | public: |
| 960 | FaceTableFixture() |
| 961 | : m_faceTable(m_forwarder) |
| 962 | { |
| 963 | } |
| 964 | |
| 965 | virtual |
| 966 | ~FaceTableFixture() |
| 967 | { |
| 968 | } |
| 969 | |
| 970 | protected: |
| 971 | Forwarder m_forwarder; |
| 972 | FaceTable m_faceTable; |
| 973 | }; |
| 974 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 975 | class LocalControlFixture : public FaceTableFixture, |
| 976 | public TestFaceManagerCommon, |
| 977 | public FaceManager |
| 978 | { |
| 979 | public: |
| 980 | LocalControlFixture() |
| 981 | : FaceManager(FaceTableFixture::m_faceTable, TestFaceManagerCommon::m_face) |
| 982 | { |
| 983 | } |
| 984 | }; |
| 985 | |
| 986 | BOOST_FIXTURE_TEST_CASE(LocalControlInFaceId, |
| 987 | AuthorizedCommandFixture<LocalControlFixture>) |
| 988 | { |
| 989 | shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>(); |
| 990 | BOOST_REQUIRE(dummy->isLocal()); |
| 991 | FaceTableFixture::m_faceTable.add(dummy); |
| 992 | |
| 993 | ControlParameters parameters; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 994 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 995 | |
| 996 | Block encodedParameters(parameters.wireEncode()); |
| 997 | |
| 998 | Name enable("/localhost/nfd/faces/enable-local-control"); |
| 999 | enable.append(encodedParameters); |
| 1000 | |
| 1001 | shared_ptr<Interest> enableCommand(make_shared<Interest>(enable)); |
| 1002 | enableCommand->setIncomingFaceId(dummy->getId()); |
| 1003 | |
| 1004 | generateCommand(*enableCommand); |
| 1005 | |
| 1006 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1007 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
| 1008 | enableCommand->getName(), 200, "Success", encodedParameters); |
| 1009 | |
| 1010 | onValidatedFaceRequest(enableCommand); |
| 1011 | |
| 1012 | BOOST_REQUIRE(didCallbackFire()); |
| 1013 | BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1014 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1015 | |
| 1016 | TestFaceManagerCommon::m_face->onReceiveData.clear(); |
| 1017 | resetCallbackFired(); |
| 1018 | |
| 1019 | Name disable("/localhost/nfd/faces/disable-local-control"); |
| 1020 | disable.append(encodedParameters); |
| 1021 | |
| 1022 | shared_ptr<Interest> disableCommand(make_shared<Interest>(disable)); |
| 1023 | disableCommand->setIncomingFaceId(dummy->getId()); |
| 1024 | |
| 1025 | generateCommand(*disableCommand); |
| 1026 | |
| 1027 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1028 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
| 1029 | disableCommand->getName(), 200, "Success", encodedParameters); |
| 1030 | |
| 1031 | onValidatedFaceRequest(disableCommand); |
| 1032 | |
| 1033 | BOOST_REQUIRE(didCallbackFire()); |
| 1034 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1035 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1036 | } |
| 1037 | |
| 1038 | BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdFaceNotFound, |
| 1039 | AuthorizedCommandFixture<LocalControlFixture>) |
| 1040 | { |
| 1041 | shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>(); |
| 1042 | BOOST_REQUIRE(dummy->isLocal()); |
| 1043 | FaceTableFixture::m_faceTable.add(dummy); |
| 1044 | |
| 1045 | ControlParameters parameters; |
| 1046 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 1047 | |
| 1048 | Block encodedParameters(parameters.wireEncode()); |
| 1049 | |
| 1050 | Name enable("/localhost/nfd/faces/enable-local-control"); |
| 1051 | enable.append(encodedParameters); |
| 1052 | |
| 1053 | shared_ptr<Interest> enableCommand(make_shared<Interest>(enable)); |
| 1054 | enableCommand->setIncomingFaceId(dummy->getId() + 100); |
| 1055 | |
| 1056 | generateCommand(*enableCommand); |
| 1057 | |
| 1058 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1059 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1060 | enableCommand->getName(), 410, "Face not found"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1061 | |
| 1062 | onValidatedFaceRequest(enableCommand); |
| 1063 | |
| 1064 | BOOST_REQUIRE(didCallbackFire()); |
| 1065 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1066 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1067 | |
| 1068 | TestFaceManagerCommon::m_face->onReceiveData.clear(); |
| 1069 | resetCallbackFired(); |
| 1070 | |
| 1071 | Name disable("/localhost/nfd/faces/disable-local-control"); |
| 1072 | disable.append(encodedParameters); |
| 1073 | |
| 1074 | shared_ptr<Interest> disableCommand(make_shared<Interest>(disable)); |
| 1075 | disableCommand->setIncomingFaceId(dummy->getId() + 100); |
| 1076 | |
| 1077 | generateCommand(*disableCommand); |
| 1078 | |
| 1079 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1080 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1081 | disableCommand->getName(), 410, "Face not found"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1082 | |
| 1083 | onValidatedFaceRequest(disableCommand); |
| 1084 | |
| 1085 | BOOST_REQUIRE(didCallbackFire()); |
| 1086 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1087 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1088 | } |
| 1089 | |
| 1090 | BOOST_FIXTURE_TEST_CASE(LocalControlMissingFeature, |
| 1091 | AuthorizedCommandFixture<LocalControlFixture>) |
| 1092 | { |
| 1093 | shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>(); |
| 1094 | BOOST_REQUIRE(dummy->isLocal()); |
| 1095 | FaceTableFixture::m_faceTable.add(dummy); |
| 1096 | |
| 1097 | ControlParameters parameters; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1098 | |
| 1099 | Block encodedParameters(parameters.wireEncode()); |
| 1100 | |
| 1101 | Name enable("/localhost/nfd/faces/enable-local-control"); |
| 1102 | enable.append(encodedParameters); |
| 1103 | |
| 1104 | shared_ptr<Interest> enableCommand(make_shared<Interest>(enable)); |
| 1105 | enableCommand->setIncomingFaceId(dummy->getId()); |
| 1106 | |
| 1107 | generateCommand(*enableCommand); |
| 1108 | |
| 1109 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1110 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
| 1111 | enableCommand->getName(), 400, "Malformed command"); |
| 1112 | |
| 1113 | onValidatedFaceRequest(enableCommand); |
| 1114 | |
| 1115 | BOOST_REQUIRE(didCallbackFire()); |
| 1116 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1117 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1118 | |
| 1119 | TestFaceManagerCommon::m_face->onReceiveData.clear(); |
| 1120 | resetCallbackFired(); |
| 1121 | |
| 1122 | Name disable("/localhost/nfd/faces/disable-local-control"); |
| 1123 | disable.append(encodedParameters); |
| 1124 | |
| 1125 | shared_ptr<Interest> disableCommand(make_shared<Interest>(disable)); |
| 1126 | disableCommand->setIncomingFaceId(dummy->getId()); |
| 1127 | |
| 1128 | generateCommand(*disableCommand); |
| 1129 | |
| 1130 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1131 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
| 1132 | disableCommand->getName(), 400, "Malformed command"); |
| 1133 | |
| 1134 | onValidatedFaceRequest(disableCommand); |
| 1135 | |
| 1136 | BOOST_REQUIRE(didCallbackFire()); |
| 1137 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1138 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1139 | } |
| 1140 | |
| 1141 | BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdNonLocal, |
| 1142 | AuthorizedCommandFixture<LocalControlFixture>) |
| 1143 | { |
| 1144 | shared_ptr<DummyFace> dummy = make_shared<DummyFace>(); |
| 1145 | BOOST_REQUIRE(!dummy->isLocal()); |
| 1146 | FaceTableFixture::m_faceTable.add(dummy); |
| 1147 | |
| 1148 | ControlParameters parameters; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1149 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID); |
| 1150 | |
| 1151 | Block encodedParameters(parameters.wireEncode()); |
| 1152 | |
| 1153 | Name enable("/localhost/nfd/faces/enable-local-control"); |
| 1154 | enable.append(encodedParameters); |
| 1155 | |
| 1156 | shared_ptr<Interest> enableCommand(make_shared<Interest>(enable)); |
| 1157 | enableCommand->setIncomingFaceId(dummy->getId()); |
| 1158 | |
| 1159 | generateCommand(*enableCommand); |
| 1160 | |
| 1161 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1162 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1163 | enableCommand->getName(), 412, "Face is non-local"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1164 | |
| 1165 | onValidatedFaceRequest(enableCommand); |
| 1166 | |
| 1167 | BOOST_REQUIRE(didCallbackFire()); |
| 1168 | |
| 1169 | TestFaceManagerCommon::m_face->onReceiveData.clear(); |
| 1170 | resetCallbackFired(); |
| 1171 | |
| 1172 | Name disable("/localhost/nfd/faces/disable-local-control"); |
| 1173 | enable.append(encodedParameters); |
| 1174 | |
| 1175 | shared_ptr<Interest> disableCommand(make_shared<Interest>(enable)); |
| 1176 | disableCommand->setIncomingFaceId(dummy->getId()); |
| 1177 | |
| 1178 | generateCommand(*disableCommand); |
| 1179 | |
| 1180 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1181 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1182 | disableCommand->getName(), 412, "Face is non-local"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1183 | |
| 1184 | onValidatedFaceRequest(disableCommand); |
| 1185 | |
| 1186 | BOOST_REQUIRE(didCallbackFire()); |
| 1187 | } |
| 1188 | |
| 1189 | BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceId, |
| 1190 | AuthorizedCommandFixture<LocalControlFixture>) |
| 1191 | { |
| 1192 | shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>(); |
| 1193 | BOOST_REQUIRE(dummy->isLocal()); |
| 1194 | FaceTableFixture::m_faceTable.add(dummy); |
| 1195 | |
| 1196 | ControlParameters parameters; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1197 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID); |
| 1198 | |
| 1199 | Block encodedParameters(parameters.wireEncode()); |
| 1200 | |
| 1201 | Name enable("/localhost/nfd/faces/enable-local-control"); |
| 1202 | enable.append(encodedParameters); |
| 1203 | |
| 1204 | shared_ptr<Interest> enableCommand(make_shared<Interest>(enable)); |
| 1205 | enableCommand->setIncomingFaceId(dummy->getId()); |
| 1206 | |
| 1207 | generateCommand(*enableCommand); |
| 1208 | |
| 1209 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1210 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
| 1211 | enableCommand->getName(), 200, "Success", encodedParameters); |
| 1212 | |
| 1213 | onValidatedFaceRequest(enableCommand); |
| 1214 | |
| 1215 | BOOST_REQUIRE(didCallbackFire()); |
| 1216 | BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1217 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1218 | |
| 1219 | |
| 1220 | TestFaceManagerCommon::m_face->onReceiveData.clear(); |
| 1221 | resetCallbackFired(); |
| 1222 | |
| 1223 | Name disable("/localhost/nfd/faces/disable-local-control"); |
| 1224 | disable.append(encodedParameters); |
| 1225 | |
| 1226 | shared_ptr<Interest> disableCommand(make_shared<Interest>(disable)); |
| 1227 | disableCommand->setIncomingFaceId(dummy->getId()); |
| 1228 | |
| 1229 | generateCommand(*disableCommand); |
| 1230 | |
| 1231 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1232 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
| 1233 | disableCommand->getName(), 200, "Success", encodedParameters); |
| 1234 | |
| 1235 | onValidatedFaceRequest(disableCommand); |
| 1236 | |
| 1237 | BOOST_REQUIRE(didCallbackFire()); |
| 1238 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1239 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1240 | } |
| 1241 | |
| 1242 | BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdFaceNotFound, |
| 1243 | AuthorizedCommandFixture<LocalControlFixture>) |
| 1244 | { |
| 1245 | shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>(); |
| 1246 | BOOST_REQUIRE(dummy->isLocal()); |
| 1247 | FaceTableFixture::m_faceTable.add(dummy); |
| 1248 | |
| 1249 | ControlParameters parameters; |
| 1250 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID); |
| 1251 | |
| 1252 | Block encodedParameters(parameters.wireEncode()); |
| 1253 | |
| 1254 | Name enable("/localhost/nfd/faces/enable-local-control"); |
| 1255 | enable.append(encodedParameters); |
| 1256 | |
| 1257 | shared_ptr<Interest> enableCommand(make_shared<Interest>(enable)); |
| 1258 | enableCommand->setIncomingFaceId(dummy->getId() + 100); |
| 1259 | |
| 1260 | generateCommand(*enableCommand); |
| 1261 | |
| 1262 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1263 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1264 | enableCommand->getName(), 410, "Face not found"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1265 | |
| 1266 | onValidatedFaceRequest(enableCommand); |
| 1267 | |
| 1268 | BOOST_REQUIRE(didCallbackFire()); |
| 1269 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1270 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1271 | |
| 1272 | |
| 1273 | TestFaceManagerCommon::m_face->onReceiveData.clear(); |
| 1274 | resetCallbackFired(); |
| 1275 | |
| 1276 | Name disable("/localhost/nfd/faces/disable-local-control"); |
| 1277 | disable.append(encodedParameters); |
| 1278 | |
| 1279 | shared_ptr<Interest> disableCommand(make_shared<Interest>(disable)); |
| 1280 | disableCommand->setIncomingFaceId(dummy->getId() + 100); |
| 1281 | |
| 1282 | generateCommand(*disableCommand); |
| 1283 | |
| 1284 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1285 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1286 | disableCommand->getName(), 410, "Face not found"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1287 | |
| 1288 | onValidatedFaceRequest(disableCommand); |
| 1289 | |
| 1290 | BOOST_REQUIRE(didCallbackFire()); |
| 1291 | BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)); |
| 1292 | BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID)); |
| 1293 | } |
| 1294 | |
| 1295 | BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdNonLocal, |
| 1296 | AuthorizedCommandFixture<LocalControlFixture>) |
| 1297 | { |
| 1298 | shared_ptr<DummyFace> dummy = make_shared<DummyFace>(); |
| 1299 | BOOST_REQUIRE(!dummy->isLocal()); |
| 1300 | FaceTableFixture::m_faceTable.add(dummy); |
| 1301 | |
| 1302 | ControlParameters parameters; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1303 | parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID); |
| 1304 | |
| 1305 | Block encodedParameters(parameters.wireEncode()); |
| 1306 | |
| 1307 | Name enable("/localhost/nfd/faces/enable-local-control"); |
| 1308 | enable.append(encodedParameters); |
| 1309 | |
| 1310 | shared_ptr<Interest> enableCommand(make_shared<Interest>(enable)); |
| 1311 | enableCommand->setIncomingFaceId(dummy->getId()); |
| 1312 | |
| 1313 | generateCommand(*enableCommand); |
| 1314 | |
| 1315 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1316 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1317 | enableCommand->getName(), 412, "Face is non-local"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1318 | |
| 1319 | onValidatedFaceRequest(enableCommand); |
| 1320 | |
| 1321 | BOOST_REQUIRE(didCallbackFire()); |
| 1322 | |
| 1323 | TestFaceManagerCommon::m_face->onReceiveData.clear(); |
| 1324 | resetCallbackFired(); |
| 1325 | |
| 1326 | Name disable("/localhost/nfd/faces/disable-local-control"); |
| 1327 | disable.append(encodedParameters); |
| 1328 | |
| 1329 | shared_ptr<Interest> disableCommand(make_shared<Interest>(disable)); |
| 1330 | disableCommand->setIncomingFaceId(dummy->getId()); |
| 1331 | |
| 1332 | generateCommand(*disableCommand); |
| 1333 | |
| 1334 | TestFaceManagerCommon::m_face->onReceiveData += |
| 1335 | bind(&LocalControlFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 51d242a | 2014-03-31 13:46:43 -0600 | [diff] [blame] | 1336 | disableCommand->getName(), 412, "Face is non-local"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1337 | |
| 1338 | onValidatedFaceRequest(disableCommand); |
| 1339 | |
| 1340 | BOOST_REQUIRE(didCallbackFire()); |
| 1341 | } |
| 1342 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1343 | class FaceFixture : public FaceTableFixture, |
| 1344 | public TestFaceManagerCommon, |
| 1345 | public FaceManager |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1346 | { |
| 1347 | public: |
| 1348 | FaceFixture() |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1349 | : FaceManager(FaceTableFixture::m_faceTable, |
| 1350 | TestFaceManagerCommon::m_face) |
| 1351 | , m_receivedNotification(false) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1352 | { |
| 1353 | |
| 1354 | } |
| 1355 | |
| 1356 | virtual |
| 1357 | ~FaceFixture() |
| 1358 | { |
| 1359 | |
| 1360 | } |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1361 | |
| 1362 | void |
| 1363 | callbackDispatch(const Data& response, |
| 1364 | const Name& expectedName, |
| 1365 | uint32_t expectedCode, |
| 1366 | const std::string& expectedText, |
| 1367 | const Block& expectedBody, |
| 1368 | const ndn::nfd::FaceEventNotification& expectedFaceEvent) |
| 1369 | { |
| 1370 | Block payload = response.getContent().blockFromValue(); |
| 1371 | if (payload.type() == ndn::tlv::nfd::ControlResponse) |
| 1372 | { |
| 1373 | validateControlResponse(response, expectedName, expectedCode, |
| 1374 | expectedText, expectedBody); |
| 1375 | } |
| 1376 | else if (payload.type() == ndn::tlv::nfd::FaceEventNotification) |
| 1377 | { |
| 1378 | validateFaceEvent(payload, expectedFaceEvent); |
| 1379 | } |
| 1380 | else |
| 1381 | { |
| 1382 | BOOST_FAIL("Received unknown message type: #" << payload.type()); |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | void |
| 1387 | callbackDispatch(const Data& response, |
| 1388 | const Name& expectedName, |
| 1389 | uint32_t expectedCode, |
| 1390 | const std::string& expectedText, |
| 1391 | const ndn::nfd::FaceEventNotification& expectedFaceEvent) |
| 1392 | { |
| 1393 | Block payload = response.getContent().blockFromValue(); |
| 1394 | if (payload.type() == ndn::tlv::nfd::ControlResponse) |
| 1395 | { |
| 1396 | validateControlResponse(response, expectedName, |
| 1397 | expectedCode, expectedText); |
| 1398 | } |
| 1399 | else if (payload.type() == ndn::tlv::nfd::FaceEventNotification) |
| 1400 | { |
| 1401 | validateFaceEvent(payload, expectedFaceEvent); |
| 1402 | } |
| 1403 | else |
| 1404 | { |
| 1405 | BOOST_FAIL("Received unknown message type: #" << payload.type()); |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | void |
| 1410 | validateFaceEvent(const Block& wire, |
| 1411 | const ndn::nfd::FaceEventNotification& expectedFaceEvent) |
| 1412 | { |
| 1413 | |
| 1414 | m_receivedNotification = true; |
| 1415 | |
| 1416 | ndn::nfd::FaceEventNotification notification(wire); |
| 1417 | |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 1418 | BOOST_CHECK_EQUAL(notification.getKind(), expectedFaceEvent.getKind()); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1419 | BOOST_CHECK_EQUAL(notification.getFaceId(), expectedFaceEvent.getFaceId()); |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 1420 | BOOST_CHECK_EQUAL(notification.getRemoteUri(), expectedFaceEvent.getRemoteUri()); |
| 1421 | BOOST_CHECK_EQUAL(notification.getLocalUri(), expectedFaceEvent.getLocalUri()); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1422 | } |
| 1423 | |
| 1424 | bool |
| 1425 | didReceiveNotication() const |
| 1426 | { |
| 1427 | return m_receivedNotification; |
| 1428 | } |
| 1429 | |
| 1430 | protected: |
| 1431 | bool m_receivedNotification; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1432 | }; |
| 1433 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1434 | BOOST_FIXTURE_TEST_CASE(CreateFaceBadUri, AuthorizedCommandFixture<FaceFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1435 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1436 | ControlParameters parameters; |
| 1437 | parameters.setUri("tcp:/127.0.0.1"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1438 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1439 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1440 | |
| 1441 | Name commandName("/localhost/nfd/faces"); |
| 1442 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1443 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1444 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1445 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 1446 | generateCommand(*command); |
| 1447 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1448 | getFace()->onReceiveData += |
| 1449 | bind(&FaceFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1450 | command->getName(), 400, "Malformed command"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1451 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1452 | createFace(*command, parameters); |
| 1453 | |
| 1454 | BOOST_REQUIRE(didCallbackFire()); |
| 1455 | } |
| 1456 | |
| 1457 | BOOST_FIXTURE_TEST_CASE(CreateFaceMissingUri, AuthorizedCommandFixture<FaceFixture>) |
| 1458 | { |
| 1459 | ControlParameters parameters; |
| 1460 | |
| 1461 | Block encodedParameters(parameters.wireEncode()); |
| 1462 | |
| 1463 | Name commandName("/localhost/nfd/faces"); |
| 1464 | commandName.append("create"); |
| 1465 | commandName.append(encodedParameters); |
| 1466 | |
| 1467 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 1468 | generateCommand(*command); |
| 1469 | |
| 1470 | getFace()->onReceiveData += |
| 1471 | bind(&FaceFixture::validateControlResponse, this, _1, |
| 1472 | command->getName(), 400, "Malformed command"); |
| 1473 | |
| 1474 | createFace(*command, parameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1475 | |
| 1476 | BOOST_REQUIRE(didCallbackFire()); |
| 1477 | } |
| 1478 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1479 | BOOST_FIXTURE_TEST_CASE(CreateFaceUnknownScheme, AuthorizedCommandFixture<FaceFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1480 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1481 | ControlParameters parameters; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1482 | // this will be an unsupported protocol because no factories have been |
| 1483 | // added to the face manager |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1484 | parameters.setUri("tcp://127.0.0.1"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1485 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1486 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1487 | |
| 1488 | Name commandName("/localhost/nfd/faces"); |
| 1489 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1490 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1491 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1492 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 1493 | generateCommand(*command); |
| 1494 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1495 | getFace()->onReceiveData += |
| 1496 | bind(&FaceFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1497 | command->getName(), 501, "Unsupported protocol"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1498 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1499 | createFace(*command, parameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1500 | |
| 1501 | BOOST_REQUIRE(didCallbackFire()); |
| 1502 | } |
| 1503 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1504 | BOOST_FIXTURE_TEST_CASE(OnCreated, AuthorizedCommandFixture<FaceFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1505 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1506 | ControlParameters parameters; |
| 1507 | parameters.setUri("tcp://127.0.0.1"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1508 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1509 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1510 | |
| 1511 | Name commandName("/localhost/nfd/faces"); |
| 1512 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1513 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1514 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1515 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 1516 | generateCommand(*command); |
| 1517 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1518 | ControlParameters resultParameters; |
| 1519 | resultParameters.setUri("tcp://127.0.0.1"); |
| 1520 | resultParameters.setFaceId(1); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1521 | |
| 1522 | shared_ptr<DummyFace> dummy(make_shared<DummyFace>()); |
| 1523 | |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 1524 | ndn::nfd::FaceEventNotification expectedFaceEvent; |
| 1525 | expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_CREATED) |
| 1526 | .setFaceId(1) |
| 1527 | .setRemoteUri(dummy->getRemoteUri().toString()) |
| 1528 | .setLocalUri(dummy->getLocalUri().toString()) |
| 1529 | .setFlags(0); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1530 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1531 | Block encodedResultParameters(resultParameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1532 | |
| 1533 | getFace()->onReceiveData += |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1534 | bind(&FaceFixture::callbackDispatch, this, _1, |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1535 | command->getName(), 200, "Success", |
| 1536 | encodedResultParameters, expectedFaceEvent); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1537 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1538 | onCreated(command->getName(), parameters, dummy); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1539 | |
| 1540 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1541 | BOOST_REQUIRE(didReceiveNotication()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1542 | } |
| 1543 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1544 | BOOST_FIXTURE_TEST_CASE(OnConnectFailed, AuthorizedCommandFixture<FaceFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1545 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1546 | ControlParameters parameters; |
| 1547 | parameters.setUri("tcp://127.0.0.1"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1548 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1549 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1550 | |
| 1551 | Name commandName("/localhost/nfd/faces"); |
| 1552 | commandName.append("create"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1553 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1554 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1555 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 1556 | generateCommand(*command); |
| 1557 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1558 | getFace()->onReceiveData += |
| 1559 | bind(&FaceFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | ca53ac6 | 2014-03-27 19:58:40 -0600 | [diff] [blame] | 1560 | command->getName(), 408, "unit-test-reason"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1561 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1562 | onConnectFailed(command->getName(), "unit-test-reason"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1563 | |
| 1564 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1565 | BOOST_CHECK_EQUAL(didReceiveNotication(), false); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1566 | } |
| 1567 | |
| 1568 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1569 | BOOST_FIXTURE_TEST_CASE(DestroyFace, AuthorizedCommandFixture<FaceFixture>) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1570 | { |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1571 | shared_ptr<DummyFace> dummy(make_shared<DummyFace>()); |
| 1572 | FaceTableFixture::m_faceTable.add(dummy); |
| 1573 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1574 | ControlParameters parameters; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1575 | parameters.setFaceId(dummy->getId()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1576 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1577 | Block encodedParameters(parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1578 | |
| 1579 | Name commandName("/localhost/nfd/faces"); |
| 1580 | commandName.append("destroy"); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1581 | commandName.append(encodedParameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1582 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 1583 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 1584 | generateCommand(*command); |
| 1585 | |
Junxiao Shi | 6e69432 | 2014-04-03 10:27:13 -0700 | [diff] [blame] | 1586 | ndn::nfd::FaceEventNotification expectedFaceEvent; |
| 1587 | expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_DESTROYED) |
| 1588 | .setFaceId(dummy->getId()) |
| 1589 | .setRemoteUri(dummy->getRemoteUri().toString()) |
| 1590 | .setLocalUri(dummy->getLocalUri().toString()) |
| 1591 | .setFlags(0); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1592 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1593 | getFace()->onReceiveData += |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1594 | bind(&FaceFixture::callbackDispatch, this, _1, |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1595 | command->getName(), 200, "Success", boost::ref(encodedParameters), expectedFaceEvent); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1596 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame] | 1597 | destroyFace(*command, parameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1598 | |
| 1599 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 1600 | BOOST_REQUIRE(didReceiveNotication()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1601 | } |
| 1602 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 1603 | class FaceListFixture : public FaceStatusPublisherFixture |
| 1604 | { |
| 1605 | public: |
| 1606 | FaceListFixture() |
| 1607 | : m_manager(m_table, m_face) |
| 1608 | { |
| 1609 | |
| 1610 | } |
| 1611 | |
| 1612 | virtual |
| 1613 | ~FaceListFixture() |
| 1614 | { |
| 1615 | |
| 1616 | } |
| 1617 | |
| 1618 | protected: |
| 1619 | FaceManager m_manager; |
| 1620 | }; |
| 1621 | |
| 1622 | BOOST_FIXTURE_TEST_CASE(TestFaceList, FaceListFixture) |
| 1623 | |
| 1624 | { |
| 1625 | Name commandName("/localhost/nfd/faces/list"); |
| 1626 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 1627 | |
| 1628 | // MAX_SEGMENT_SIZE == 4400, FaceStatus size with filler counters is 55 |
| 1629 | // 55 divides 4400 (== 80), so only use 79 FaceStatuses and then two smaller ones |
| 1630 | // to force a FaceStatus to span Data packets |
| 1631 | for (int i = 0; i < 79; i++) |
| 1632 | { |
| 1633 | shared_ptr<TestCountersFace> dummy(make_shared<TestCountersFace>()); |
| 1634 | |
| 1635 | uint64_t filler = std::numeric_limits<uint64_t>::max() - 1; |
| 1636 | dummy->setCounters(filler, filler, filler, filler); |
| 1637 | |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 1638 | m_referenceFaces.push_back(dummy); |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 1639 | |
| 1640 | add(dummy); |
| 1641 | } |
| 1642 | |
| 1643 | for (int i = 0; i < 2; i++) |
| 1644 | { |
| 1645 | shared_ptr<TestCountersFace> dummy(make_shared<TestCountersFace>()); |
| 1646 | uint64_t filler = std::numeric_limits<uint32_t>::max() - 1; |
| 1647 | dummy->setCounters(filler, filler, filler, filler); |
| 1648 | |
Alexander Afanasyev | 7b7dfdd | 2014-03-21 13:57:54 -0700 | [diff] [blame] | 1649 | m_referenceFaces.push_back(dummy); |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 1650 | |
| 1651 | add(dummy); |
| 1652 | } |
| 1653 | |
| 1654 | ndn::EncodingBuffer buffer; |
| 1655 | |
| 1656 | m_face->onReceiveData += |
| 1657 | bind(&FaceStatusPublisherFixture::decodeFaceStatusBlock, this, _1); |
| 1658 | |
| 1659 | m_manager.listFaces(*command); |
| 1660 | BOOST_REQUIRE(m_finished); |
| 1661 | } |
| 1662 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1663 | BOOST_AUTO_TEST_SUITE_END() |
| 1664 | |
| 1665 | } // namespace tests |
| 1666 | } // namespace nfd |