blob: 989ff7b3923865b17b5cf5adfc09da8fa625e835 [file] [log] [blame]
Eric Newberry42602412016-08-27 09:33:18 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shiea47bde2017-01-26 17:49:16 +00003 * Copyright (c) 2014-2017, Regents of the University of California,
Eric Newberry42602412016-08-27 09:33:18 -07004 * 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())
Junxiao Shiea47bde2017-01-26 17:49:16 +000035 , faceSystem(faceTable)
36 , manager(faceSystem, dispatcher, *authenticator)
Eric Newberry42602412016-08-27 09:33:18 -070037{
38 dispatcher.addTopPrefix("/localhost/nfd");
39
40 std::string config =
41 "face_system\n"
42 "{\n"
43 " tcp\n"
44 " {\n"
45 " port " + to_string(port) + "\n"
46 " }\n"
47 " udp\n"
48 " {\n"
49 " port " + to_string(port) + "\n"
50 " mcast no\n"
51 " }\n"
52 " ether\n"
53 " {\n"
54 " mcast no\n"
55 " }\n"
56 "}\n"
57 "authorizations\n"
58 "{\n"
59 " authorize\n"
60 " {\n"
61 " certfile any\n"
62 " privileges\n"
63 " {\n"
64 " faces\n"
65 " }\n"
66 " }\n"
67 "}\n"
68 "\n";
69
70 ConfigFile cf;
71 manager.setConfigFile(cf);
72 authenticator->setConfigFile(cf);
73 cf.parse(config, false, "dummy-config");
74}
75
76FaceManagerCommandNode::~FaceManagerCommandNode()
77{
78 // Explicitly closing faces is necessary. Otherwise, in a subsequent test case,
79 // incoming packets may be delivered to an old socket from a previous test case.
80 // This should be handled by the FaceTable destructor - see #2517
81 std::vector<std::reference_wrapper<Face>> facesToClose;
82 std::copy(faceTable.begin(), faceTable.end(), std::back_inserter(facesToClose));
83 for (Face& face : facesToClose) {
84 face.close();
85 }
86}
87
88FaceManagerCommandFixture::FaceManagerCommandFixture()
89 : node1(m_keyChain, 16363)
90 , node2(m_keyChain, 26363)
91{
92 advanceClocks(time::milliseconds(1), 5);
93}
94
95FaceManagerCommandFixture::~FaceManagerCommandFixture()
96{
97 advanceClocks(time::milliseconds(1), 5);
98}
99
100} // namespace tests
101} // namespace nfd