face+mgmt: accept LocalUri in ProtocolFactory and FaceManager

refs #4016

Change-Id: I3e192e6d3982ae8e6ced1dbfbaa62f1c993f799e
diff --git a/tests/daemon/face/ethernet-factory.t.cpp b/tests/daemon/face/ethernet-factory.t.cpp
index 56373d0..b8b07d1 100644
--- a/tests/daemon/face/ethernet-factory.t.cpp
+++ b/tests/daemon/face/ethernet-factory.t.cpp
@@ -327,18 +327,21 @@
 
   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/face-system.t.cpp b/tests/daemon/face/face-system.t.cpp
index bae735b..8e69441 100644
--- a/tests/daemon/face/face-system.t.cpp
+++ b/tests/daemon/face/face-system.t.cpp
@@ -53,7 +53,8 @@
   }
 
   void
-  createFace(const FaceUri& uri,
+  createFace(const FaceUri& remoteUri,
+             const ndn::optional<FaceUri>& localUri,
              ndn::nfd::FacePersistency persistency,
              bool wantLocalFieldsEnabled,
              const FaceCreatedCallback& onCreated,
diff --git a/tests/daemon/face/factory-test-common.hpp b/tests/daemon/face/factory-test-common.hpp
index 8622d06..20ccaf3 100644
--- a/tests/daemon/face/factory-test-common.hpp
+++ b/tests/daemon/face/factory-test-common.hpp
@@ -43,12 +43,13 @@
 
 inline void
 createFace(ProtocolFactory& factory,
-           const FaceUri& uri,
+           const FaceUri& remoteUri,
+           const ndn::optional<FaceUri>& localUri,
            ndn::nfd::FacePersistency persistency,
            bool wantLocalFieldsEnabled,
            const CreateFaceExpectedResult& expected)
 {
-  factory.createFace(uri, persistency, wantLocalFieldsEnabled,
+  factory.createFace(remoteUri, localUri, persistency, wantLocalFieldsEnabled,
                      [expected] (const shared_ptr<Face>&) {
                        BOOST_CHECK_EQUAL(CreateFaceExpectedResult::SUCCESS, expected.result);
                      },
diff --git a/tests/daemon/face/tcp-factory.t.cpp b/tests/daemon/face/tcp-factory.t.cpp
index 9f5e7c1..31e8918 100644
--- a/tests/daemon/face/tcp-factory.t.cpp
+++ b/tests/daemon/face/tcp-factory.t.cpp
@@ -172,6 +172,7 @@
 
   createFace(factory,
              FaceUri("tcp4://127.0.0.1:6363"),
+             {},
              ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
              false,
              {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
@@ -179,7 +180,8 @@
   factory.createChannel("127.0.0.1", "20071");
 
   createFace(factory,
-             FaceUri("tcp4://127.0.0.1:20070"),
+             FaceUri("tcp4://127.0.0.1:6363"),
+             {},
              ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
              false,
              {CreateFaceExpectedResult::SUCCESS, 0, ""});
@@ -191,9 +193,11 @@
 
   factory.createChannel("127.0.0.1", "20070");
   factory.createChannel("127.0.0.1", "20071");
+  factory.createChannel("127.0.0.1", "20072");
 
   createFace(factory,
              FaceUri("tcp4://127.0.0.1:20070"),
+             {},
              ndn::nfd::FACE_PERSISTENCY_PERMANENT,
              false,
              {CreateFaceExpectedResult::FAILURE, 406,
@@ -201,10 +205,19 @@
 
   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"});
+
+  createFace(factory,
+             FaceUri("tcp4://127.0.0.1:20072"),
+             FaceUri("udp4://127.0.0.1:20073"),
+             ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+             false,
+             {CreateFaceExpectedResult::FAILURE, 406,
+               "Unicast TCP faces cannot be created with a LocalUri"});
 }
 
 class FaceCreateTimeoutFixture : public BaseFixture
@@ -240,6 +253,7 @@
   shared_ptr<TcpChannel> channel = factory.createChannel("0.0.0.0", "20070");
 
   factory.createFace(FaceUri("tcp4://192.0.2.1:20070"),
+                     {},
                      ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
                      false,
                      bind(&FaceCreateTimeoutFixture::onFaceCreated, this, _1),
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index 14a0aee..e658248 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -603,6 +603,7 @@
 
   createFace(factory,
              FaceUri("udp4://127.0.0.1:6363"),
+             {},
              ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
              false,
              {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
@@ -611,18 +612,21 @@
 
   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, ""});
@@ -633,13 +637,23 @@
   UdpFactory factory;
 
   factory.createChannel("127.0.0.1", "20070");
+  factory.createChannel("127.0.0.1", "20071");
 
   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"});
+
+  createFace(factory,
+             FaceUri("udp4://127.0.0.1:20071"),
+             FaceUri("udp4://127.0.0.1:20073"),
+             ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+             false,
+             {CreateFaceExpectedResult::FAILURE, 406,
+               "Unicast UDP faces cannot be created with a LocalUri"});
 }
 
 class FakeNetworkInterfaceFixture : public BaseFixture
diff --git a/tests/daemon/face/unix-stream-factory.t.cpp b/tests/daemon/face/unix-stream-factory.t.cpp
index b0d48c7..7cdd741 100644
--- a/tests/daemon/face/unix-stream-factory.t.cpp
+++ b/tests/daemon/face/unix-stream-factory.t.cpp
@@ -137,18 +137,21 @@
 
   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 78d2321..95fd7d8 100644
--- a/tests/daemon/face/websocket-factory.t.cpp
+++ b/tests/daemon/face/websocket-factory.t.cpp
@@ -199,18 +199,21 @@
 
   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"});