blob: 9f9c3ce662f1818a2a7a6341070410519cbf9e62 [file] [log] [blame]
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -07001/* -*- 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/strategy-choice-manager.hpp"
8#include "face/face.hpp"
9#include "mgmt/internal-face.hpp"
10#include "table/name-tree.hpp"
11#include "table/strategy-choice.hpp"
12#include "fw/forwarder.hpp"
13#include "fw/strategy.hpp"
14#include "tests/face/dummy-face.hpp"
Junxiao Shif3c07812014-03-11 21:48:49 -070015#include "tests/fw/dummy-strategy.hpp"
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070016
17#include "tests/test-common.hpp"
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070018#include "validation-common.hpp"
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070019
20namespace nfd {
21namespace tests {
22
23NFD_LOG_INIT("StrategyChoiceManagerTest");
24
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070025class StrategyChoiceManagerFixture : protected BaseFixture
26{
27public:
28
29 StrategyChoiceManagerFixture()
Junxiao Shif3c07812014-03-11 21:48:49 -070030 : m_strategyChoice(m_forwarder.getStrategyChoice())
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070031 , m_face(make_shared<InternalFace>())
32 , m_manager(m_strategyChoice, m_face)
33 , m_callbackFired(false)
34 {
Junxiao Shif3c07812014-03-11 21:48:49 -070035 m_strategyChoice.install(make_shared<DummyStrategy>(boost::ref(m_forwarder), "/localhost/nfd/strategy/test-strategy-a"));
36 m_strategyChoice.insert("ndn:/", "/localhost/nfd/strategy/test-strategy-a");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070037 }
38
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -070039 virtual
40 ~StrategyChoiceManagerFixture()
41 {
42
43 }
44
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -070045 void
46 validateControlResponseCommon(const Data& response,
47 const Name& expectedName,
48 uint32_t expectedCode,
49 const std::string& expectedText,
50 ControlResponse& control)
51 {
52 m_callbackFired = true;
53 Block controlRaw = response.getContent().blockFromValue();
54
55 control.wireDecode(controlRaw);
56
57 NFD_LOG_DEBUG("received control response"
58 << " Name: " << response.getName()
59 << " code: " << control.getCode()
60 << " text: " << control.getText());
61
62 BOOST_CHECK_EQUAL(response.getName(), expectedName);
63 BOOST_CHECK_EQUAL(control.getCode(), expectedCode);
64 BOOST_CHECK_EQUAL(control.getText(), expectedText);
65 }
66
67 void
68 validateControlResponse(const Data& response,
69 const Name& expectedName,
70 uint32_t expectedCode,
71 const std::string& expectedText)
72 {
73 ControlResponse control;
74 validateControlResponseCommon(response, expectedName,
75 expectedCode, expectedText, control);
76
77 if (!control.getBody().empty())
78 {
79 BOOST_FAIL("found unexpected control response body");
80 }
81 }
82
83 void
84 validateControlResponse(const Data& response,
85 const Name& expectedName,
86 uint32_t expectedCode,
87 const std::string& expectedText,
88 const Block& expectedBody)
89 {
90 ControlResponse control;
91 validateControlResponseCommon(response, expectedName,
92 expectedCode, expectedText, control);
93
94 BOOST_REQUIRE(!control.getBody().empty());
95 BOOST_REQUIRE(control.getBody().value_size() == expectedBody.value_size());
96
97 BOOST_CHECK(memcmp(control.getBody().value(), expectedBody.value(),
98 expectedBody.value_size()) == 0);
99
100 }
101
102 bool
103 didCallbackFire()
104 {
105 return m_callbackFired;
106 }
107
108 void
109 resetCallbackFired()
110 {
111 m_callbackFired = false;
112 }
113
114 shared_ptr<InternalFace>&
115 getFace()
116 {
117 return m_face;
118 }
119
120 StrategyChoiceManager&
121 getManager()
122 {
123 return m_manager;
124 }
125
126 StrategyChoice&
127 getStrategyChoice()
128 {
129 return m_strategyChoice;
130 }
131
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700132 void
133 addInterestRule(const std::string& regex,
134 ndn::IdentityCertificate& certificate)
135 {
136 m_manager.addInterestRule(regex, certificate);
137 }
138
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700139protected:
140 Forwarder m_forwarder;
Junxiao Shif3c07812014-03-11 21:48:49 -0700141 StrategyChoice& m_strategyChoice;
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700142 shared_ptr<InternalFace> m_face;
143 StrategyChoiceManager m_manager;
144
145private:
146 bool m_callbackFired;
147};
148
149class AllStrategiesFixture : public StrategyChoiceManagerFixture
150{
151public:
152 AllStrategiesFixture()
153 {
Junxiao Shif3c07812014-03-11 21:48:49 -0700154 m_strategyChoice.install(make_shared<DummyStrategy>(boost::ref(m_forwarder), "/localhost/nfd/strategy/test-strategy-b"));
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700155 }
156
157 virtual
158 ~AllStrategiesFixture()
159 {
160
161 }
162};
163
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700164template <typename T> class AuthorizedCommandFixture : public CommandFixture<T>
165{
166public:
167 AuthorizedCommandFixture()
168 {
169 const std::string regex = "^<localhost><nfd><strategy-choice>";
170 T::addInterestRule(regex, *CommandFixture<T>::m_certificate);
171 }
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700172
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700173 virtual
174 ~AuthorizedCommandFixture()
175 {
176
177 }
178};
179
180BOOST_FIXTURE_TEST_SUITE(MgmtStrategyChoiceManager,
181 AuthorizedCommandFixture<AllStrategiesFixture>)
182
183BOOST_FIXTURE_TEST_CASE(TestFireInterestFilter, AllStrategiesFixture)
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700184{
185 shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/strategy-choice"));
186
187 getFace()->onReceiveData +=
188 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
189 command->getName(), 400, "Malformed command");
190
191 getFace()->sendInterest(*command);
Junxiao Shi16d1b7d2014-03-27 21:29:09 -0700192 g_io.run_one();
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700193
194 BOOST_REQUIRE(didCallbackFire());
195}
196
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700197BOOST_FIXTURE_TEST_CASE(MalformedCommmand, AllStrategiesFixture)
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700198{
199 shared_ptr<Interest> command(make_shared<Interest>("/localhost/nfd/strategy-choice"));
200
201 getFace()->onReceiveData +=
202 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
203 command->getName(), 400, "Malformed command");
204
205 getManager().onStrategyChoiceRequest(*command);
206
207 BOOST_REQUIRE(didCallbackFire());
208}
209
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700210BOOST_FIXTURE_TEST_CASE(UnsignedCommand, AllStrategiesFixture)
211{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600212 ControlParameters parameters;
213 parameters.setName("/test");
214 parameters.setStrategy("/localhost/nfd/strategy/best-route");
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700215
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600216 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700217
218 Name commandName("/localhost/nfd/strategy-choice");
219 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600220 commandName.append(encodedParameters);
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700221
222 shared_ptr<Interest> command(make_shared<Interest>(commandName));
223
224 getFace()->onReceiveData +=
225 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
226 command->getName(), 401, "Signature required");
227
228 getManager().onStrategyChoiceRequest(*command);
229
230 BOOST_REQUIRE(didCallbackFire());
231}
232
233BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand,
234 UnauthorizedCommandFixture<StrategyChoiceManagerFixture>)
235{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600236 ControlParameters parameters;
237 parameters.setName("/test");
238 parameters.setStrategy("/localhost/nfd/strategy/best-route");
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700239
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600240 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700241
242 Name commandName("/localhost/nfd/strategy-choice");
243 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600244 commandName.append(encodedParameters);
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700245
246 shared_ptr<Interest> command(make_shared<Interest>(commandName));
247 generateCommand(*command);
248
249 getFace()->onReceiveData +=
250 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
251 command->getName(), 403, "Unauthorized command");
252
253 getManager().onStrategyChoiceRequest(*command);
254
255 BOOST_REQUIRE(didCallbackFire());
256}
257
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700258BOOST_AUTO_TEST_CASE(UnsupportedVerb)
259{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600260 ControlParameters parameters;
261 parameters.setName("/test");
262 parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700263
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600264 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700265
266 Name commandName("/localhost/nfd/strategy-choice");
267 commandName.append("unsupported");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600268 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700269
270 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700271 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700272
273 getFace()->onReceiveData +=
274 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
275 command->getName(), 501, "Unsupported command");
276
277 getManager().onValidatedStrategyChoiceRequest(command);
278
279 BOOST_REQUIRE(didCallbackFire());
280}
281
282BOOST_AUTO_TEST_CASE(BadOptionParse)
283{
284 Name commandName("/localhost/nfd/strategy-choice");
285 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600286 commandName.append("NotReallyParameters");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700287
288 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700289 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700290
291 getFace()->onReceiveData +=
292 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
293 command->getName(), 400, "Malformed command");
294
295 getManager().onValidatedStrategyChoiceRequest(command);
296
297 BOOST_REQUIRE(didCallbackFire());
298}
299
300BOOST_AUTO_TEST_CASE(SetStrategies)
301{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600302 ControlParameters parameters;
303 parameters.setName("/test");
304 parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700305
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600306 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700307
308 Name commandName("/localhost/nfd/strategy-choice");
309 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600310 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700311
312 shared_ptr<Interest> command(make_shared<Interest>(commandName));
313
314 getFace()->onReceiveData +=
315 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600316 command->getName(), 200, "Success", encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700317
318 getManager().onValidatedStrategyChoiceRequest(command);
319
320 BOOST_REQUIRE(didCallbackFire());
321 fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
322 BOOST_REQUIRE_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600323}
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700324
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600325BOOST_AUTO_TEST_CASE(SetStrategiesMissingName)
326{
327 ControlParameters parameters;
328 parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
329
330 Block encodedParameters(parameters.wireEncode());
331
332 Name commandName("/localhost/nfd/strategy-choice");
333 commandName.append("set");
334 commandName.append(encodedParameters);
335
336 shared_ptr<Interest> command(make_shared<Interest>(commandName));
337
338 getFace()->onReceiveData +=
339 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
340 command->getName(), 400, "Malformed command");
341
342 getManager().onValidatedStrategyChoiceRequest(command);
343
344 BOOST_REQUIRE(didCallbackFire());
345}
346
347BOOST_AUTO_TEST_CASE(SetStrategiesMissingStrategy)
348{
349 ControlParameters parameters;
350 parameters.setName("/test");
351
352 Block encodedParameters(parameters.wireEncode());
353
354 Name commandName("/localhost/nfd/strategy-choice");
355 commandName.append("set");
356 commandName.append(encodedParameters);
357
358 shared_ptr<Interest> command(make_shared<Interest>(commandName));
359
360 getFace()->onReceiveData +=
361 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
362 command->getName(), 400, "Malformed command");
363
364 getManager().onValidatedStrategyChoiceRequest(command);
365
366 BOOST_REQUIRE(didCallbackFire());
367 fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
368 BOOST_REQUIRE_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-a");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700369}
370
371BOOST_AUTO_TEST_CASE(SetUnsupportedStrategy)
372{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600373 ControlParameters parameters;
374 parameters.setName("/test");
375 parameters.setStrategy("/localhost/nfd/strategy/unit-test-doesnotexist");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700376
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600377 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700378
379 Name commandName("/localhost/nfd/strategy-choice");
380 commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600381 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700382
383 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700384 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700385
386 getFace()->onReceiveData +=
387 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
388 command->getName(), 504, "Unsupported strategy");
389
390 getManager().onValidatedStrategyChoiceRequest(command);
391
392 BOOST_REQUIRE(didCallbackFire());
393 fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
394 BOOST_CHECK_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-a");
395}
396
397class DefaultStrategyOnlyFixture : public StrategyChoiceManagerFixture
398{
399public:
400 DefaultStrategyOnlyFixture()
401 : StrategyChoiceManagerFixture()
402 {
403
404 }
405
406 virtual
407 ~DefaultStrategyOnlyFixture()
408 {
409
410 }
411};
412
413
414/// \todo I'm not sure this code branch (code 405) can happen. The manager tests for the strategy first and will return 504.
415// BOOST_FIXTURE_TEST_CASE(SetNotInstalled, DefaultStrategyOnlyFixture)
416// {
417// BOOST_REQUIRE(!getStrategyChoice().hasStrategy("/localhost/nfd/strategy/test-strategy-b"));
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600418// ControlParameters parameters;
419// parameters.setName("/test");
420// parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700421
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600422// Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700423
424// Name commandName("/localhost/nfd/strategy-choice");
425// commandName.append("set");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600426// commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700427
428// shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700429// generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700430
431// getFace()->onReceiveData +=
432// bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
433// command->getName(), 405, "Strategy not installed");
434
435// getManager().onValidatedStrategyChoiceRequest(command);
436
437// BOOST_REQUIRE(didCallbackFire());
438// fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
439// BOOST_CHECK_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-a");
440// }
441
442BOOST_AUTO_TEST_CASE(Unset)
443{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600444 ControlParameters parameters;
445 parameters.setName("/test");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700446
447 BOOST_REQUIRE(m_strategyChoice.insert("/test", "/localhost/nfd/strategy/test-strategy-b"));
448 BOOST_REQUIRE_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
449 "/localhost/nfd/strategy/test-strategy-b");
450
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600451 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700452
453 Name commandName("/localhost/nfd/strategy-choice");
454 commandName.append("unset");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600455 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700456
457 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700458 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700459
460 getFace()->onReceiveData +=
461 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600462 command->getName(), 200, "Success", encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700463
464 getManager().onValidatedStrategyChoiceRequest(command);
465
466 BOOST_REQUIRE(didCallbackFire());
467
468 BOOST_CHECK_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
469 "/localhost/nfd/strategy/test-strategy-a");
470}
471
472BOOST_AUTO_TEST_CASE(UnsetRoot)
473{
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600474 ControlParameters parameters;
475 parameters.setName("/");
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700476
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600477 Block encodedParameters(parameters.wireEncode());
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700478
479 Name commandName("/localhost/nfd/strategy-choice");
480 commandName.append("unset");
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600481 commandName.append(encodedParameters);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700482
483 shared_ptr<Interest> command(make_shared<Interest>(commandName));
Steve DiBenedetto2c2b8892014-02-27 11:46:48 -0700484 generateCommand(*command);
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700485
486 getFace()->onReceiveData +=
487 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
488 command->getName(), 403, "Cannot unset root prefix strategy");
489
490 getManager().onValidatedStrategyChoiceRequest(command);
491
492 BOOST_REQUIRE(didCallbackFire());
493
494 BOOST_CHECK_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
495 "/localhost/nfd/strategy/test-strategy-a");
496}
497
Steve DiBenedetto7564d972014-03-24 14:28:46 -0600498BOOST_AUTO_TEST_CASE(UnsetMissingName)
499{
500 ControlParameters parameters;
501
502 BOOST_REQUIRE(m_strategyChoice.insert("/test", "/localhost/nfd/strategy/test-strategy-b"));
503 BOOST_REQUIRE_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
504 "/localhost/nfd/strategy/test-strategy-b");
505
506 Block encodedParameters(parameters.wireEncode());
507
508 Name commandName("/localhost/nfd/strategy-choice");
509 commandName.append("unset");
510 commandName.append(encodedParameters);
511
512 shared_ptr<Interest> command(make_shared<Interest>(commandName));
513 generateCommand(*command);
514
515 getFace()->onReceiveData +=
516 bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
517 command->getName(), 400, "Malformed command");
518
519 getManager().onValidatedStrategyChoiceRequest(command);
520
521 BOOST_REQUIRE(didCallbackFire());
522
523 BOOST_CHECK_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
524 "/localhost/nfd/strategy/test-strategy-b");
525}
526
Steve DiBenedetto5330e0d2014-03-05 21:52:51 -0700527BOOST_AUTO_TEST_SUITE_END()
528
529} // namespace tests
530} // namespace nfd