blob: 1b738410f8d2c52f948ee6f0d0a51c63257ab629 [file] [log] [blame]
Eric Newberry42602412016-08-27 09:33:18 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2016, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "face-manager-command-fixture.hpp"
27
28namespace nfd {
29namespace tests {
30
31FaceManagerCommandNode::FaceManagerCommandNode(ndn::KeyChain& keyChain, uint16_t port)
32 : face(getGlobalIoService(), keyChain, {true, true})
33 , dispatcher(face, keyChain, ndn::security::SigningInfo())
34 , authenticator(CommandAuthenticator::create())
35 , manager(faceTable, dispatcher, *authenticator)
36{
37 dispatcher.addTopPrefix("/localhost/nfd");
38
39 std::string config =
40 "face_system\n"
41 "{\n"
42 " tcp\n"
43 " {\n"
44 " port " + to_string(port) + "\n"
45 " }\n"
46 " udp\n"
47 " {\n"
48 " port " + to_string(port) + "\n"
49 " mcast no\n"
50 " }\n"
51 " ether\n"
52 " {\n"
53 " mcast no\n"
54 " }\n"
55 "}\n"
56 "authorizations\n"
57 "{\n"
58 " authorize\n"
59 " {\n"
60 " certfile any\n"
61 " privileges\n"
62 " {\n"
63 " faces\n"
64 " }\n"
65 " }\n"
66 "}\n"
67 "\n";
68
69 ConfigFile cf;
70 manager.setConfigFile(cf);
71 authenticator->setConfigFile(cf);
72 cf.parse(config, false, "dummy-config");
73}
74
75FaceManagerCommandNode::~FaceManagerCommandNode()
76{
77 // Explicitly closing faces is necessary. Otherwise, in a subsequent test case,
78 // incoming packets may be delivered to an old socket from a previous test case.
79 // This should be handled by the FaceTable destructor - see #2517
80 std::vector<std::reference_wrapper<Face>> facesToClose;
81 std::copy(faceTable.begin(), faceTable.end(), std::back_inserter(facesToClose));
82 for (Face& face : facesToClose) {
83 face.close();
84 }
85}
86
87FaceManagerCommandFixture::FaceManagerCommandFixture()
88 : node1(m_keyChain, 16363)
89 , node2(m_keyChain, 26363)
90{
91 advanceClocks(time::milliseconds(1), 5);
92}
93
94FaceManagerCommandFixture::~FaceManagerCommandFixture()
95{
96 advanceClocks(time::milliseconds(1), 5);
97}
98
99} // namespace tests
100} // namespace nfd