blob: 837326619caac436dec2ce634b37ba117ddda600 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento8de8a8b2022-05-12 01:26:43 -04002/*
Varun Patila2599da2023-07-12 16:37:15 -07003 * Copyright (c) 2014-2023, The University of Memphis,
Vince Lehmanc2e51f62015-01-20 15:03:11 -06004 * Regents of the University of California,
5 * Arizona Board of Regents.
akmhoque3d06e792014-05-27 16:23:20 -05006 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
Vince Lehman7c603292014-09-11 17:48:16 -050021
Nick Gordonff9a6272017-10-12 13:38:29 -050022#include "conf-file-processor.hpp"
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040023
24#include "tests/boost-test.hpp"
25#include "tests/io-key-chain-fixture.hpp"
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -050026
Nick Gordonff9a6272017-10-12 13:38:29 -050027#include <fstream>
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -050028#include <boost/algorithm/string.hpp>
Davide Pesavento8de8a8b2022-05-12 01:26:43 -040029
Muktadir R Chowdhuryc69da0a2015-12-18 13:24:38 -060030#include <ndn-cxx/util/dummy-client-face.hpp>
31
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050032namespace nlsr {
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050033namespace test {
34
dmcoomes9f936662017-03-02 10:33:09 -060035using std::shared_ptr;
Vince Lehman904c2412014-09-23 19:36:11 -050036
Vince Lehman7b616582014-10-17 16:25:39 -050037const std::string SECTION_GENERAL =
38 "general\n"
39 "{\n"
40 " network /ndn/\n"
41 " site /memphis.edu/\n"
42 " router /cs/pollux/\n"
43 " lsa-refresh-time 1800\n"
44 " lsa-interest-lifetime 3\n"
Alexander Afanasyev1cf1e102014-08-17 19:47:57 -070045 " router-dead-interval 86400\n"
Ashlesh Gawande32ec3fd2018-07-18 13:42:32 -050046 " sync-protocol psync\n"
Ashlesh Gawandef7da9c52018-02-06 17:36:46 -060047 " sync-interest-lifetime 10000\n"
dulalsaurab82a34c22019-02-04 17:31:21 +000048 " state-dir /tmp\n"
Vince Lehman7b616582014-10-17 16:25:39 -050049 "}\n\n";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050050
Varun Patila2599da2023-07-12 16:37:15 -070051const std::string SECTION_GENERAL_SVS =
52 "general\n"
53 "{\n"
54 " network /ndn/\n"
55 " site /memphis.edu/\n"
56 " router /cs/pollux/\n"
57 " sync-protocol svs\n"
58 "}\n\n";
59
Vince Lehman7b616582014-10-17 16:25:39 -050060const std::string SECTION_NEIGHBORS =
61 "neighbors\n"
62 "{\n"
63 " hello-retries 3\n"
64 " hello-timeout 1\n"
65 " hello-interval 60\n\n"
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -050066 " adj-lsa-build-interval 10\n"
Vince Lehman7b616582014-10-17 16:25:39 -050067 " neighbor\n"
68 " {\n"
69 " name /ndn/memphis.edu/cs/castor\n"
Ashlesh Gawande7e3f6d72019-01-25 13:13:43 -060070 " face-uri udp://10.0.0.1\n"
Vince Lehman7b616582014-10-17 16:25:39 -050071 " link-cost 20\n"
72 " }\n\n"
73 " neighbor\n"
74 " {\n"
75 " name /ndn/memphis.edu/cs/mira\n"
Ashlesh Gawande7e3f6d72019-01-25 13:13:43 -060076 " face-uri udp://10.0.0.2\n"
Vince Lehman7b616582014-10-17 16:25:39 -050077 " link-cost 30\n"
78 " }\n"
79 "}\n\n";
80
81const std::string SECTION_HYPERBOLIC_ON =
82 "hyperbolic\n"
83 "{\n"
84 " state on\n"
85 " radius 123.456\n"
86 " angle 1.45\n"
87 "}\n\n";
88
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -060089const std::string SECTION_HYPERBOLIC_ANGLES_ON =
90 "hyperbolic\n"
91 "{\n"
92 " state on\n"
93 " radius 123.456\n"
94 " angle 1.45,2.25\n"
95 "}\n\n";
96
Vince Lehman7b616582014-10-17 16:25:39 -050097const std::string SECTION_HYPERBOLIC_OFF =
98 "hyperbolic\n"
99 "{\n"
100 " state off\n"
101 " radius 123.456\n"
102 " angle 1.45\n"
103 "}\n\n";
104
105const std::string SECTION_FIB =
106 "fib\n"
107 "{\n"
108 " max-faces-per-prefix 3\n"
109 " routing-calc-interval 9\n"
110 "}\n\n";
111
112const std::string SECTION_ADVERTISING =
113 "advertising\n"
114 "{\n"
115 " prefix /ndn/edu/memphis/cs/netlab\n"
116 " prefix /ndn/edu/memphis/sports/basketball\n"
117 "}\n";
118
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600119// NEED TO TEST SECURITY SECTION SUCH AS LOADING CERTIFICATE
120
Vince Lehman7b616582014-10-17 16:25:39 -0500121const std::string CONFIG_LINK_STATE = SECTION_GENERAL + SECTION_NEIGHBORS +
122 SECTION_HYPERBOLIC_OFF + SECTION_FIB + SECTION_ADVERTISING;
123
124const std::string CONFIG_HYPERBOLIC = SECTION_GENERAL + SECTION_NEIGHBORS +
125 SECTION_HYPERBOLIC_ON + SECTION_FIB + SECTION_ADVERTISING;
126
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600127const std::string CONFIG_HYPERBOLIC_ANGLES = SECTION_GENERAL + SECTION_NEIGHBORS +
128 SECTION_HYPERBOLIC_ANGLES_ON + SECTION_FIB +
129 SECTION_ADVERTISING;
130
Varun Patila2599da2023-07-12 16:37:15 -0700131const std::string CONFIG_SVS = SECTION_GENERAL_SVS;
132
Davide Pesavento8de8a8b2022-05-12 01:26:43 -0400133class ConfFileProcessorFixture : public IoKeyChainFixture
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500134{
Vince Lehman7b616582014-10-17 16:25:39 -0500135public:
136 ConfFileProcessorFixture()
Davide Pesavento8de8a8b2022-05-12 01:26:43 -0400137 : face(m_io, m_keyChain)
Saurab Dulal427e0122019-11-28 11:58:02 -0600138 , conf(face, m_keyChain, "unit-test-nlsr.conf")
Vince Lehman7b616582014-10-17 16:25:39 -0500139 {
140 }
Vince Lehman904c2412014-09-23 19:36:11 -0500141
Davide Pesavento8de8a8b2022-05-12 01:26:43 -0400142 ~ConfFileProcessorFixture() override
Vince Lehman7b616582014-10-17 16:25:39 -0500143 {
144 remove("unit-test-nlsr.conf");
145 }
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500146
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -0500147 bool
148 processConfigurationString(std::string confString)
Vince Lehman7b616582014-10-17 16:25:39 -0500149 {
150 std::ofstream config;
151 config.open("unit-test-nlsr.conf");
152 config << confString;
153 config.close();
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500154
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600155 ConfFileProcessor processor(conf);
Vince Lehman7b616582014-10-17 16:25:39 -0500156 return processor.processConfFile();
157 }
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500158
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -0500159 void
alvya2228c62014-12-09 10:25:11 -0600160 commentOut(const std::string& key, std::string& config)
161 {
162 boost::replace_all(config, key, ";" + key);
163 }
164
Vince Lehman7b616582014-10-17 16:25:39 -0500165public:
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -0500166 ndn::util::DummyClientFace face;
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600167 ConfParameter conf;
Vince Lehman7b616582014-10-17 16:25:39 -0500168};
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500169
Vince Lehman7b616582014-10-17 16:25:39 -0500170BOOST_FIXTURE_TEST_SUITE(TestConfFileProcessor, ConfFileProcessorFixture)
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500171
Vince Lehman7b616582014-10-17 16:25:39 -0500172BOOST_AUTO_TEST_CASE(LinkState)
173{
174 processConfigurationString(CONFIG_LINK_STATE);
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -0500175 conf.buildRouterAndSyncUserPrefix();
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500176
Vince Lehman7b616582014-10-17 16:25:39 -0500177 // General
178 BOOST_CHECK_EQUAL(conf.getNetwork(), "/ndn/");
179 BOOST_CHECK_EQUAL(conf.getSiteName(), "/memphis.edu/");
180 BOOST_CHECK_EQUAL(conf.getRouterName(), "/cs/pollux/");
181 BOOST_CHECK_EQUAL(conf.getRouterPrefix(), "/ndn/memphis.edu/cs/pollux/");
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600182 BOOST_CHECK_EQUAL(conf.getSyncPrefix(), ndn::Name("/localhop/ndn/nlsr/sync").appendVersion(ConfParameter::SYNC_VERSION));
Ashlesh Gawandecba0ae22018-03-27 17:57:56 -0500183 BOOST_CHECK_EQUAL(conf.getLsaPrefix(), "/localhop/ndn/nlsr/LSA");
Vince Lehman7b616582014-10-17 16:25:39 -0500184 BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), 1800);
Davide Pesavento1954a0c2022-09-30 15:56:04 -0400185 BOOST_CHECK(conf.getSyncProtocol() == SyncProtocol::PSYNC);
Vince Lehman7b616582014-10-17 16:25:39 -0500186 BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(), ndn::time::seconds(3));
Alexander Afanasyev1cf1e102014-08-17 19:47:57 -0700187 BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), 86400);
Ashlesh Gawandef7da9c52018-02-06 17:36:46 -0600188 BOOST_CHECK_EQUAL(conf.getSyncInterestLifetime(), ndn::time::milliseconds(10000));
dulalsaurab82a34c22019-02-04 17:31:21 +0000189 BOOST_CHECK_EQUAL(conf.getStateFileDir(), "/tmp");
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700190
Vince Lehman7b616582014-10-17 16:25:39 -0500191 // Neighbors
192 BOOST_CHECK_EQUAL(conf.getInterestRetryNumber(), 3);
193 BOOST_CHECK_EQUAL(conf.getInterestResendTime(), 1);
194 BOOST_CHECK_EQUAL(conf.getInfoInterestInterval(), 60);
195
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -0500196 BOOST_CHECK_EQUAL(conf.getAdjLsaBuildInterval(), 10);
Vince Lehman7b616582014-10-17 16:25:39 -0500197
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600198 BOOST_CHECK(conf.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira"));
199 BOOST_CHECK(conf.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/castor"));
200 BOOST_CHECK(!conf.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/fail"));
Vince Lehman7b616582014-10-17 16:25:39 -0500201
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600202 Adjacent mira = conf.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira");
Vince Lehman7b616582014-10-17 16:25:39 -0500203 BOOST_CHECK_EQUAL(mira.getName(), "/ndn/memphis.edu/cs/mira");
204 BOOST_CHECK_EQUAL(mira.getLinkCost(), 30);
Ashlesh Gawande7e3f6d72019-01-25 13:13:43 -0600205 BOOST_CHECK_EQUAL(mira.getFaceUri().toString(), "udp4://10.0.0.2:6363");
Vince Lehman7b616582014-10-17 16:25:39 -0500206
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600207 Adjacent castor = conf.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/castor");
Vince Lehman7b616582014-10-17 16:25:39 -0500208 BOOST_CHECK_EQUAL(castor.getName(), "/ndn/memphis.edu/cs/castor");
209 BOOST_CHECK_EQUAL(castor.getLinkCost(), 20);
Ashlesh Gawande7e3f6d72019-01-25 13:13:43 -0600210 BOOST_CHECK_EQUAL(castor.getFaceUri().toString(), "udp4://10.0.0.1:6363");
Vince Lehman7b616582014-10-17 16:25:39 -0500211
212 // Hyperbolic
213 BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 0);
214
215 // FIB
216 BOOST_CHECK_EQUAL(conf.getMaxFacesPerPrefix(), 3);
217 BOOST_CHECK_EQUAL(conf.getRoutingCalcInterval(), 9);
218
219 // Advertising
Ashlesh Gawande85998a12017-12-07 22:22:13 -0600220 BOOST_CHECK_EQUAL(conf.getNamePrefixList().size(), 2);
Vince Lehman7b616582014-10-17 16:25:39 -0500221}
222
Varun Patila2599da2023-07-12 16:37:15 -0700223BOOST_AUTO_TEST_CASE(SVSPrefix)
224{
225 processConfigurationString(CONFIG_SVS);
226 conf.buildRouterAndSyncUserPrefix();
227
228 // SVS does not use localhop
229 BOOST_CHECK_EQUAL(conf.getNetwork(), "/ndn/");
230 BOOST_CHECK_EQUAL(conf.getSyncPrefix(), ndn::Name("/ndn/nlsr/sync").appendVersion(ConfParameter::SYNC_VERSION));
231}
232
alvy2fe12872014-11-25 10:32:23 -0600233BOOST_AUTO_TEST_CASE(MalformedUri)
234{
235 const std::string MALFORMED_URI =
236 "neighbors\n"
237 "{\n"
238 " hello-retries 3\n"
239 " hello-timeout 1\n"
240 " hello-interval 60\n\n"
Ashlesh Gawande6b388fc2019-09-30 10:14:41 -0500241 " adj-lsa-build-interval 10\n"
alvy2fe12872014-11-25 10:32:23 -0600242 " neighbor\n"
243 " {\n"
244 " name /ndn/memphis.edu/cs/castor\n"
245 " face-uri udp4:malformed-uri\n"
246 " link-cost 20\n"
247 " }\n"
248 "}\n\n";
249
250 BOOST_CHECK_EQUAL(processConfigurationString(MALFORMED_URI), false);
251}
252
Vince Lehman7b616582014-10-17 16:25:39 -0500253BOOST_AUTO_TEST_CASE(Hyperbolic)
254{
255 processConfigurationString(CONFIG_HYPERBOLIC);
256
Vince Lehman7b616582014-10-17 16:25:39 -0500257 BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
258 BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600259 std::vector<double> angles;
260 angles.push_back(1.45);
261 BOOST_CHECK(conf.getCorTheta() == angles);
262}
263
264BOOST_AUTO_TEST_CASE(Hyperbolic2)
265{
266 processConfigurationString(CONFIG_HYPERBOLIC_ANGLES);
267
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600268 BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
269 BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
270 std::vector<double> angles;
271 angles.push_back(1.45);
272 angles.push_back(2.25);
273 BOOST_CHECK(conf.getCorTheta() == angles);
Vince Lehman7b616582014-10-17 16:25:39 -0500274}
275
alvya2228c62014-12-09 10:25:11 -0600276BOOST_AUTO_TEST_CASE(DefaultValuesGeneral)
Vince Lehman7b616582014-10-17 16:25:39 -0500277{
alvya2228c62014-12-09 10:25:11 -0600278 std::string config = SECTION_GENERAL;
Vince Lehman7b616582014-10-17 16:25:39 -0500279
alvya2228c62014-12-09 10:25:11 -0600280 commentOut("lsa-refresh-time", config);
281 commentOut("lsa-interest-lifetime", config);
282 commentOut("router-dead-interval", config);
283
Ashlesh Gawande328fc112019-12-12 17:06:44 -0600284 BOOST_CHECK(processConfigurationString(config));
Vince Lehman7b616582014-10-17 16:25:39 -0500285
alvy5a454952014-12-15 12:49:54 -0600286 BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), static_cast<uint32_t>(LSA_REFRESH_TIME_DEFAULT));
alvya2228c62014-12-09 10:25:11 -0600287 BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(),
288 static_cast<ndn::time::seconds>(LSA_INTEREST_LIFETIME_DEFAULT));
Ashlesh Gawande328fc112019-12-12 17:06:44 -0600289 BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), (2 * conf.getLsaRefreshTime()));
290
291 BOOST_CHECK(conf.m_confFileName != conf.getConfFileNameDynamic());
292 conf.m_confFileName = "/tmp/nlsr.conf";
293 BOOST_CHECK(conf.m_confFileName == conf.getConfFileNameDynamic());
294 BOOST_CHECK(!processConfigurationString(config));
alvya2228c62014-12-09 10:25:11 -0600295}
296
297BOOST_AUTO_TEST_CASE(DefaultValuesNeighbors)
298{
299 std::string config = SECTION_NEIGHBORS;
300
301 commentOut("hello-retries", config);
302 commentOut("hello-timeout", config);
303 commentOut("hello-interval", config);
304 commentOut("first-hello-interval", config);
305 commentOut("adj-lsa-build-interval", config);
306
307 BOOST_CHECK_EQUAL(processConfigurationString(config), true);
308
alvya2228c62014-12-09 10:25:11 -0600309 BOOST_CHECK_EQUAL(conf.getInterestRetryNumber(), static_cast<uint32_t>(HELLO_RETRIES_DEFAULT));
alvy5a454952014-12-15 12:49:54 -0600310 BOOST_CHECK_EQUAL(conf.getInterestResendTime(), static_cast<uint32_t>(HELLO_TIMEOUT_DEFAULT));
311 BOOST_CHECK_EQUAL(conf.getInfoInterestInterval(), static_cast<uint32_t>(HELLO_INTERVAL_DEFAULT));
Vince Lehman7b616582014-10-17 16:25:39 -0500312 BOOST_CHECK_EQUAL(conf.getAdjLsaBuildInterval(),
313 static_cast<uint32_t>(ADJ_LSA_BUILD_INTERVAL_DEFAULT));
alvya2228c62014-12-09 10:25:11 -0600314}
Vince Lehman7b616582014-10-17 16:25:39 -0500315
Ashlesh Gawande9ecbdc92019-03-11 13:18:45 -0700316BOOST_AUTO_TEST_CASE(CanonizeNeighbors)
317{
318 std::string config = std::string(R"INFO(neighbors
319 {
320 neighbor
321 {
322 name /ndn/edu/arizona/%C1.Router/hobo
323 face-uri udp4://hobo.cs.arizona.edu
324 link-cost 20
325 }
326 neighbor
327 {
328 name /ndn/edu/umich/%C1.Router/ndn0
329 face-uri udp4://michigan.testbed.named-data.net
330 link-cost 30
331 }
332 })INFO");
333
334 BOOST_CHECK_EQUAL(processConfigurationString(config), true);
335
336 BOOST_CHECK_EQUAL(conf.m_adjl.getAdjacent("/ndn/edu/arizona/%C1.Router/hobo").getFaceUri().toString(),
337 "udp4://128.196.203.36:6363");
338 BOOST_CHECK_EQUAL(conf.m_adjl.getAdjacent("/ndn/edu/umich/%C1.Router/ndn0").getFaceUri().toString(),
339 "udp4://198.111.224.197:6363");
340}
341
alvya2228c62014-12-09 10:25:11 -0600342BOOST_AUTO_TEST_CASE(DefaultValuesFib)
343{
344 std::string config = SECTION_FIB;
345
346 commentOut("max-faces-per-prefix", config);
347 commentOut("routing-calc-interval", config);
348
349 BOOST_CHECK_EQUAL(processConfigurationString(config), true);
350
alvya2228c62014-12-09 10:25:11 -0600351 BOOST_CHECK_EQUAL(conf.getMaxFacesPerPrefix(),
352 static_cast<uint32_t>(MAX_FACES_PER_PREFIX_DEFAULT));
353 BOOST_CHECK_EQUAL(conf.getRoutingCalcInterval(),
354 static_cast<uint32_t>(ROUTING_CALC_INTERVAL_DEFAULT));
355}
356
357BOOST_AUTO_TEST_CASE(DefaultValuesHyperbolic)
358{
359 std::string config = SECTION_HYPERBOLIC_ON;
360
361 commentOut("state", config);
362
363 BOOST_CHECK_EQUAL(processConfigurationString(config), true);
364
alvya2228c62014-12-09 10:25:11 -0600365 BOOST_CHECK_EQUAL(conf.getHyperbolicState(), static_cast<int32_t>(HYPERBOLIC_STATE_DEFAULT));
Vince Lehman7b616582014-10-17 16:25:39 -0500366}
367
368BOOST_AUTO_TEST_CASE(OutOfRangeValue)
369{
370 const std::string SECTION_FIB_OUT_OF_RANGE =
371 "fib\n"
372 "{\n"
373 " max-faces-per-prefix 3\n"
374 " routing-calc-interval 999\n" // Larger than max value
375 "}\n\n";
376
377 // Processing should fail due to out of range value
378 BOOST_CHECK_EQUAL(processConfigurationString(SECTION_FIB_OUT_OF_RANGE), false);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500379}
380
alvy5a454952014-12-15 12:49:54 -0600381BOOST_AUTO_TEST_CASE(NegativeValue)
382{
383 const std::string SECTION_GENERAL_NEGATIVE_VALUE =
384 "general\n"
385 "{\n"
386 " network /ndn/\n"
387 " site /memphis.edu/\n"
388 " router /cs/pollux/\n"
389 " lsa-refresh-time -1800\n"
390 " lsa-interest-lifetime -3\n"
391 " router-dead-interval -86400\n"
392 "}\n\n";
393
394 // Processing should fail due to negative value
395 BOOST_CHECK_EQUAL(processConfigurationString(SECTION_GENERAL_NEGATIVE_VALUE), false);
396}
397
Vince Lehmanc2acdcb2015-04-29 11:14:35 -0500398BOOST_AUTO_TEST_CASE(LoadCertToPublish)
399{
Davide Pesavento8de8a8b2022-05-12 01:26:43 -0400400 auto identity = m_keyChain.createIdentity("/TestNLSR/identity");
401 saveIdentityCert(identity, "cert-to-publish.cert");
Vince Lehmanc2acdcb2015-04-29 11:14:35 -0500402
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -0500403 const std::string SECTION_SECURITY = R"CONF(
404 security
405 {
406 validator
407 {
408 trust-anchor
409 {
410 type any
411 }
412 }
413 prefix-update-validator
414 {
415 trust-anchor
416 {
417 type any
418 }
419 }
420 cert-to-publish "cert-to-publish.cert"
421 }
422 )CONF";
Vince Lehmanc2acdcb2015-04-29 11:14:35 -0500423
424 BOOST_CHECK(processConfigurationString(SECTION_SECURITY));
425
Vince Lehmanc2acdcb2015-04-29 11:14:35 -0500426}
427
Vince Lehmand33e5bc2015-06-22 15:27:50 -0500428BOOST_AUTO_TEST_CASE(PrefixUpdateValidatorOptional) // Bug #2814
429{
Muktadir Chowdhuryf04f9892017-08-20 20:42:56 -0500430 const std::string SECTION_SECURITY = R"CONF(
431 security
432 {
433 validator
434 {
435 trust-anchor
436 {
437 type any
438 }
439 }
440 }
441 )CONF";
Vince Lehmand33e5bc2015-06-22 15:27:50 -0500442
443 BOOST_CHECK(processConfigurationString(SECTION_SECURITY));
444}
445
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -0500446BOOST_AUTO_TEST_SUITE_END()
447
Nick Gordonfad8e252016-08-11 14:21:38 -0500448} // namespace test
449} // namespace nlsr