blob: ede55c337215867bb1bf0aa933bd210683eae095 [file] [log] [blame]
Junxiao Shieef49a92018-11-10 12:19:36 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Davide Pesaventoe422f9e2022-06-03 01:30:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Junxiao Shieef49a92018-11-10 12:19:36 +00004 * 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/netdev-bound.hpp"
27#include "face-system-fixture.hpp"
28
29#include "tests/test-common.hpp"
30
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040031namespace nfd::tests {
32
33using namespace nfd::face;
Junxiao Shieef49a92018-11-10 12:19:36 +000034
35BOOST_AUTO_TEST_SUITE(Face)
36BOOST_FIXTURE_TEST_SUITE(TestNetdevBound, FaceSystemFixture)
37
38BOOST_AUTO_TEST_SUITE(ProcessConfig)
39
40BOOST_AUTO_TEST_CASE(Normal)
41{
42 faceSystem.m_factories["pf"] = make_unique<DummyProtocolFactory>(faceSystem.makePFCtorParams());
43 auto pf = static_cast<DummyProtocolFactory*>(faceSystem.getFactoryById("pf"));
44 pf->newProvidedSchemes.insert("udp4+dev");
45
46 const std::string CONFIG = R"CONFIG(
47 face_system
48 {
49 pf
50 {
51 }
52 netdev_bound
53 {
54 rule
55 {
56 remote udp4://192.0.2.1:6363
57 remote udp4://192.0.2.2:6363
58 whitelist
59 {
60 *
61 }
62 blacklist
63 {
64 ifname wlan0
65 }
66 }
67 rule
68 {
69 remote udp4://192.0.2.3:6363
70 remote udp4://192.0.2.4:6363
71 whitelist
72 {
73 ifname eth0
74 }
75 blacklist
76 {
77 }
78 }
79 rule
80 {
81 remote udp4://192.0.2.5:6363
82 }
83 }
84 }
85 )CONFIG";
86
87 parseConfig(CONFIG, true);
88 parseConfig(CONFIG, false);
89}
90
91BOOST_AUTO_TEST_CASE(NonCanonicalRemote)
92{
93 const std::string CONFIG = R"CONFIG(
94 face_system
95 {
96 netdev_bound
97 {
98 rule
99 {
100 remote udp://192.0.2.1
101 }
102 }
103 }
104 )CONFIG";
105
106 BOOST_CHECK_THROW(parseConfig(CONFIG, true), ConfigFile::Error);
107}
108
109BOOST_AUTO_TEST_SUITE_END() // ProcessConfig
110
111BOOST_AUTO_TEST_SUITE_END() // TestNetdevBound
112BOOST_AUTO_TEST_SUITE_END() // Face
113
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400114} // namespace nfd::tests