Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "mgmt/fib-manager.hpp" |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 8 | #include "table/fib.hpp" |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 9 | #include "table/fib-nexthop.hpp" |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 10 | #include "face/face.hpp" |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 11 | #include "mgmt/internal-face.hpp" |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 12 | #include "tests/face/dummy-face.hpp" |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 13 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 14 | #include "validation-common.hpp" |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 15 | #include "tests/test-common.hpp" |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 16 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 17 | namespace nfd { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 18 | namespace tests { |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 19 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 20 | NFD_LOG_INIT("FibManagerTest"); |
| 21 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 22 | class FibManagerFixture : protected BaseFixture |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 23 | { |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 24 | public: |
| 25 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 26 | virtual |
| 27 | ~FibManagerFixture() |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 28 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 31 | shared_ptr<Face> |
| 32 | getFace(FaceId id) |
| 33 | { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 34 | if (id > 0 && static_cast<size_t>(id) <= m_faces.size()) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 35 | { |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 36 | return m_faces[id - 1]; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 37 | } |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 38 | NFD_LOG_DEBUG("No face found returning NULL"); |
| 39 | return shared_ptr<DummyFace>(); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | void |
| 43 | addFace(shared_ptr<Face> face) |
| 44 | { |
| 45 | m_faces.push_back(face); |
| 46 | } |
| 47 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 48 | void |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 49 | validateControlResponseCommon(const Data& response, |
| 50 | const Name& expectedName, |
| 51 | uint32_t expectedCode, |
| 52 | const std::string& expectedText, |
| 53 | ControlResponse& control) |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 54 | { |
| 55 | m_callbackFired = true; |
| 56 | Block controlRaw = response.getContent().blockFromValue(); |
| 57 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 58 | control.wireDecode(controlRaw); |
| 59 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 60 | // NFD_LOG_DEBUG("received control response" |
| 61 | // << " Name: " << response.getName() |
| 62 | // << " code: " << control.getCode() |
| 63 | // << " text: " << control.getText()); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 64 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 65 | BOOST_CHECK_EQUAL(response.getName(), expectedName); |
| 66 | BOOST_CHECK_EQUAL(control.getCode(), expectedCode); |
| 67 | BOOST_CHECK_EQUAL(control.getText(), expectedText); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 68 | } |
| 69 | |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 70 | void |
| 71 | validateControlResponse(const Data& response, |
| 72 | const Name& expectedName, |
| 73 | uint32_t expectedCode, |
| 74 | const std::string& expectedText) |
| 75 | { |
| 76 | ControlResponse control; |
| 77 | validateControlResponseCommon(response, expectedName, |
| 78 | expectedCode, expectedText, control); |
| 79 | |
| 80 | if (!control.getBody().empty()) |
| 81 | { |
| 82 | BOOST_FAIL("found unexpected control response body"); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | void |
| 87 | validateControlResponse(const Data& response, |
| 88 | const Name& expectedName, |
| 89 | uint32_t expectedCode, |
| 90 | const std::string& expectedText, |
| 91 | const Block& expectedBody) |
| 92 | { |
| 93 | ControlResponse control; |
| 94 | validateControlResponseCommon(response, expectedName, |
| 95 | expectedCode, expectedText, control); |
| 96 | |
| 97 | BOOST_REQUIRE(!control.getBody().empty()); |
| 98 | BOOST_REQUIRE(control.getBody().value_size() == expectedBody.value_size()); |
| 99 | |
| 100 | BOOST_CHECK(memcmp(control.getBody().value(), expectedBody.value(), |
| 101 | expectedBody.value_size()) == 0); |
| 102 | |
| 103 | } |
| 104 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 105 | bool |
| 106 | didCallbackFire() |
| 107 | { |
| 108 | return m_callbackFired; |
| 109 | } |
| 110 | |
| 111 | void |
| 112 | resetCallbackFired() |
| 113 | { |
| 114 | m_callbackFired = false; |
| 115 | } |
| 116 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 117 | shared_ptr<InternalFace> |
| 118 | getInternalFace() |
| 119 | { |
| 120 | return m_face; |
| 121 | } |
| 122 | |
| 123 | FibManager& |
| 124 | getFibManager() |
| 125 | { |
| 126 | return m_manager; |
| 127 | } |
| 128 | |
| 129 | Fib& |
| 130 | getFib() |
| 131 | { |
| 132 | return m_fib; |
| 133 | } |
| 134 | |
| 135 | void |
| 136 | addInterestRule(const std::string& regex, |
| 137 | ndn::IdentityCertificate& certificate) |
| 138 | { |
| 139 | m_manager.addInterestRule(regex, certificate); |
| 140 | } |
| 141 | |
| 142 | protected: |
| 143 | FibManagerFixture() |
| 144 | : m_face(make_shared<InternalFace>()) |
| 145 | , m_nameTree(1024) |
| 146 | , m_fib(m_nameTree) |
| 147 | , m_manager(boost::ref(m_fib), |
| 148 | bind(&FibManagerFixture::getFace, this, _1), |
| 149 | m_face) |
| 150 | , m_callbackFired(false) |
| 151 | { |
| 152 | } |
| 153 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 154 | private: |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 155 | shared_ptr<InternalFace> m_face; |
| 156 | NameTree m_nameTree; |
| 157 | Fib m_fib; |
| 158 | FibManager m_manager; |
| 159 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 160 | std::vector<shared_ptr<Face> > m_faces; |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 161 | bool m_callbackFired; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 162 | }; |
| 163 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 164 | template <typename T> class AuthorizedCommandFixture: |
| 165 | public CommandFixture<T> |
| 166 | { |
| 167 | public: |
| 168 | AuthorizedCommandFixture() |
| 169 | { |
| 170 | const std::string regex = "^<localhost><nfd><fib>"; |
| 171 | T::addInterestRule(regex, *CommandFixture<T>::m_certificate); |
| 172 | } |
| 173 | |
| 174 | virtual |
| 175 | ~AuthorizedCommandFixture() |
| 176 | { |
| 177 | } |
| 178 | }; |
| 179 | |
| 180 | BOOST_FIXTURE_TEST_SUITE(MgmtFibManager, AuthorizedCommandFixture<FibManagerFixture>) |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 181 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 182 | bool |
| 183 | foundNextHop(FaceId id, uint32_t cost, const fib::NextHop& next) |
| 184 | { |
| 185 | return id == next.getFace()->getId() && next.getCost() == cost; |
| 186 | } |
| 187 | |
| 188 | bool |
| 189 | addedNextHopWithCost(const Fib& fib, const Name& prefix, size_t oldSize, uint32_t cost) |
| 190 | { |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 191 | shared_ptr<fib::Entry> entry = fib.findExactMatch(prefix); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 192 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 193 | if (static_cast<bool>(entry)) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 194 | { |
| 195 | const fib::NextHopList& hops = entry->getNextHops(); |
| 196 | return hops.size() == oldSize + 1 && |
| 197 | std::find_if(hops.begin(), hops.end(), bind(&foundNextHop, -1, cost, _1)) != hops.end(); |
| 198 | } |
| 199 | return false; |
| 200 | } |
| 201 | |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 202 | bool |
| 203 | foundNextHopWithFace(FaceId id, uint32_t cost, |
| 204 | shared_ptr<Face> face, const fib::NextHop& next) |
| 205 | { |
| 206 | return id == next.getFace()->getId() && next.getCost() == cost && face == next.getFace(); |
| 207 | } |
| 208 | |
| 209 | bool |
| 210 | addedNextHopWithFace(const Fib& fib, const Name& prefix, size_t oldSize, |
| 211 | uint32_t cost, shared_ptr<Face> face) |
| 212 | { |
| 213 | shared_ptr<fib::Entry> entry = fib.findExactMatch(prefix); |
| 214 | |
| 215 | if (static_cast<bool>(entry)) |
| 216 | { |
| 217 | const fib::NextHopList& hops = entry->getNextHops(); |
| 218 | return hops.size() == oldSize + 1 && |
| 219 | std::find_if(hops.begin(), hops.end(), bind(&foundNextHop, -1, cost, _1)) != hops.end(); |
| 220 | } |
| 221 | return false; |
| 222 | } |
| 223 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 224 | BOOST_AUTO_TEST_CASE(TestFireInterestFilter) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 225 | { |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 226 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 227 | |
| 228 | Interest command("/localhost/nfd/fib"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 229 | |
| 230 | face->onReceiveData += |
| 231 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
| 232 | command.getName(), 400, "Malformed command"); |
| 233 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 234 | face->sendInterest(command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 235 | |
| 236 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 237 | } |
| 238 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 239 | BOOST_AUTO_TEST_CASE(MalformedCommmand) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 240 | { |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 241 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 242 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 243 | BOOST_REQUIRE(didCallbackFire() == false); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 244 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 245 | Interest command("/localhost/nfd/fib"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 246 | |
| 247 | face->onReceiveData += |
| 248 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
| 249 | command.getName(), 400, "Malformed command"); |
| 250 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 251 | getFibManager().onFibRequest(command); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 252 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 253 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 254 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 255 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 256 | BOOST_AUTO_TEST_CASE(UnsupportedVerb) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 257 | { |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 258 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 259 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 260 | FibManagementOptions options; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 261 | options.setName("/hello"); |
| 262 | options.setFaceId(1); |
| 263 | options.setCost(1); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 264 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 265 | Block encodedOptions(options.wireEncode()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 266 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 267 | Name commandName("/localhost/nfd/fib"); |
| 268 | commandName.append("unsupported"); |
| 269 | commandName.append(encodedOptions); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 270 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 271 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 272 | generateCommand(*command); |
| 273 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 274 | face->onReceiveData += |
| 275 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 276 | command->getName(), 501, "Unsupported command"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 277 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 278 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 279 | |
| 280 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 281 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 282 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 283 | BOOST_AUTO_TEST_CASE(UnsignedCommand) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 284 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 285 | addFace(make_shared<DummyFace>()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 286 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 287 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 288 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 289 | FibManagementOptions options; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 290 | options.setName("/hello"); |
| 291 | options.setFaceId(1); |
| 292 | options.setCost(101); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 293 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 294 | Block encodedOptions(options.wireEncode()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 295 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 296 | Name commandName("/localhost/nfd/fib"); |
| 297 | commandName.append("add-nexthop"); |
| 298 | commandName.append(encodedOptions); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 299 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 300 | Interest command(commandName); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 301 | |
| 302 | face->onReceiveData += |
| 303 | bind(&FibManagerFixture::validateControlResponse, |
| 304 | this, _1, command.getName(), 401, "Signature required"); |
| 305 | |
| 306 | |
| 307 | getFibManager().onFibRequest(command); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 308 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 309 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 310 | BOOST_REQUIRE(!addedNextHopWithCost(getFib(), "/hello", 0, 101)); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 311 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 312 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 313 | BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand, UnauthorizedCommandFixture<FibManagerFixture>) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 314 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 315 | addFace(make_shared<DummyFace>()); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 316 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 317 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 318 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 319 | FibManagementOptions options; |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 320 | options.setName("/hello"); |
| 321 | options.setFaceId(1); |
| 322 | options.setCost(101); |
| 323 | |
| 324 | Block encodedOptions(options.wireEncode()); |
| 325 | |
| 326 | Name commandName("/localhost/nfd/fib"); |
| 327 | commandName.append("add-nexthop"); |
| 328 | commandName.append(encodedOptions); |
| 329 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 330 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 331 | generateCommand(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 332 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 333 | face->onReceiveData += |
| 334 | bind(&FibManagerFixture::validateControlResponse, |
| 335 | this, _1, command->getName(), 403, "Unauthorized command"); |
| 336 | |
| 337 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 338 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 339 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 340 | BOOST_REQUIRE(!addedNextHopWithCost(getFib(), "/hello", 0, 101)); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 341 | } |
| 342 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 343 | BOOST_AUTO_TEST_CASE(BadOptionParse) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 344 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 345 | addFace(make_shared<DummyFace>()); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 346 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 347 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 348 | |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 349 | Name commandName("/localhost/nfd/fib"); |
| 350 | commandName.append("add-nexthop"); |
| 351 | commandName.append("NotReallyOptions"); |
| 352 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 353 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 354 | generateCommand(*command); |
| 355 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 356 | face->onReceiveData += |
| 357 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 358 | command->getName(), 400, "Malformed command"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 359 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 360 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 361 | |
| 362 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 365 | BOOST_AUTO_TEST_CASE(UnknownFaceId) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 366 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 367 | addFace(make_shared<DummyFace>()); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 368 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 369 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 370 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 371 | FibManagementOptions options; |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 372 | options.setName("/hello"); |
| 373 | options.setFaceId(1000); |
| 374 | options.setCost(101); |
| 375 | |
| 376 | Block encodedOptions(options.wireEncode()); |
| 377 | |
| 378 | Name commandName("/localhost/nfd/fib"); |
| 379 | commandName.append("add-nexthop"); |
| 380 | commandName.append(encodedOptions); |
| 381 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 382 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 383 | generateCommand(*command); |
| 384 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 385 | face->onReceiveData += |
| 386 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 387 | command->getName(), 404, "Face not found"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 388 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 389 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 390 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 391 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 392 | BOOST_REQUIRE(addedNextHopWithCost(getFib(), "/hello", 0, 101) == false); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 393 | } |
| 394 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 395 | BOOST_AUTO_TEST_CASE(TestImplicitFaceId) |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 396 | { |
| 397 | addFace(make_shared<DummyFace>()); |
| 398 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 399 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 400 | |
| 401 | FibManagementOptions options; |
| 402 | options.setName("/hello"); |
| 403 | options.setFaceId(0); |
| 404 | options.setCost(101); |
| 405 | |
| 406 | Block encodedOptions(options.wireEncode()); |
| 407 | |
| 408 | Name commandName("/localhost/nfd/fib"); |
| 409 | commandName.append("add-nexthop"); |
| 410 | commandName.append(encodedOptions); |
| 411 | |
| 412 | FibManagementOptions expectedOptions; |
| 413 | expectedOptions.setName("/hello"); |
| 414 | expectedOptions.setFaceId(1); |
| 415 | expectedOptions.setCost(101); |
| 416 | |
| 417 | Block encodedExpectedOptions(expectedOptions.wireEncode()); |
| 418 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 419 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 420 | command->setIncomingFaceId(1); |
| 421 | generateCommand(*command); |
| 422 | |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 423 | face->onReceiveData += |
| 424 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 425 | command->getName(), 200, "Success", encodedExpectedOptions); |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 426 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 427 | getFib().insert("/hello"); |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 428 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 429 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 430 | |
| 431 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 432 | BOOST_REQUIRE(addedNextHopWithFace(getFib(), "/hello", 0, 101, getFace(1))); |
Steve DiBenedetto | 2693db9 | 2014-02-10 15:58:36 -0700 | [diff] [blame] | 433 | } |
| 434 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 435 | BOOST_AUTO_TEST_CASE(AddNextHopVerbInitialAdd) |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 436 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 437 | addFace(make_shared<DummyFace>()); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 438 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 439 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 440 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 441 | FibManagementOptions options; |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 442 | options.setName("/hello"); |
| 443 | options.setFaceId(1); |
| 444 | options.setCost(101); |
| 445 | |
| 446 | Block encodedOptions(options.wireEncode()); |
| 447 | |
| 448 | Name commandName("/localhost/nfd/fib"); |
| 449 | commandName.append("add-nexthop"); |
| 450 | commandName.append(encodedOptions); |
| 451 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 452 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 453 | generateCommand(*command); |
| 454 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 455 | face->onReceiveData += |
| 456 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 457 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 458 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 459 | getFib().insert("/hello"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 460 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 461 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 80ddc21 | 2014-02-01 22:23:56 -0700 | [diff] [blame] | 462 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 463 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 464 | BOOST_REQUIRE(addedNextHopWithCost(getFib(), "/hello", 0, 101)); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 465 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 466 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 467 | BOOST_AUTO_TEST_CASE(AddNextHopVerbAddToExisting) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 468 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 469 | addFace(make_shared<DummyFace>()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 470 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 471 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 472 | getFib().insert("/hello"); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 473 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 474 | for (int i = 1; i <= 2; i++) |
| 475 | { |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 476 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 477 | FibManagementOptions options; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 478 | options.setName("/hello"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 479 | options.setFaceId(1); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 480 | options.setCost(100 + i); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 481 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 482 | Block encodedOptions(options.wireEncode()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 483 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 484 | Name commandName("/localhost/nfd/fib"); |
| 485 | commandName.append("add-nexthop"); |
| 486 | commandName.append(encodedOptions); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 487 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 488 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 489 | generateCommand(*command); |
| 490 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 491 | face->onReceiveData += |
| 492 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 493 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 494 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 495 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 496 | BOOST_REQUIRE(didCallbackFire()); |
| 497 | resetCallbackFired(); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 498 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 499 | shared_ptr<fib::Entry> entry = getFib().findExactMatch("/hello"); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 500 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 501 | if (static_cast<bool>(entry)) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 502 | { |
| 503 | const fib::NextHopList& hops = entry->getNextHops(); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 504 | BOOST_REQUIRE(hops.size() == 1); |
| 505 | BOOST_REQUIRE(std::find_if(hops.begin(), hops.end(), |
| 506 | bind(&foundNextHop, -1, 100 + i, _1)) != hops.end()); |
| 507 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 508 | } |
| 509 | else |
| 510 | { |
| 511 | BOOST_FAIL("Failed to find expected fib entry"); |
| 512 | } |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 513 | |
| 514 | face->onReceiveData.clear(); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 515 | } |
| 516 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 517 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 518 | BOOST_AUTO_TEST_CASE(AddNextHopVerbUpdateFaceCost) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 519 | { |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 520 | addFace(make_shared<DummyFace>()); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 521 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 522 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 523 | getFib().insert("/hello"); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 524 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 525 | FibManagementOptions options; |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 526 | options.setName("/hello"); |
| 527 | options.setFaceId(1); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 528 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 529 | { |
| 530 | options.setCost(1); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 531 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 532 | Block encodedOptions(options.wireEncode()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 533 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 534 | Name commandName("/localhost/nfd/fib"); |
| 535 | commandName.append("add-nexthop"); |
| 536 | commandName.append(encodedOptions); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 537 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 538 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 539 | generateCommand(*command); |
| 540 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 541 | face->onReceiveData += |
| 542 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 543 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 544 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 545 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 546 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 547 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 548 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 549 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 550 | resetCallbackFired(); |
| 551 | face->onReceiveData.clear(); |
| 552 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 553 | { |
| 554 | options.setCost(102); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 555 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 556 | Block encodedOptions(options.wireEncode()); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 557 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 558 | Name commandName("/localhost/nfd/fib"); |
| 559 | commandName.append("add-nexthop"); |
| 560 | commandName.append(encodedOptions); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 561 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 562 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 563 | generateCommand(*command); |
| 564 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 565 | face->onReceiveData += |
| 566 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 567 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 568 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 569 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 570 | |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 571 | BOOST_REQUIRE(didCallbackFire()); |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 572 | } |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 573 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 574 | shared_ptr<fib::Entry> entry = getFib().findExactMatch("/hello"); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 575 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 576 | // Add faces with cost == FaceID for the name /hello |
| 577 | // This test assumes: |
| 578 | // FaceIDs are -1 because we don't add them to a forwarder |
Steve DiBenedetto | bdedce9 | 2014-02-02 22:49:39 -0700 | [diff] [blame] | 579 | if (static_cast<bool>(entry)) |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 580 | { |
| 581 | const fib::NextHopList& hops = entry->getNextHops(); |
| 582 | BOOST_REQUIRE(hops.size() == 1); |
| 583 | BOOST_REQUIRE(std::find_if(hops.begin(), |
| 584 | hops.end(), |
| 585 | bind(&foundNextHop, -1, 102, _1)) != hops.end()); |
| 586 | } |
| 587 | else |
| 588 | { |
| 589 | BOOST_FAIL("Failed to find expected fib entry"); |
| 590 | } |
| 591 | } |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 592 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 593 | BOOST_AUTO_TEST_CASE(Insert) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 594 | { |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 595 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 596 | |
| 597 | { |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 598 | FibManagementOptions options; |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 599 | options.setName("/hello"); |
| 600 | |
| 601 | Block encodedOptions(options.wireEncode()); |
| 602 | |
| 603 | Name commandName("/localhost/nfd/fib"); |
| 604 | commandName.append("insert"); |
| 605 | commandName.append(encodedOptions); |
| 606 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 607 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 608 | generateCommand(*command); |
| 609 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 610 | face->onReceiveData += |
| 611 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 612 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 613 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 614 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | BOOST_REQUIRE(didCallbackFire()); |
| 618 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 619 | shared_ptr<fib::Entry> entry = getFib().findExactMatch("/hello"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 620 | if (static_cast<bool>(entry)) |
| 621 | { |
| 622 | const fib::NextHopList& hops = entry->getNextHops(); |
| 623 | BOOST_CHECK_EQUAL(hops.size(), 0); |
| 624 | } |
| 625 | |
| 626 | resetCallbackFired(); |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 627 | face->onReceiveData.clear(); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 628 | |
| 629 | { |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 630 | FibManagementOptions options; |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 631 | options.setName("/hello"); |
| 632 | |
| 633 | Block encodedOptions(options.wireEncode()); |
| 634 | |
| 635 | Name commandName("/localhost/nfd/fib"); |
| 636 | commandName.append("insert"); |
| 637 | commandName.append(encodedOptions); |
| 638 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 639 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 640 | generateCommand(*command); |
| 641 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 642 | face->onReceiveData += |
| 643 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 644 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 645 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 646 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | BOOST_REQUIRE(didCallbackFire()); |
| 650 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 651 | entry = getFib().findExactMatch("/hello"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 652 | if (static_cast<bool>(entry)) |
| 653 | { |
| 654 | const fib::NextHopList& hops = entry->getNextHops(); |
| 655 | BOOST_CHECK_EQUAL(hops.size(), 0); |
| 656 | } |
| 657 | |
| 658 | } |
| 659 | |
| 660 | void |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 661 | testRemove(CommandFixture<FibManagerFixture>* fixture, |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 662 | FibManager& manager, |
| 663 | Fib& fib, |
| 664 | shared_ptr<Face> face, |
| 665 | const Name& target) |
| 666 | { |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 667 | FibManagementOptions options; |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 668 | options.setName(target); |
| 669 | |
| 670 | Block encodedOptions(options.wireEncode()); |
| 671 | |
| 672 | Name commandName("/localhost/nfd/fib"); |
| 673 | commandName.append("delete"); |
| 674 | commandName.append(encodedOptions); |
| 675 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 676 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 677 | fixture->generateCommand(*command); |
| 678 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 679 | face->onReceiveData += |
| 680 | bind(&FibManagerFixture::validateControlResponse, fixture, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 681 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 682 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 683 | manager.onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 684 | |
| 685 | BOOST_REQUIRE(fixture->didCallbackFire()); |
| 686 | |
| 687 | if (static_cast<bool>(fib.findExactMatch(target))) |
| 688 | { |
| 689 | BOOST_FAIL("Found \"removed\" prefix"); |
| 690 | } |
| 691 | face->onReceiveData.clear(); |
| 692 | } |
| 693 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 694 | BOOST_AUTO_TEST_CASE(Delete) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 695 | { |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 696 | shared_ptr<InternalFace> face = getInternalFace(); |
| 697 | FibManager& manager = getFibManager(); |
| 698 | Fib& fib = getFib(); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 699 | |
| 700 | fib.insert("/a"); |
| 701 | fib.insert("/a/b"); |
| 702 | fib.insert("/a/b/c"); |
| 703 | |
| 704 | testRemove(this, manager, fib, face, "/"); |
| 705 | |
| 706 | if (!static_cast<bool>(fib.findExactMatch("/a")) || |
| 707 | !static_cast<bool>(fib.findExactMatch("/a/b")) || |
| 708 | !static_cast<bool>(fib.findExactMatch("/a/b/c"))) |
| 709 | { |
| 710 | BOOST_FAIL("Removed incorrect entry"); |
| 711 | } |
| 712 | |
| 713 | testRemove(this, manager, fib, face, "/a/b"); |
| 714 | |
| 715 | if (!static_cast<bool>(fib.findExactMatch("/a")) || |
| 716 | !static_cast<bool>(fib.findExactMatch("/a/b/c"))) |
| 717 | { |
| 718 | BOOST_FAIL("Removed incorrect entry"); |
| 719 | } |
| 720 | |
| 721 | testRemove(this, manager, fib, face, "/a/b/c"); |
| 722 | |
| 723 | if (!static_cast<bool>(fib.findExactMatch("/a"))) |
| 724 | { |
| 725 | BOOST_FAIL("Removed incorrect entry"); |
| 726 | } |
| 727 | |
| 728 | testRemove(this, manager, fib, face, "/a"); |
| 729 | |
| 730 | testRemove(this, manager, fib, face, "/does/not/exist"); |
| 731 | } |
| 732 | |
| 733 | bool |
| 734 | removedNextHopWithCost(const Fib& fib, const Name& prefix, size_t oldSize, uint32_t cost) |
| 735 | { |
| 736 | shared_ptr<fib::Entry> entry = fib.findExactMatch(prefix); |
| 737 | |
| 738 | if (static_cast<bool>(entry)) |
| 739 | { |
| 740 | const fib::NextHopList& hops = entry->getNextHops(); |
| 741 | return hops.size() == oldSize - 1 && |
| 742 | std::find_if(hops.begin(), hops.end(), bind(&foundNextHop, -1, cost, _1)) == hops.end(); |
| 743 | } |
| 744 | return false; |
| 745 | } |
| 746 | |
| 747 | void |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 748 | testRemoveNextHop(CommandFixture<FibManagerFixture>* fixture, |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 749 | FibManager& manager, |
| 750 | Fib& fib, |
| 751 | shared_ptr<Face> face, |
| 752 | const Name& targetName, |
| 753 | FaceId targetFace) |
| 754 | { |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 755 | FibManagementOptions options; |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 756 | options.setName(targetName); |
| 757 | options.setFaceId(targetFace); |
| 758 | |
| 759 | Block encodedOptions(options.wireEncode()); |
| 760 | |
| 761 | Name commandName("/localhost/nfd/fib"); |
| 762 | commandName.append("remove-nexthop"); |
| 763 | commandName.append(encodedOptions); |
| 764 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 765 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 766 | fixture->generateCommand(*command); |
| 767 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 768 | face->onReceiveData += |
| 769 | bind(&FibManagerFixture::validateControlResponse, fixture, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 770 | command->getName(), 200, "Success", encodedOptions); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 771 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 772 | manager.onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 773 | |
| 774 | BOOST_REQUIRE(fixture->didCallbackFire()); |
| 775 | |
| 776 | fixture->resetCallbackFired(); |
| 777 | face->onReceiveData.clear(); |
| 778 | } |
| 779 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 780 | BOOST_AUTO_TEST_CASE(RemoveNextHop) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 781 | { |
| 782 | shared_ptr<Face> face1 = make_shared<DummyFace>(); |
| 783 | shared_ptr<Face> face2 = make_shared<DummyFace>(); |
| 784 | shared_ptr<Face> face3 = make_shared<DummyFace>(); |
| 785 | |
| 786 | addFace(face1); |
| 787 | addFace(face2); |
| 788 | addFace(face3); |
| 789 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 790 | shared_ptr<InternalFace> face = getInternalFace(); |
| 791 | FibManager& manager = getFibManager(); |
| 792 | Fib& fib = getFib(); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 793 | |
| 794 | shared_ptr<fib::Entry> entry = fib.insert("/hello").first; |
| 795 | |
| 796 | entry->addNextHop(face1, 101); |
| 797 | entry->addNextHop(face2, 202); |
| 798 | entry->addNextHop(face3, 303); |
| 799 | |
| 800 | testRemoveNextHop(this, manager, fib, face, "/hello", 2); |
| 801 | BOOST_REQUIRE(removedNextHopWithCost(fib, "/hello", 3, 202)); |
| 802 | |
| 803 | testRemoveNextHop(this, manager, fib, face, "/hello", 3); |
| 804 | BOOST_REQUIRE(removedNextHopWithCost(fib, "/hello", 2, 303)); |
| 805 | |
| 806 | testRemoveNextHop(this, manager, fib, face, "/hello", 1); |
| 807 | BOOST_REQUIRE(removedNextHopWithCost(fib, "/hello", 1, 101)); |
| 808 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 809 | if (!static_cast<bool>(getFib().findExactMatch("/hello"))) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 810 | { |
| 811 | BOOST_FAIL("removed entry after removing all next hops"); |
| 812 | } |
| 813 | |
| 814 | } |
| 815 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 816 | BOOST_AUTO_TEST_CASE(RemoveNoFace) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 817 | { |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 818 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 819 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 820 | FibManagementOptions options; |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 821 | options.setName("/hello"); |
| 822 | options.setFaceId(1); |
| 823 | |
| 824 | Block encodedOptions(options.wireEncode()); |
| 825 | |
| 826 | Name commandName("/localhost/nfd/fib"); |
| 827 | commandName.append("remove-nexthop"); |
| 828 | commandName.append(encodedOptions); |
| 829 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 830 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 831 | generateCommand(*command); |
| 832 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 833 | face->onReceiveData += |
| 834 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 835 | command->getName(), 404, "Face not found"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 836 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 837 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 838 | |
| 839 | BOOST_REQUIRE(didCallbackFire()); |
| 840 | } |
| 841 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 842 | BOOST_AUTO_TEST_CASE(RemoveNoPrefix) |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 843 | { |
| 844 | addFace(make_shared<DummyFace>()); |
| 845 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 846 | shared_ptr<InternalFace> face = getInternalFace(); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 847 | |
Alexander Afanasyev | d482fd3 | 2014-02-09 23:40:20 -0800 | [diff] [blame] | 848 | FibManagementOptions options; |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 849 | options.setName("/hello"); |
| 850 | options.setFaceId(1); |
| 851 | |
| 852 | Block encodedOptions(options.wireEncode()); |
| 853 | |
| 854 | Name commandName("/localhost/nfd/fib"); |
| 855 | commandName.append("remove-nexthop"); |
| 856 | commandName.append(encodedOptions); |
| 857 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 858 | shared_ptr<Interest> command(make_shared<Interest>(commandName)); |
| 859 | generateCommand(*command); |
| 860 | |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 861 | face->onReceiveData += |
| 862 | bind(&FibManagerFixture::validateControlResponse, this, _1, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 863 | command->getName(), 404, "Prefix not found"); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 864 | |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame^] | 865 | getFibManager().onFibRequest(*command); |
Steve DiBenedetto | 0b73f44 | 2014-02-05 22:02:03 -0700 | [diff] [blame] | 866 | |
| 867 | BOOST_REQUIRE(didCallbackFire()); |
| 868 | } |
| 869 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 870 | BOOST_AUTO_TEST_SUITE_END() |
| 871 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 872 | } // namespace tests |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 873 | } // namespace nfd |