face+mgmt: enable local fields through ProtocolFactory::createFace
refs #3731
Change-Id: I569dae59cda150ffcb1c0ff1d01a575d8850beca
diff --git a/tests/daemon/face/ethernet-factory.t.cpp b/tests/daemon/face/ethernet-factory.t.cpp
index b9e9cda..248a668 100644
--- a/tests/daemon/face/ethernet-factory.t.cpp
+++ b/tests/daemon/face/ethernet-factory.t.cpp
@@ -69,16 +69,19 @@
createFace(factory,
FaceUri("ether://[08:00:27:01:01:01]"),
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("ether://[08:00:27:01:01:01]"),
ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("ether://[08:00:27:01:01:01]"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
}
diff --git a/tests/daemon/face/factory-test-common.hpp b/tests/daemon/face/factory-test-common.hpp
index 8676be5..e842ced 100644
--- a/tests/daemon/face/factory-test-common.hpp
+++ b/tests/daemon/face/factory-test-common.hpp
@@ -44,9 +44,10 @@
createFace(ProtocolFactory& factory,
const FaceUri& uri,
ndn::nfd::FacePersistency persistency,
+ bool wantLocalFieldsEnabled,
const CreateFaceExpectedResult& expected)
{
- factory.createFace(uri, persistency,
+ factory.createFace(uri, persistency, wantLocalFieldsEnabled,
[expected] (const shared_ptr<Face>& newFace) {
BOOST_CHECK_EQUAL(CreateFaceExpectedResult::SUCCESS, expected.result);
},
diff --git a/tests/daemon/face/tcp-channel.t.cpp b/tests/daemon/face/tcp-channel.t.cpp
index d04ea26..f8dae5d 100644
--- a/tests/daemon/face/tcp-channel.t.cpp
+++ b/tests/daemon/face/tcp-channel.t.cpp
@@ -77,7 +77,7 @@
void
connect(TcpChannel& channel)
{
- channel.connect(listenerEp,
+ channel.connect(listenerEp, false,
[this] (const shared_ptr<Face>& newFace) {
BOOST_REQUIRE(newFace != nullptr);
connectFaceClosedSignal(*newFace, [this] { limitedIo.afterOp(); });
@@ -177,7 +177,7 @@
// do not listen
auto channel = makeChannel(A());
- channel->connect(tcp::Endpoint(address, 7040),
+ channel->connect(tcp::Endpoint(address, 7040), false,
[this] (const shared_ptr<Face>&) {
BOOST_FAIL("Connect succeeded when it should have failed");
this->limitedIo.afterOp();
diff --git a/tests/daemon/face/tcp-factory.t.cpp b/tests/daemon/face/tcp-factory.t.cpp
index 7418b26..a617011 100644
--- a/tests/daemon/face/tcp-factory.t.cpp
+++ b/tests/daemon/face/tcp-factory.t.cpp
@@ -79,6 +79,7 @@
createFace(factory,
FaceUri("tcp4://127.0.0.1:6363"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
factory.createChannel("127.0.0.1", "20071");
@@ -86,6 +87,7 @@
createFace(factory,
FaceUri("tcp4://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
{CreateFaceExpectedResult::SUCCESS, 0, ""});
}
@@ -99,12 +101,14 @@
createFace(factory,
FaceUri("tcp4://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 406,
"Outgoing TCP faces only support persistent persistency"});
createFace(factory,
FaceUri("tcp4://127.0.0.1:20071"),
ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ false,
{CreateFaceExpectedResult::FAILURE, 406,
"Outgoing TCP faces only support persistent persistency"});
}
@@ -143,6 +147,7 @@
factory.createFace(FaceUri("tcp4://192.0.2.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
bind(&FaceCreateTimeoutFixture::onFaceCreated, this, _1),
bind(&FaceCreateTimeoutFixture::onConnectFailed, this, _2));
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index eb27f3a..5e46d97 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -151,6 +151,7 @@
createFace(factory,
FaceUri("udp4://127.0.0.1:6363"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
factory.createChannel("127.0.0.1", "20071");
@@ -158,16 +159,19 @@
createFace(factory,
FaceUri("udp4://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
{CreateFaceExpectedResult::SUCCESS, 0, ""});
//test the upgrade
createFace(factory,
FaceUri("udp4://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
{CreateFaceExpectedResult::SUCCESS, 0, ""});
createFace(factory,
FaceUri("udp4://127.0.0.1:20072"),
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
{CreateFaceExpectedResult::SUCCESS, 0, ""});
}
@@ -180,6 +184,7 @@
createFace(factory,
FaceUri("udp4://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ false,
{CreateFaceExpectedResult::FAILURE, 406,
"Outgoing unicast UDP faces do not support on-demand persistency"});
}
diff --git a/tests/daemon/face/unix-stream-factory.t.cpp b/tests/daemon/face/unix-stream-factory.t.cpp
index 1c33122..832841f 100644
--- a/tests/daemon/face/unix-stream-factory.t.cpp
+++ b/tests/daemon/face/unix-stream-factory.t.cpp
@@ -80,16 +80,19 @@
createFace(factory,
FaceUri("unix:///var/run/nfd.sock"),
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("unix:///var/run/nfd.sock"),
ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("unix:///var/run/nfd.sock"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
}
diff --git a/tests/daemon/face/websocket-factory.t.cpp b/tests/daemon/face/websocket-factory.t.cpp
index cb00922..e7abef2 100644
--- a/tests/daemon/face/websocket-factory.t.cpp
+++ b/tests/daemon/face/websocket-factory.t.cpp
@@ -62,16 +62,19 @@
createFace(factory,
FaceUri("ws://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("ws://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
createFace(factory,
FaceUri("ws://127.0.0.1:20070"),
ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ false,
{CreateFaceExpectedResult::FAILURE, 406, "Unsupported protocol"});
}
diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp
index c691491..ed89388 100644
--- a/tests/daemon/mgmt/face-manager-create-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-create-face.t.cpp
@@ -120,6 +120,58 @@
}
};
+class LocalTcpFaceLocalFieldsEnabled
+{
+public:
+ ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true);
+ }
+};
+
+class LocalTcpFaceLocalFieldsDisabled
+{
+public:
+ ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, false);
+ }
+};
+
+class NonLocalUdpFaceLocalFieldsEnabled // won't work because non-local scope
+{
+public:
+ ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("udp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true);
+ }
+};
+
+class NonLocalUdpFaceLocalFieldsDisabled
+{
+public:
+ ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("udp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, false);
+ }
+};
+
namespace mpl = boost::mpl;
// pairs of CreateCommand and Success/Failure status
@@ -129,7 +181,11 @@
mpl::pair<UdpFaceOnDemand, CommandFailure<406>>,
mpl::pair<UdpFacePersistent, CommandSuccess>,
mpl::pair<UdpFacePermanent, CommandSuccess>,
- mpl::pair<UdpFaceConnectToSelf, CommandFailure<406>>> Faces;
+ mpl::pair<UdpFaceConnectToSelf, CommandFailure<406>>,
+ mpl::pair<LocalTcpFaceLocalFieldsEnabled, CommandSuccess>,
+ mpl::pair<LocalTcpFaceLocalFieldsDisabled, CommandSuccess>,
+ mpl::pair<NonLocalUdpFaceLocalFieldsEnabled, CommandFailure<406>>,
+ mpl::pair<NonLocalUdpFaceLocalFieldsDisabled, CommandSuccess>> Faces;
BOOST_FIXTURE_TEST_CASE_TEMPLATE(NewFace, T, Faces, FaceManagerCommandFixture)
{
@@ -162,10 +218,12 @@
if (actual.getCode() == 200) {
if (expectedParams.hasFlags()) {
- // TODO: #3731 check if Flags match
+ BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED),
+ actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED));
}
else {
- // TODO: #3731 check if Flags at defaults
+ // local fields are disabled by default
+ BOOST_CHECK_EQUAL(actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED), false);
}
}
else {
@@ -193,7 +251,7 @@
typedef mpl::vector<// mpl::pair<mpl::pair<TcpFacePersistent, TcpFacePermanent>, TcpFacePermanent>, // no need to check now
- // mpl::pair<mpl::pair<TcpFacePermanent, TcpFacePersistent>, TcpFacePermanent>, // no need to check now
+ // mpl::pair<mpl::pair<TcpFacePermanent, TcpFacePersistent>, TcpFacePersistent>, // no need to check now
mpl::pair<mpl::pair<UdpFacePersistent, UdpFacePermanent>, UdpFacePermanent>,
mpl::pair<mpl::pair<UdpFacePermanent, UdpFacePersistent>, UdpFacePermanent>> FaceTransitions;
@@ -235,6 +293,7 @@
ControlResponse actual(response.getContent().blockFromValue());
BOOST_REQUIRE_EQUAL(actual.getCode(), 200);
+ BOOST_TEST_MESSAGE(actual.getText());
ControlParameters expectedParams(FinalFaceType().getParameters());
ControlParameters actualParams(actual.getBody());
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index 3c34cb2..9b7c71a 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -335,6 +335,7 @@
virtual void
createFace(const FaceUri& uri,
ndn::nfd::FacePersistency persistency,
+ bool wantLocalFieldsEnabled,
const FaceCreatedCallback& onCreated,
const FaceCreationFailedCallback& onConnectFailed) override
{