mgmt: refactor management modules to conform to NFD Management Protocol
Refactor management protocol specific option types to ControlParameters
Add control parameter field enforcement
Add missing control response "success" message bodies
Update fib management protocol response codes and behavior
Merge local control header manager into face manager
Refactor references of nfd::LocalControlHeaderFeature enum to ndn::nfd::LocalControlFeature
Remove "control-header" privilege from default configuration
refs: #1397, #1399, #1400
Change-Id: Id042daf00b3cee1f1c7fa38d2e4a4ff6d95c15c6
diff --git a/tests/mgmt/face-manager.cpp b/tests/mgmt/face-manager.cpp
index 5a46097..9cfca66 100644
--- a/tests/mgmt/face-manager.cpp
+++ b/tests/mgmt/face-manager.cpp
@@ -672,14 +672,14 @@
BOOST_AUTO_TEST_CASE(UnsignedCommand)
{
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp://127.0.0.1");
+ ControlParameters parameters;
+ parameters.setUri("tcp://127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
@@ -694,14 +694,14 @@
BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand, UnauthorizedCommandFixture<FaceManagerFixture>)
{
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp://127.0.0.1");
+ ControlParameters parameters;
+ parameters.setUri("tcp://127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -733,13 +733,13 @@
BOOST_FIXTURE_TEST_CASE(UnsupportedCommand, AuthorizedCommandFixture<FaceManagerFixture>)
{
- ndn::nfd::FaceManagementOptions options;
+ ControlParameters parameters;
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("unsupported");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -768,15 +768,15 @@
}
virtual void
- createFace(const Name& requestName,
- ndn::nfd::FaceManagementOptions& options)
+ createFace(const Interest& request,
+ ControlParameters& parameters)
{
m_createFaceFired = true;
}
virtual void
- destroyFace(const Name& requestName,
- ndn::nfd::FaceManagementOptions& options)
+ destroyFace(const Interest& request,
+ ControlParameters& parameters)
{
m_destroyFaceFired = true;
}
@@ -809,7 +809,7 @@
{
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append("NotReallyOptions");
+ commandName.append("NotReallyParameters");
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -826,14 +826,14 @@
BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestCreateFace,
AuthorizedCommandFixture<ValidatedFaceRequestFixture>)
{
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp://127.0.0.1");
+ ControlParameters parameters;
+ parameters.setUri("tcp://127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -845,14 +845,14 @@
BOOST_FIXTURE_TEST_CASE(ValidatedFaceRequestDestroyFace,
AuthorizedCommandFixture<ValidatedFaceRequestFixture>)
{
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp://127.0.0.1");
+ ControlParameters parameters;
+ parameters.setUri("tcp://127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("destroy");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -879,6 +879,379 @@
FaceTable m_faceTable;
};
+class LocalControlFixture : public FaceTableFixture,
+ public TestFaceManagerCommon,
+ public FaceManager
+{
+public:
+ LocalControlFixture()
+ : FaceManager(FaceTableFixture::m_faceTable, TestFaceManagerCommon::m_face)
+ {
+ }
+};
+
+BOOST_FIXTURE_TEST_CASE(LocalControlInFaceId,
+ AuthorizedCommandFixture<LocalControlFixture>)
+{
+ shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
+ BOOST_REQUIRE(dummy->isLocal());
+ FaceTableFixture::m_faceTable.add(dummy);
+
+ ControlParameters parameters;
+ parameters.setFaceId(dummy->getId());
+ parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name enable("/localhost/nfd/faces/enable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
+ enableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*enableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ enableCommand->getName(), 200, "Success", encodedParameters);
+
+ onValidatedFaceRequest(enableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+
+ TestFaceManagerCommon::m_face->onReceiveData.clear();
+ resetCallbackFired();
+
+ Name disable("/localhost/nfd/faces/disable-local-control");
+ disable.append(encodedParameters);
+
+ shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
+ disableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*disableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ disableCommand->getName(), 200, "Success", encodedParameters);
+
+ onValidatedFaceRequest(disableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+}
+
+BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdFaceNotFound,
+ AuthorizedCommandFixture<LocalControlFixture>)
+{
+ shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
+ BOOST_REQUIRE(dummy->isLocal());
+ FaceTableFixture::m_faceTable.add(dummy);
+
+ ControlParameters parameters;
+ parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name enable("/localhost/nfd/faces/enable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
+ enableCommand->setIncomingFaceId(dummy->getId() + 100);
+
+ generateCommand(*enableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ enableCommand->getName(), 410, "Requested face not found");
+
+ onValidatedFaceRequest(enableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+
+ TestFaceManagerCommon::m_face->onReceiveData.clear();
+ resetCallbackFired();
+
+ Name disable("/localhost/nfd/faces/disable-local-control");
+ disable.append(encodedParameters);
+
+ shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
+ disableCommand->setIncomingFaceId(dummy->getId() + 100);
+
+ generateCommand(*disableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ disableCommand->getName(), 410, "Requested face not found");
+
+ onValidatedFaceRequest(disableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+}
+
+BOOST_FIXTURE_TEST_CASE(LocalControlMissingFeature,
+ AuthorizedCommandFixture<LocalControlFixture>)
+{
+ shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
+ BOOST_REQUIRE(dummy->isLocal());
+ FaceTableFixture::m_faceTable.add(dummy);
+
+ ControlParameters parameters;
+ parameters.setFaceId(dummy->getId());
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name enable("/localhost/nfd/faces/enable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
+ enableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*enableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ enableCommand->getName(), 400, "Malformed command");
+
+ onValidatedFaceRequest(enableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+
+ TestFaceManagerCommon::m_face->onReceiveData.clear();
+ resetCallbackFired();
+
+ Name disable("/localhost/nfd/faces/disable-local-control");
+ disable.append(encodedParameters);
+
+ shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
+ disableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*disableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ disableCommand->getName(), 400, "Malformed command");
+
+ onValidatedFaceRequest(disableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+}
+
+BOOST_FIXTURE_TEST_CASE(LocalControlInFaceIdNonLocal,
+ AuthorizedCommandFixture<LocalControlFixture>)
+{
+ shared_ptr<DummyFace> dummy = make_shared<DummyFace>();
+ BOOST_REQUIRE(!dummy->isLocal());
+ FaceTableFixture::m_faceTable.add(dummy);
+
+ ControlParameters parameters;
+ parameters.setFaceId(dummy->getId());
+ parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name enable("/localhost/nfd/faces/enable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
+ enableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*enableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ enableCommand->getName(), 412, "Requested face is non-local");
+
+ onValidatedFaceRequest(enableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+
+ TestFaceManagerCommon::m_face->onReceiveData.clear();
+ resetCallbackFired();
+
+ Name disable("/localhost/nfd/faces/disable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> disableCommand(make_shared<Interest>(enable));
+ disableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*disableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ disableCommand->getName(), 412, "Requested face is non-local");
+
+ onValidatedFaceRequest(disableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+}
+
+BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceId,
+ AuthorizedCommandFixture<LocalControlFixture>)
+{
+ shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
+ BOOST_REQUIRE(dummy->isLocal());
+ FaceTableFixture::m_faceTable.add(dummy);
+
+ ControlParameters parameters;
+ parameters.setFaceId(dummy->getId());
+ parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name enable("/localhost/nfd/faces/enable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
+ enableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*enableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ enableCommand->getName(), 200, "Success", encodedParameters);
+
+ onValidatedFaceRequest(enableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+
+
+ TestFaceManagerCommon::m_face->onReceiveData.clear();
+ resetCallbackFired();
+
+ Name disable("/localhost/nfd/faces/disable-local-control");
+ disable.append(encodedParameters);
+
+ shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
+ disableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*disableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ disableCommand->getName(), 200, "Success", encodedParameters);
+
+ onValidatedFaceRequest(disableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+}
+
+BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdFaceNotFound,
+ AuthorizedCommandFixture<LocalControlFixture>)
+{
+ shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
+ BOOST_REQUIRE(dummy->isLocal());
+ FaceTableFixture::m_faceTable.add(dummy);
+
+ ControlParameters parameters;
+ parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name enable("/localhost/nfd/faces/enable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
+ enableCommand->setIncomingFaceId(dummy->getId() + 100);
+
+ generateCommand(*enableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ enableCommand->getName(), 410, "Requested face not found");
+
+ onValidatedFaceRequest(enableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+
+
+ TestFaceManagerCommon::m_face->onReceiveData.clear();
+ resetCallbackFired();
+
+ Name disable("/localhost/nfd/faces/disable-local-control");
+ disable.append(encodedParameters);
+
+ shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
+ disableCommand->setIncomingFaceId(dummy->getId() + 100);
+
+ generateCommand(*disableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ disableCommand->getName(), 410, "Requested face not found");
+
+ onValidatedFaceRequest(disableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID));
+ BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID));
+}
+
+BOOST_FIXTURE_TEST_CASE(LocalControlNextHopFaceIdNonLocal,
+ AuthorizedCommandFixture<LocalControlFixture>)
+{
+ shared_ptr<DummyFace> dummy = make_shared<DummyFace>();
+ BOOST_REQUIRE(!dummy->isLocal());
+ FaceTableFixture::m_faceTable.add(dummy);
+
+ ControlParameters parameters;
+ parameters.setFaceId(dummy->getId());
+ parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name enable("/localhost/nfd/faces/enable-local-control");
+ enable.append(encodedParameters);
+
+ shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
+ enableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*enableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ enableCommand->getName(), 412, "Requested face is non-local");
+
+ onValidatedFaceRequest(enableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+
+ TestFaceManagerCommon::m_face->onReceiveData.clear();
+ resetCallbackFired();
+
+ Name disable("/localhost/nfd/faces/disable-local-control");
+ disable.append(encodedParameters);
+
+ shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
+ disableCommand->setIncomingFaceId(dummy->getId());
+
+ generateCommand(*disableCommand);
+
+ TestFaceManagerCommon::m_face->onReceiveData +=
+ bind(&LocalControlFixture::validateControlResponse, this, _1,
+ disableCommand->getName(), 412, "Requested face is non-local");
+
+ onValidatedFaceRequest(disableCommand);
+
+ BOOST_REQUIRE(didCallbackFire());
+}
+
class FaceFixture : public FaceTableFixture,
public TestFaceManagerCommon,
public FaceManager
@@ -971,14 +1344,14 @@
BOOST_FIXTURE_TEST_CASE(CreateFaceBadUri, AuthorizedCommandFixture<FaceFixture>)
{
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp:/127.0.0.1");
+ ControlParameters parameters;
+ parameters.setUri("tcp:/127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -987,23 +1360,45 @@
bind(&FaceFixture::validateControlResponse, this, _1,
command->getName(), 400, "Malformed command");
- createFace(command->getName(), options);
+ createFace(*command, parameters);
+
+ BOOST_REQUIRE(didCallbackFire());
+}
+
+BOOST_FIXTURE_TEST_CASE(CreateFaceMissingUri, AuthorizedCommandFixture<FaceFixture>)
+{
+ ControlParameters parameters;
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name commandName("/localhost/nfd/faces");
+ commandName.append("create");
+ commandName.append(encodedParameters);
+
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+ generateCommand(*command);
+
+ getFace()->onReceiveData +=
+ bind(&FaceFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
+
+ createFace(*command, parameters);
BOOST_REQUIRE(didCallbackFire());
}
BOOST_FIXTURE_TEST_CASE(CreateFaceUnknownScheme, AuthorizedCommandFixture<FaceFixture>)
{
- ndn::nfd::FaceManagementOptions options;
+ ControlParameters parameters;
// this will be an unsupported protocol because no factories have been
// added to the face manager
- options.setUri("tcp://127.0.0.1");
+ parameters.setUri("tcp://127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -1012,28 +1407,28 @@
bind(&FaceFixture::validateControlResponse, this, _1,
command->getName(), 501, "Unsupported protocol");
- createFace(command->getName(), options);
+ createFace(*command, parameters);
BOOST_REQUIRE(didCallbackFire());
}
BOOST_FIXTURE_TEST_CASE(OnCreated, AuthorizedCommandFixture<FaceFixture>)
{
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp://127.0.0.1");
+ ControlParameters parameters;
+ parameters.setUri("tcp://127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
- ndn::nfd::FaceManagementOptions resultOptions;
- resultOptions.setUri("tcp://127.0.0.1");
- resultOptions.setFaceId(1);
+ ControlParameters resultParameters;
+ resultParameters.setUri("tcp://127.0.0.1");
+ resultParameters.setFaceId(1);
shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
@@ -1042,14 +1437,14 @@
dummy->getUri().toString(),
0);
- Block encodedResultOptions(resultOptions.wireEncode());
+ Block encodedResultParameters(resultParameters.wireEncode());
getFace()->onReceiveData +=
bind(&FaceFixture::callbackDispatch, this, _1,
- command->getName(), 200, "Success",
- encodedResultOptions, expectedFaceEvent);
+ command->getName(), 200, "Success",
+ encodedResultParameters, expectedFaceEvent);
- onCreated(command->getName(), options, dummy);
+ onCreated(command->getName(), parameters, dummy);
BOOST_REQUIRE(didCallbackFire());
BOOST_REQUIRE(didReceiveNotication());
@@ -1057,14 +1452,14 @@
BOOST_FIXTURE_TEST_CASE(OnConnectFailed, AuthorizedCommandFixture<FaceFixture>)
{
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp://127.0.0.1");
+ ControlParameters parameters;
+ parameters.setUri("tcp://127.0.0.1");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("create");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -1085,15 +1480,15 @@
shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
FaceTableFixture::m_faceTable.add(dummy);
- ndn::nfd::FaceManagementOptions options;
- options.setUri("tcp://127.0.0.1");
- options.setFaceId(dummy->getId());
+ ControlParameters parameters;
+ parameters.setUri("tcp://127.0.0.1");
+ parameters.setFaceId(dummy->getId());
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/faces");
commandName.append("destroy");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -1104,9 +1499,9 @@
getFace()->onReceiveData +=
bind(&FaceFixture::callbackDispatch, this, _1,
- command->getName(), 200, "Success", boost::ref(encodedOptions), expectedFaceEvent);
+ command->getName(), 200, "Success", boost::ref(encodedParameters), expectedFaceEvent);
- destroyFace(command->getName(), options);
+ destroyFace(*command, parameters);
BOOST_REQUIRE(didCallbackFire());
BOOST_REQUIRE(didReceiveNotication());
diff --git a/tests/mgmt/fib-manager.cpp b/tests/mgmt/fib-manager.cpp
index f388f47..5076e0d 100644
--- a/tests/mgmt/fib-manager.cpp
+++ b/tests/mgmt/fib-manager.cpp
@@ -97,7 +97,7 @@
expectedCode, expectedText, control);
BOOST_REQUIRE(!control.getBody().empty());
- BOOST_REQUIRE(control.getBody().value_size() == expectedBody.value_size());
+ BOOST_REQUIRE_EQUAL(control.getBody().value_size(), expectedBody.value_size());
BOOST_CHECK(memcmp(control.getBody().value(), expectedBody.value(),
expectedBody.value_size()) == 0);
@@ -253,16 +253,16 @@
{
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
- options.setCost(1);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
+ parameters.setCost(1);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("unsupported");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -282,16 +282,16 @@
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
- options.setCost(101);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
+ parameters.setCost(101);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
Interest command(commandName);
@@ -312,16 +312,16 @@
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
- options.setCost(101);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
+ parameters.setCost(101);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -344,7 +344,7 @@
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append("NotReallyOptions");
+ commandName.append("NotReallyParameters");
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -364,23 +364,23 @@
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1000);
- options.setCost(101);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1000);
+ parameters.setCost(101);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 404, "Face not found");
+ command->getName(), 410, "Face not found");
getFibManager().onFibRequest(*command);
@@ -394,23 +394,23 @@
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(0);
- options.setCost(101);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(0);
+ parameters.setCost(101);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
- FibManagementOptions expectedOptions;
- expectedOptions.setName("/hello");
- expectedOptions.setFaceId(1);
- expectedOptions.setCost(101);
+ ControlParameters expectedParameters;
+ expectedParameters.setName("/hello");
+ expectedParameters.setFaceId(1);
+ expectedParameters.setCost(101);
- Block encodedExpectedOptions(expectedOptions.wireEncode());
+ Block encodedExpectedParameters(expectedParameters.wireEncode());
shared_ptr<Interest> command(make_shared<Interest>(commandName));
command->setIncomingFaceId(1);
@@ -418,7 +418,7 @@
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 200, "Success", encodedExpectedOptions);
+ command->getName(), 200, "Success", encodedExpectedParameters);
getFibManager().onFibRequest(*command);
@@ -432,23 +432,23 @@
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
- options.setCost(101);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
+ parameters.setCost(101);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 200, "Success", encodedOptions);
+ command->getName(), 200, "Success", encodedParameters);
getFibManager().onFibRequest(*command);
@@ -456,6 +456,40 @@
BOOST_REQUIRE(addedNextHopWithCost(getFib(), "/hello", 0, 101));
}
+BOOST_AUTO_TEST_CASE(AddNextHopVerbImplicitCost)
+{
+ addFace(make_shared<DummyFace>());
+
+ shared_ptr<InternalFace> face = getInternalFace();
+
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name commandName("/localhost/nfd/fib");
+ commandName.append("add-nexthop");
+ commandName.append(encodedParameters);
+
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+ generateCommand(*command);
+
+ ControlParameters resultParameters;
+ resultParameters.setName("/hello");
+ resultParameters.setFaceId(1);
+ resultParameters.setCost(0);
+
+ face->onReceiveData +=
+ bind(&FibManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 200, "Success", resultParameters.wireEncode());
+
+ getFibManager().onFibRequest(*command);
+
+ BOOST_REQUIRE(didCallbackFire());
+ BOOST_REQUIRE(addedNextHopWithCost(getFib(), "/hello", 0, 0));
+}
+
BOOST_AUTO_TEST_CASE(AddNextHopVerbAddToExisting)
{
addFace(make_shared<DummyFace>());
@@ -464,23 +498,23 @@
for (int i = 1; i <= 2; i++)
{
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
- options.setCost(100 + i);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
+ parameters.setCost(100 + i);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 200, "Success", encodedOptions);
+ command->getName(), 200, "Success", encodedParameters);
getFibManager().onFibRequest(*command);
BOOST_REQUIRE(didCallbackFire());
@@ -510,25 +544,25 @@
addFace(make_shared<DummyFace>());
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
{
- options.setCost(1);
+ parameters.setCost(1);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 200, "Success", encodedOptions);
+ command->getName(), 200, "Success", encodedParameters);
getFibManager().onFibRequest(*command);
@@ -539,20 +573,20 @@
face->onReceiveData.clear();
{
- options.setCost(102);
+ parameters.setCost(102);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("add-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 200, "Success", encodedOptions);
+ command->getName(), 200, "Success", encodedParameters);
getFibManager().onFibRequest(*command);
@@ -578,151 +612,59 @@
}
}
-// BOOST_AUTO_TEST_CASE(Insert)
-// {
-// addFace(make_shared<DummyFace>());
-// addFace(make_shared<DummyFace>());
-// shared_ptr<InternalFace> face = getInternalFace();
+BOOST_AUTO_TEST_CASE(AddNextHopVerbMissingPrefix)
+{
+ addFace(make_shared<DummyFace>());
-// {
-// FibManagementOptions options;
-// options.setName("/hello");
-// options.setFaceId(1);
-// options.setCost(101);
+ shared_ptr<InternalFace> face = getInternalFace();
-// Block encodedOptions(options.wireEncode());
+ ControlParameters parameters;
+ parameters.setFaceId(1);
-// Name commandName("/localhost/nfd/fib");
-// commandName.append("add-nexthop");
-// commandName.append(encodedOptions);
+ Block encodedParameters(parameters.wireEncode());
-// shared_ptr<Interest> command(make_shared<Interest>(commandName));
-// generateCommand(*command);
+ Name commandName("/localhost/nfd/fib");
+ commandName.append("add-nexthop");
+ commandName.append(encodedParameters);
-// face->onReceiveData +=
-// bind(&FibManagerFixture::validateControlResponse, this, _1,
-// command->getName(), 200, "Success", encodedOptions);
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+ generateCommand(*command);
-// getFibManager().onFibRequest(*command);
-// }
+ face->onReceiveData +=
+ bind(&FibManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
-// BOOST_REQUIRE(didCallbackFire());
+ getFibManager().onFibRequest(*command);
-// shared_ptr<fib::Entry> entry = getFib().findExactMatch("/hello");
-// if (static_cast<bool>(entry))
-// {
-// const fib::NextHopList& hops = entry->getNextHops();
-// BOOST_CHECK_EQUAL(hops.size(), 1);
-// }
+ BOOST_REQUIRE(didCallbackFire());
+}
-// resetCallbackFired();
-// face->onReceiveData.clear();
+BOOST_AUTO_TEST_CASE(AddNextHopVerbMissingFaceId)
+{
+ addFace(make_shared<DummyFace>());
-// {
-// FibManagementOptions options;
-// options.setName("/hello");
-// options.setFaceId(2);
-// options.setCost(102);
+ shared_ptr<InternalFace> face = getInternalFace();
-// Block encodedOptions(options.wireEncode());
+ ControlParameters parameters;
+ parameters.setName("/hello");
-// Name commandName("/localhost/nfd/fib");
-// commandName.append("add-nexthop");
-// commandName.append(encodedOptions);
+ Block encodedParameters(parameters.wireEncode());
-// shared_ptr<Interest> command(make_shared<Interest>(commandName));
-// generateCommand(*command);
+ Name commandName("/localhost/nfd/fib");
+ commandName.append("add-nexthop");
+ commandName.append(encodedParameters);
-// face->onReceiveData +=
-// bind(&FibManagerFixture::validateControlResponse, this, _1,
-// command->getName(), 200, "Success", encodedOptions);
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+ generateCommand(*command);
-// getFibManager().onFibRequest(*command);
-// }
+ face->onReceiveData +=
+ bind(&FibManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
-// BOOST_REQUIRE(didCallbackFire());
+ getFibManager().onFibRequest(*command);
-// entry = getFib().findExactMatch("/hello");
-// if (static_cast<bool>(entry))
-// {
-// const fib::NextHopList& hops = entry->getNextHops();
-// BOOST_CHECK_EQUAL(hops.size(), 2);
-// }
-
-// }
-
-// void
-// testRemove(CommandFixture<FibManagerFixture>* fixture,
-// FibManager& manager,
-// Fib& fib,
-// shared_ptr<Face> face,
-// const Name& target)
-// {
-// FibManagementOptions options;
-// options.setName(target);
-
-// Block encodedOptions(options.wireEncode());
-
-// Name commandName("/localhost/nfd/fib");
-// commandName.append("delete");
-// commandName.append(encodedOptions);
-
-// shared_ptr<Interest> command(make_shared<Interest>(commandName));
-// fixture->generateCommand(*command);
-
-// face->onReceiveData +=
-// bind(&FibManagerFixture::validateControlResponse, fixture, _1,
-// command->getName(), 200, "Success", encodedOptions);
-
-// manager.onFibRequest(*command);
-
-// BOOST_REQUIRE(fixture->didCallbackFire());
-
-// if (static_cast<bool>(fib.findExactMatch(target)))
-// {
-// BOOST_FAIL("Found \"removed\" prefix");
-// }
-// face->onReceiveData.clear();
-// }
-
-// BOOST_AUTO_TEST_CASE(Delete)
-// {
-// shared_ptr<InternalFace> face = getInternalFace();
-// FibManager& manager = getFibManager();
-// Fib& fib = getFib();
-
-// fib.insert("/a");
-// fib.insert("/a/b");
-// fib.insert("/a/b/c");
-
-// testRemove(this, manager, fib, face, "/");
-
-// if (!static_cast<bool>(fib.findExactMatch("/a")) ||
-// !static_cast<bool>(fib.findExactMatch("/a/b")) ||
-// !static_cast<bool>(fib.findExactMatch("/a/b/c")))
-// {
-// BOOST_FAIL("Removed incorrect entry");
-// }
-
-// testRemove(this, manager, fib, face, "/a/b");
-
-// if (!static_cast<bool>(fib.findExactMatch("/a")) ||
-// !static_cast<bool>(fib.findExactMatch("/a/b/c")))
-// {
-// BOOST_FAIL("Removed incorrect entry");
-// }
-
-// testRemove(this, manager, fib, face, "/a/b/c");
-
-// if (!static_cast<bool>(fib.findExactMatch("/a")))
-// {
-// BOOST_FAIL("Removed incorrect entry");
-// }
-
-// testRemove(this, manager, fib, face, "/a");
-
-// testRemove(this, manager, fib, face, "/does/not/exist");
-// }
+ BOOST_REQUIRE(didCallbackFire());
+}
bool
removedNextHopWithCost(const Fib& fib, const Name& prefix, size_t oldSize, uint32_t cost)
@@ -746,22 +688,22 @@
const Name& targetName,
FaceId targetFace)
{
- FibManagementOptions options;
- options.setName(targetName);
- options.setFaceId(targetFace);
+ ControlParameters parameters;
+ parameters.setName(targetName);
+ parameters.setFaceId(targetFace);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("remove-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
fixture->generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, fixture, _1,
- command->getName(), 200, "Success", encodedOptions);
+ command->getName(), 200, "Success", encodedParameters);
manager.onFibRequest(*command);
@@ -803,54 +745,108 @@
BOOST_CHECK(!static_cast<bool>(getFib().findExactMatch("/hello")));
}
-BOOST_AUTO_TEST_CASE(RemoveNoFace)
+BOOST_AUTO_TEST_CASE(RemoveFaceNotFound)
{
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("remove-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 404, "Face not found");
+ command->getName(), 200, "Success", encodedParameters);
getFibManager().onFibRequest(*command);
BOOST_REQUIRE(didCallbackFire());
}
-BOOST_AUTO_TEST_CASE(RemoveNoPrefix)
+BOOST_AUTO_TEST_CASE(RemovePrefixNotFound)
{
addFace(make_shared<DummyFace>());
shared_ptr<InternalFace> face = getInternalFace();
- FibManagementOptions options;
- options.setName("/hello");
- options.setFaceId(1);
+ ControlParameters parameters;
+ parameters.setName("/hello");
+ parameters.setFaceId(1);
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/fib");
commandName.append("remove-nexthop");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
face->onReceiveData +=
bind(&FibManagerFixture::validateControlResponse, this, _1,
- command->getName(), 404, "Prefix not found");
+ command->getName(), 200, "Success", encodedParameters);
+
+ getFibManager().onFibRequest(*command);
+
+ BOOST_REQUIRE(didCallbackFire());
+}
+
+BOOST_AUTO_TEST_CASE(RemoveMissingPrefix)
+{
+ addFace(make_shared<DummyFace>());
+
+ shared_ptr<InternalFace> face = getInternalFace();
+
+ ControlParameters parameters;
+ parameters.setFaceId(1);
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name commandName("/localhost/nfd/fib");
+ commandName.append("remove-nexthop");
+ commandName.append(encodedParameters);
+
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+ generateCommand(*command);
+
+ face->onReceiveData +=
+ bind(&FibManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
+
+ getFibManager().onFibRequest(*command);
+
+ BOOST_REQUIRE(didCallbackFire());
+}
+
+BOOST_AUTO_TEST_CASE(RemoveMissingFaceId)
+{
+ addFace(make_shared<DummyFace>());
+
+ shared_ptr<InternalFace> face = getInternalFace();
+
+ ControlParameters parameters;
+ parameters.setName("/hello");
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name commandName("/localhost/nfd/fib");
+ commandName.append("remove-nexthop");
+ commandName.append(encodedParameters);
+
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+ generateCommand(*command);
+
+ face->onReceiveData +=
+ bind(&FibManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
getFibManager().onFibRequest(*command);
diff --git a/tests/mgmt/local-control-header-manager.cpp b/tests/mgmt/local-control-header-manager.cpp
deleted file mode 100644
index 168f43f..0000000
--- a/tests/mgmt/local-control-header-manager.cpp
+++ /dev/null
@@ -1,348 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (C) 2014 Named Data Networking Project
- * See COPYING for copyright and distribution information.
- */
-
-#include "mgmt/local-control-header-manager.hpp"
-#include "mgmt/internal-face.hpp"
-#include "tests/face/dummy-face.hpp"
-
-#include "tests/test-common.hpp"
-#include "validation-common.hpp"
-
-namespace nfd {
-namespace tests {
-
-NFD_LOG_INIT("LocalControlHeaderManagerTest");
-
-class LocalControlHeaderManagerFixture : protected BaseFixture
-{
-public:
-
- shared_ptr<Face>
- getFace(FaceId id)
- {
- if (id > 0 && static_cast<size_t>(id) <= m_faces.size())
- {
- return m_faces[id - 1];
- }
- NFD_LOG_DEBUG("No face found returning NULL");
- return shared_ptr<DummyFace>();
- }
-
- void
- addFace(shared_ptr<Face> face)
- {
- m_faces.push_back(face);
- }
-
- shared_ptr<InternalFace>
- getInternalFace()
- {
- return m_face;
- }
-
- LocalControlHeaderManager&
- getManager()
- {
- return m_manager;
- }
-
- void
- addInterestRule(const std::string& regex,
- ndn::IdentityCertificate& certificate)
- {
- m_manager.addInterestRule(regex, certificate);
- }
-
- void
- validateControlResponse(const Data& response,
- const Name& expectedName,
- uint32_t expectedCode,
- const std::string& expectedText)
- {
- m_callbackFired = true;
-
- ControlResponse control;
- Block controlRaw = response.getContent().blockFromValue();
-
- control.wireDecode(controlRaw);
-
- NFD_LOG_DEBUG("received control response"
- << " Name: " << response.getName()
- << " code: " << control.getCode()
- << " text: " << control.getText());
-
- BOOST_CHECK_EQUAL(response.getName(), expectedName);
- BOOST_CHECK_EQUAL(control.getCode(), expectedCode);
- BOOST_CHECK_EQUAL(control.getText(), expectedText);
-
- if (!control.getBody().empty())
- {
- BOOST_FAIL("found unexpected control response body");
- }
- }
-
- bool
- didCallbackFire()
- {
- return m_callbackFired;
- }
-
- void
- resetCallbackFired()
- {
- m_callbackFired = false;
- }
-
-protected:
- LocalControlHeaderManagerFixture()
- : m_face(make_shared<InternalFace>()),
- m_manager(bind(&LocalControlHeaderManagerFixture::getFace, this, _1),
- m_face),
- m_callbackFired(false)
- {
- }
-
-private:
- shared_ptr<InternalFace> m_face;
- LocalControlHeaderManager m_manager;
- std::vector<shared_ptr<Face> > m_faces;
- bool m_callbackFired;
-};
-
-template <typename T> class AuthorizedCommandFixture:
- public CommandFixture<T>
-{
-public:
- AuthorizedCommandFixture()
- {
- const std::string regex = "^<localhost><nfd><control-header>";
- T::addInterestRule(regex, *CommandFixture<T>::m_certificate);
- }
-
- virtual
- ~AuthorizedCommandFixture()
- {
- }
-};
-
-BOOST_FIXTURE_TEST_SUITE(MgmtLocalControlHeaderManager,
- AuthorizedCommandFixture<LocalControlHeaderManagerFixture>)
-
-BOOST_AUTO_TEST_CASE(InFaceId)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name enable("/localhost/nfd/control-header/in-faceid/enable");
- shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
- enableCommand->setIncomingFaceId(1);
-
- generateCommand(*enableCommand);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- enableCommand->getName(), 200, "Success");
-
- getManager().onLocalControlHeaderRequest(*enableCommand);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
-
- getInternalFace()->onReceiveData.clear();
- resetCallbackFired();
-
- Name disable("/localhost/nfd/control-header/in-faceid/disable");
- shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
- disableCommand->setIncomingFaceId(1);
-
- generateCommand(*disableCommand);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- disableCommand->getName(), 200, "Success");
-
- getManager().onLocalControlHeaderRequest(*disableCommand);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
-}
-
-BOOST_AUTO_TEST_CASE(NextHopFaceId)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name enable("/localhost/nfd/control-header/nexthop-faceid/enable");
-
- shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
- enableCommand->setIncomingFaceId(1);
- generateCommand(*enableCommand);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- enableCommand->getName(), 200, "Success");
-
- getManager().onLocalControlHeaderRequest(*enableCommand);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_REQUIRE(dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
-
- getInternalFace()->onReceiveData.clear();
- resetCallbackFired();
-
- Name disable("/localhost/nfd/control-header/nexthop-faceid/disable");
- shared_ptr<Interest> disableCommand(make_shared<Interest>(disable));
- disableCommand->setIncomingFaceId(1);
-
- generateCommand(*disableCommand);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- disableCommand->getName(), 200, "Success");
-
- getManager().onLocalControlHeaderRequest(*disableCommand);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
-}
-
-BOOST_AUTO_TEST_CASE(ShortCommand)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name commandName("/localhost/nfd/control-header");
- Interest command(commandName);
- command.setIncomingFaceId(1);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- commandName, 400, "Malformed command");
-
- getManager().onLocalControlHeaderRequest(command);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
-}
-
-BOOST_AUTO_TEST_CASE(ShortCommandModule)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name commandName("/localhost/nfd/control-header/in-faceid");
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- commandName, 400, "Malformed command");
-
- Interest command(commandName);
- command.setIncomingFaceId(1);
- getManager().onLocalControlHeaderRequest(command);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
-}
-
-BOOST_AUTO_TEST_CASE(UnsupportedModule)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name commandName("/localhost/nfd/control-header/madeup/moremadeup");
- shared_ptr<Interest> command(make_shared<Interest>(commandName));
- command->setIncomingFaceId(1);
-
- generateCommand(*command);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- command->getName(), 501, "Unsupported");
-
- getManager().onLocalControlHeaderRequest(*command);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
-}
-
-BOOST_AUTO_TEST_CASE(InFaceIdUnsupportedVerb)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name commandName("/localhost/nfd/control-header/in-faceid/madeup");
- shared_ptr<Interest> command(make_shared<Interest>(commandName));
- command->setIncomingFaceId(1);
-
-
- generateCommand(*command);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- command->getName(), 501, "Unsupported");
-
- getManager().onLocalControlHeaderRequest(*command);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
-}
-
-BOOST_AUTO_TEST_CASE(NextHopFaceIdUnsupportedVerb)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name commandName("/localhost/nfd/control-header/nexthop-faceid/madeup");
- shared_ptr<Interest> command(make_shared<Interest>(commandName));
- command->setIncomingFaceId(1);
-
- generateCommand(*command);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- command->getName(), 501, "Unsupported");
-
- getManager().onLocalControlHeaderRequest(*command);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
- BOOST_CHECK(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_NEXTHOP_FACEID));
-}
-
-BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand,
- UnauthorizedCommandFixture<LocalControlHeaderManagerFixture>)
-{
- shared_ptr<LocalFace> dummy = make_shared<DummyLocalFace>();
- addFace(dummy);
-
- Name enable("/localhost/nfd/control-header/in-faceid/enable");
- shared_ptr<Interest> enableCommand(make_shared<Interest>(enable));
- enableCommand->setIncomingFaceId(1);
-
- generateCommand(*enableCommand);
-
- getInternalFace()->onReceiveData +=
- bind(&LocalControlHeaderManagerFixture::validateControlResponse, this, _1,
- enableCommand->getName(), 403, "Unauthorized command");
-
- getManager().onLocalControlHeaderRequest(*enableCommand);
-
- BOOST_REQUIRE(didCallbackFire());
- BOOST_REQUIRE(!dummy->isLocalControlHeaderEnabled(LOCAL_CONTROL_HEADER_FEATURE_IN_FACEID));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace tests
-} // namespace nfd
diff --git a/tests/mgmt/manager-base.cpp b/tests/mgmt/manager-base.cpp
index fb10973..4e690a9 100644
--- a/tests/mgmt/manager-base.cpp
+++ b/tests/mgmt/manager-base.cpp
@@ -37,6 +37,15 @@
void
testSendResponse(const Name& name,
uint32_t code,
+ const std::string& text,
+ const Block& body)
+ {
+ sendResponse(name, code, text, body);
+ }
+
+ void
+ testSendResponse(const Name& name,
+ uint32_t code,
const std::string& text)
{
sendResponse(name, code, text);
@@ -77,6 +86,34 @@
BOOST_REQUIRE(control.getText() == expectedText);
}
+ void
+ validateControlResponse(const Data& response,
+ const Name& expectedName,
+ uint32_t expectedCode,
+ const std::string& expectedText,
+ const Block& expectedBody)
+ {
+ m_callbackFired = true;
+ Block controlRaw = response.getContent().blockFromValue();
+
+ ControlResponse control;
+ control.wireDecode(controlRaw);
+
+ NFD_LOG_DEBUG("received control response"
+ << " name: " << response.getName()
+ << " code: " << control.getCode()
+ << " text: " << control.getText());
+
+ BOOST_REQUIRE(response.getName() == expectedName);
+ BOOST_REQUIRE(control.getCode() == expectedCode);
+ BOOST_REQUIRE(control.getText() == expectedText);
+
+ BOOST_REQUIRE(control.getBody().value_size() == expectedBody.value_size());
+
+ BOOST_CHECK(memcmp(control.getBody().value(), expectedBody.value(),
+ expectedBody.value_size()) == 0);
+ }
+
bool
didCallbackFire()
{
@@ -104,6 +141,19 @@
BOOST_CHECK_EQUAL(response.getText(), "test");
}
+BOOST_AUTO_TEST_CASE(SendResponse4Arg)
+{
+ ndn::nfd::ControlParameters parameters;
+ parameters.setName("/test/body");
+
+ getInternalFace()->onReceiveData +=
+ bind(&ManagerBaseTest::validateControlResponse, this, _1,
+ "/response", 100, "test", parameters.wireEncode());
+
+ testSendResponse("/response", 100, "test", parameters.wireEncode());
+ BOOST_REQUIRE(didCallbackFire());
+}
+
BOOST_AUTO_TEST_CASE(SendResponse3Arg)
{
@@ -115,7 +165,6 @@
BOOST_REQUIRE(didCallbackFire());
}
-
BOOST_AUTO_TEST_CASE(SendResponse2Arg)
{
getInternalFace()->onReceiveData +=
diff --git a/tests/mgmt/strategy-choice-manager.cpp b/tests/mgmt/strategy-choice-manager.cpp
index 4703fb7..f24d58a 100644
--- a/tests/mgmt/strategy-choice-manager.cpp
+++ b/tests/mgmt/strategy-choice-manager.cpp
@@ -208,15 +208,15 @@
BOOST_FIXTURE_TEST_CASE(UnsignedCommand, AllStrategiesFixture)
{
- ndn::nfd::StrategyChoiceOptions options;
- options.setName("/test");
- options.setStrategy("/localhost/nfd/strategy/best-route");
+ ControlParameters parameters;
+ parameters.setName("/test");
+ parameters.setStrategy("/localhost/nfd/strategy/best-route");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("set");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
@@ -232,15 +232,15 @@
BOOST_FIXTURE_TEST_CASE(UnauthorizedCommand,
UnauthorizedCommandFixture<StrategyChoiceManagerFixture>)
{
- ndn::nfd::StrategyChoiceOptions options;
- options.setName("/test");
- options.setStrategy("/localhost/nfd/strategy/best-route");
+ ControlParameters parameters;
+ parameters.setName("/test");
+ parameters.setStrategy("/localhost/nfd/strategy/best-route");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("set");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -256,14 +256,15 @@
BOOST_AUTO_TEST_CASE(UnsupportedVerb)
{
- ndn::nfd::StrategyChoiceOptions options;
- options.setStrategy("/localhost/nfd/strategy/test-strategy-b");
+ ControlParameters parameters;
+ parameters.setName("/test");
+ parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("unsupported");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -281,7 +282,7 @@
{
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("set");
- commandName.append("NotReallyOptions");
+ commandName.append("NotReallyParameters");
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -297,43 +298,86 @@
BOOST_AUTO_TEST_CASE(SetStrategies)
{
- ndn::nfd::StrategyChoiceOptions options;
- options.setName("/test");
- options.setStrategy("/localhost/nfd/strategy/test-strategy-b");
+ ControlParameters parameters;
+ parameters.setName("/test");
+ parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("set");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
getFace()->onReceiveData +=
bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
- command->getName(), 200, "Success", encodedOptions);
+ command->getName(), 200, "Success", encodedParameters);
getManager().onValidatedStrategyChoiceRequest(command);
BOOST_REQUIRE(didCallbackFire());
fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
BOOST_REQUIRE_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-b");
+}
- resetCallbackFired();
- getFace()->onReceiveData.clear();
+BOOST_AUTO_TEST_CASE(SetStrategiesMissingName)
+{
+ ControlParameters parameters;
+ parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name commandName("/localhost/nfd/strategy-choice");
+ commandName.append("set");
+ commandName.append(encodedParameters);
+
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+
+ getFace()->onReceiveData +=
+ bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
+
+ getManager().onValidatedStrategyChoiceRequest(command);
+
+ BOOST_REQUIRE(didCallbackFire());
+}
+
+BOOST_AUTO_TEST_CASE(SetStrategiesMissingStrategy)
+{
+ ControlParameters parameters;
+ parameters.setName("/test");
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name commandName("/localhost/nfd/strategy-choice");
+ commandName.append("set");
+ commandName.append(encodedParameters);
+
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+
+ getFace()->onReceiveData +=
+ bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
+
+ getManager().onValidatedStrategyChoiceRequest(command);
+
+ BOOST_REQUIRE(didCallbackFire());
+ fw::Strategy& strategy = getStrategyChoice().findEffectiveStrategy("/test");
+ BOOST_REQUIRE_EQUAL(strategy.getName(), "/localhost/nfd/strategy/test-strategy-a");
}
BOOST_AUTO_TEST_CASE(SetUnsupportedStrategy)
{
- ndn::nfd::StrategyChoiceOptions options;
- options.setName("/test");
- options.setStrategy("/localhost/nfd/strategy/unit-test-doesnotexist");
+ ControlParameters parameters;
+ parameters.setName("/test");
+ parameters.setStrategy("/localhost/nfd/strategy/unit-test-doesnotexist");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("set");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -370,15 +414,15 @@
// BOOST_FIXTURE_TEST_CASE(SetNotInstalled, DefaultStrategyOnlyFixture)
// {
// BOOST_REQUIRE(!getStrategyChoice().hasStrategy("/localhost/nfd/strategy/test-strategy-b"));
-// ndn::nfd::StrategyChoiceOptions options;
-// options.setName("/test");
-// options.setStrategy("/localhost/nfd/strategy/test-strategy-b");
+// ControlParameters parameters;
+// parameters.setName("/test");
+// parameters.setStrategy("/localhost/nfd/strategy/test-strategy-b");
-// Block encodedOptions(options.wireEncode());
+// Block encodedParameters(parameters.wireEncode());
// Name commandName("/localhost/nfd/strategy-choice");
// commandName.append("set");
-// commandName.append(encodedOptions);
+// commandName.append(encodedParameters);
// shared_ptr<Interest> command(make_shared<Interest>(commandName));
// generateCommand(*command);
@@ -396,25 +440,25 @@
BOOST_AUTO_TEST_CASE(Unset)
{
- ndn::nfd::StrategyChoiceOptions options;
- options.setName("/test");
+ ControlParameters parameters;
+ parameters.setName("/test");
BOOST_REQUIRE(m_strategyChoice.insert("/test", "/localhost/nfd/strategy/test-strategy-b"));
BOOST_REQUIRE_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
"/localhost/nfd/strategy/test-strategy-b");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("unset");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
getFace()->onReceiveData +=
bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
- command->getName(), 200, "Success", encodedOptions);
+ command->getName(), 200, "Success", encodedParameters);
getManager().onValidatedStrategyChoiceRequest(command);
@@ -426,14 +470,14 @@
BOOST_AUTO_TEST_CASE(UnsetRoot)
{
- ndn::nfd::StrategyChoiceOptions options;
- options.setName("/");
+ ControlParameters parameters;
+ parameters.setName("/");
- Block encodedOptions(options.wireEncode());
+ Block encodedParameters(parameters.wireEncode());
Name commandName("/localhost/nfd/strategy-choice");
commandName.append("unset");
- commandName.append(encodedOptions);
+ commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
@@ -450,6 +494,35 @@
"/localhost/nfd/strategy/test-strategy-a");
}
+BOOST_AUTO_TEST_CASE(UnsetMissingName)
+{
+ ControlParameters parameters;
+
+ BOOST_REQUIRE(m_strategyChoice.insert("/test", "/localhost/nfd/strategy/test-strategy-b"));
+ BOOST_REQUIRE_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
+ "/localhost/nfd/strategy/test-strategy-b");
+
+ Block encodedParameters(parameters.wireEncode());
+
+ Name commandName("/localhost/nfd/strategy-choice");
+ commandName.append("unset");
+ commandName.append(encodedParameters);
+
+ shared_ptr<Interest> command(make_shared<Interest>(commandName));
+ generateCommand(*command);
+
+ getFace()->onReceiveData +=
+ bind(&StrategyChoiceManagerFixture::validateControlResponse, this, _1,
+ command->getName(), 400, "Malformed command");
+
+ getManager().onValidatedStrategyChoiceRequest(command);
+
+ BOOST_REQUIRE(didCallbackFire());
+
+ BOOST_CHECK_EQUAL(m_strategyChoice.findEffectiveStrategy("/test").getName(),
+ "/localhost/nfd/strategy/test-strategy-b");
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests