mgmt+face: move protocol-specific face creation checks into protocol factories
Also brought implementation of faces/create in line with design
refs #3731
Change-Id: I4f48079136b42c7fdbd4fdfba37116d2565f9dc1
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.cpp b/tests/daemon/mgmt/face-manager-command-fixture.cpp
new file mode 100644
index 0000000..1b73841
--- /dev/null
+++ b/tests/daemon/mgmt/face-manager-command-fixture.cpp
@@ -0,0 +1,100 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2016, Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology,
+ * The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "face-manager-command-fixture.hpp"
+
+namespace nfd {
+namespace tests {
+
+FaceManagerCommandNode::FaceManagerCommandNode(ndn::KeyChain& keyChain, uint16_t port)
+ : face(getGlobalIoService(), keyChain, {true, true})
+ , dispatcher(face, keyChain, ndn::security::SigningInfo())
+ , authenticator(CommandAuthenticator::create())
+ , manager(faceTable, dispatcher, *authenticator)
+{
+ dispatcher.addTopPrefix("/localhost/nfd");
+
+ std::string config =
+ "face_system\n"
+ "{\n"
+ " tcp\n"
+ " {\n"
+ " port " + to_string(port) + "\n"
+ " }\n"
+ " udp\n"
+ " {\n"
+ " port " + to_string(port) + "\n"
+ " mcast no\n"
+ " }\n"
+ " ether\n"
+ " {\n"
+ " mcast no\n"
+ " }\n"
+ "}\n"
+ "authorizations\n"
+ "{\n"
+ " authorize\n"
+ " {\n"
+ " certfile any\n"
+ " privileges\n"
+ " {\n"
+ " faces\n"
+ " }\n"
+ " }\n"
+ "}\n"
+ "\n";
+
+ ConfigFile cf;
+ manager.setConfigFile(cf);
+ authenticator->setConfigFile(cf);
+ cf.parse(config, false, "dummy-config");
+}
+
+FaceManagerCommandNode::~FaceManagerCommandNode()
+{
+ // Explicitly closing faces is necessary. Otherwise, in a subsequent test case,
+ // incoming packets may be delivered to an old socket from a previous test case.
+ // This should be handled by the FaceTable destructor - see #2517
+ std::vector<std::reference_wrapper<Face>> facesToClose;
+ std::copy(faceTable.begin(), faceTable.end(), std::back_inserter(facesToClose));
+ for (Face& face : facesToClose) {
+ face.close();
+ }
+}
+
+FaceManagerCommandFixture::FaceManagerCommandFixture()
+ : node1(m_keyChain, 16363)
+ , node2(m_keyChain, 26363)
+{
+ advanceClocks(time::milliseconds(1), 5);
+}
+
+FaceManagerCommandFixture::~FaceManagerCommandFixture()
+{
+ advanceClocks(time::milliseconds(1), 5);
+}
+
+} // namespace tests
+} // namespace nfd