blob: 0cc36423ad3e130b5553f05701eebcd703bf8f81 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi22f85682018-01-22 19:23:22 +00002/*
3 * Copyright (c) 2013-2018 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Junxiao Shi5ec80222014-03-25 20:08:05 -070020 */
21
Junxiao Shi7357ef22016-09-07 02:39:37 +000022#include "mgmt/nfd/control-command.hpp"
Junxiao Shi5ec80222014-03-25 20:08:05 -070023
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070024#include "boost-test.hpp"
Junxiao Shi5ec80222014-03-25 20:08:05 -070025
26namespace ndn {
27namespace nfd {
Spyridon Mastorakis429634f2015-02-19 17:35:33 -080028namespace tests {
Junxiao Shi5ec80222014-03-25 20:08:05 -070029
Junxiao Shi7357ef22016-09-07 02:39:37 +000030BOOST_AUTO_TEST_SUITE(Mgmt)
31BOOST_AUTO_TEST_SUITE(Nfd)
32BOOST_AUTO_TEST_SUITE(TestControlCommand)
Junxiao Shi5ec80222014-03-25 20:08:05 -070033
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000034BOOST_AUTO_TEST_CASE(FaceCreateRequest)
Junxiao Shi5ec80222014-03-25 20:08:05 -070035{
36 FaceCreateCommand command;
Junxiao Shi5ec80222014-03-25 20:08:05 -070037
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000038 // good with required fields only
Junxiao Shi5ec80222014-03-25 20:08:05 -070039 ControlParameters p1;
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000040 p1.setUri("tcp4://192.0.2.1:6363");
41 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
42 BOOST_CHECK(Name("/PREFIX/faces/create").isPrefixOf(command.getRequestName("/PREFIX", p1)));
Junxiao Shi5ec80222014-03-25 20:08:05 -070043
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000044 // good with optional fields
45 ControlParameters p2(p1);
46 p2.setLocalUri("tcp4://192.0.2.2:32114")
47 .setFacePersistency(FACE_PERSISTENCY_PERMANENT)
Eric Newberry07d05c92018-01-22 16:08:01 -070048 .setBaseCongestionMarkingInterval(100_ms)
49 .setDefaultCongestionThreshold(10000)
Eric Newberryda916d62016-08-11 23:04:34 -070050 .setFlags(0x3)
51 .setMask(0x1);
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000052 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
Yukai Tud93c5fc2015-08-25 11:37:16 +080053
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000054 // Uri is required
55 ControlParameters p3;
56 BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError);
57
58 // Name is forbidden
59 ControlParameters p4(p1);
60 p4.setName("/example");
61 BOOST_CHECK_THROW(command.validateRequest(p4), ControlCommand::ArgumentError);
62
63 // Flags and Mask must be specified together
64 ControlParameters p5(p1);
65 p5.setFlags(0x3);
66 BOOST_CHECK_THROW(command.validateRequest(p5), ControlCommand::ArgumentError);
67
68 ControlParameters p6(p1);
69 p6.setMask(0x1);
70 BOOST_CHECK_THROW(command.validateRequest(p6), ControlCommand::ArgumentError);
71}
72
73BOOST_AUTO_TEST_CASE(FaceCreateResponse)
74{
75 FaceCreateCommand command;
76
77 // good
78 ControlParameters p1;
79 p1.setFaceId(3208)
Junxiao Shi144c7e32017-04-20 01:04:06 +000080 .setUri("tcp4://192.0.2.1:6363")
81 .setLocalUri("tcp4://192.0.2.2:32114")
82 .setFacePersistency(FACE_PERSISTENCY_PERMANENT)
Eric Newberry07d05c92018-01-22 16:08:01 -070083 .setBaseCongestionMarkingInterval(500_ns)
84 .setDefaultCongestionThreshold(12345)
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000085 .setFlags(0x3);
86 BOOST_CHECK_NO_THROW(command.validateResponse(p1));
Eric Newberryda916d62016-08-11 23:04:34 -070087
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000088 // Name is forbidden
89 ControlParameters p2(p1);
90 p2.setName("/example");
91 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
Yukai Tud93c5fc2015-08-25 11:37:16 +080092
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000093 // Mask is forbidden
94 ControlParameters p3(p1);
95 p3.setMask(0x1);
96 BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError);
Eric Newberryda916d62016-08-11 23:04:34 -070097
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +000098 // FaceId must be valid
99 ControlParameters p4(p1);
100 p4.setFaceId(INVALID_FACE_ID);
101 BOOST_CHECK_THROW(command.validateResponse(p4), ControlCommand::ArgumentError);
Eric Newberryda916d62016-08-11 23:04:34 -0700102
Junxiao Shi8c2ab2e2017-05-05 20:26:34 +0000103 // LocalUri is required
104 ControlParameters p5(p1);
105 p5.unsetLocalUri();
106 BOOST_CHECK_THROW(command.validateResponse(p5), ControlCommand::ArgumentError);
Junxiao Shi5ec80222014-03-25 20:08:05 -0700107}
108
Yanbiao Licbdacb22016-08-02 16:02:35 +0800109BOOST_AUTO_TEST_CASE(FaceUpdate)
110{
111 FaceUpdateCommand command;
112
113 ControlParameters p1;
114 p1.setFaceId(0);
Eric Newberryda916d62016-08-11 23:04:34 -0700115 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
Davide Pesaventof8503d22017-02-17 01:19:10 -0500116 p1.setFaceId(INVALID_FACE_ID);
Eric Newberry138ef2c2016-08-15 20:29:03 -0700117 BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
Yanbiao Licbdacb22016-08-02 16:02:35 +0800118
119 p1.setFaceId(1);
120 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
Eric Newberry138ef2c2016-08-15 20:29:03 -0700121 BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
122 command.applyDefaultsToRequest(p1);
123 BOOST_CHECK_EQUAL(p1.getFaceId(), 1);
Yanbiao Licbdacb22016-08-02 16:02:35 +0800124
125 ControlParameters p2;
126 p2.setFaceId(1)
Eric Newberry138ef2c2016-08-15 20:29:03 -0700127 .setFacePersistency(FACE_PERSISTENCY_PERSISTENT)
Eric Newberry07d05c92018-01-22 16:08:01 -0700128 .setBaseCongestionMarkingInterval(765_ns)
129 .setDefaultCongestionThreshold(54321)
Eric Newberry138ef2c2016-08-15 20:29:03 -0700130 .setFlagBit(BIT_LOCAL_FIELDS_ENABLED, false);
Yanbiao Licbdacb22016-08-02 16:02:35 +0800131 BOOST_CHECK_NO_THROW(command.validateRequest(p2));
Eric Newberry138ef2c2016-08-15 20:29:03 -0700132 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError); // Mask forbidden but present
Yanbiao Licbdacb22016-08-02 16:02:35 +0800133
Eric Newberry138ef2c2016-08-15 20:29:03 -0700134 // Flags without Mask
Eric Newberryda916d62016-08-11 23:04:34 -0700135 p2.unsetMask();
136 BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError);
Eric Newberry138ef2c2016-08-15 20:29:03 -0700137 BOOST_CHECK_NO_THROW(command.validateResponse(p2));
138
139 p2.setFlagBit(BIT_LOCAL_FIELDS_ENABLED, false);
140 p2.unsetFaceId();
141 BOOST_CHECK_NO_THROW(command.validateRequest(p2));
Eric Newberryda916d62016-08-11 23:04:34 -0700142
Yanbiao Licbdacb22016-08-02 16:02:35 +0800143 ControlParameters p3;
Eric Newberryda916d62016-08-11 23:04:34 -0700144 p3.setFaceId(1)
145 .setName("/ndn/name");
Yanbiao Licbdacb22016-08-02 16:02:35 +0800146 BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError);
147 BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError);
148
149 ControlParameters p4;
150 p4.setFaceId(1)
Eric Newberryda916d62016-08-11 23:04:34 -0700151 .setUri("tcp4://192.0.2.1");
Yanbiao Licbdacb22016-08-02 16:02:35 +0800152 BOOST_CHECK_THROW(command.validateRequest(p4), ControlCommand::ArgumentError);
153 BOOST_CHECK_THROW(command.validateResponse(p4), ControlCommand::ArgumentError);
154
155 ControlParameters p5;
Eric Newberry138ef2c2016-08-15 20:29:03 -0700156 BOOST_CHECK_NO_THROW(command.validateRequest(p5));
157 BOOST_CHECK_THROW(command.validateResponse(p5), ControlCommand::ArgumentError);
158 BOOST_CHECK(!p5.hasFaceId());
159 command.applyDefaultsToRequest(p5);
160 BOOST_REQUIRE(p5.hasFaceId());
161 BOOST_CHECK_NO_THROW(command.validateRequest(p5));
162 BOOST_CHECK_THROW(command.validateResponse(p5), ControlCommand::ArgumentError);
163 BOOST_CHECK_EQUAL(p5.getFaceId(), 0);
Yanbiao Licbdacb22016-08-02 16:02:35 +0800164}
165
Junxiao Shi5ec80222014-03-25 20:08:05 -0700166BOOST_AUTO_TEST_CASE(FaceDestroy)
167{
168 FaceDestroyCommand command;
Junxiao Shi5ec80222014-03-25 20:08:05 -0700169
170 ControlParameters p1;
171 p1.setUri("tcp4://192.0.2.1")
172 .setFaceId(4);
173 BOOST_CHECK_THROW(command.validateRequest(p1), ControlCommand::ArgumentError);
174 BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
175
176 ControlParameters p2;
Davide Pesaventof8503d22017-02-17 01:19:10 -0500177 p2.setFaceId(INVALID_FACE_ID);
Junxiao Shi5ec80222014-03-25 20:08:05 -0700178 BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError);
179 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
180
181 ControlParameters p3;
182 p3.setFaceId(6);
183 BOOST_CHECK_NO_THROW(command.validateRequest(p3));
184 BOOST_CHECK_NO_THROW(command.validateResponse(p3));
Junxiao Shi5de006b2014-10-26 20:20:52 -0700185 Name n3;
186 BOOST_CHECK_NO_THROW(n3 = command.getRequestName("/PREFIX", p3));
187 BOOST_CHECK(Name("ndn:/PREFIX/faces/destroy").isPrefixOf(n3));
Junxiao Shi5ec80222014-03-25 20:08:05 -0700188}
189
Junxiao Shi5ec80222014-03-25 20:08:05 -0700190BOOST_AUTO_TEST_CASE(FibAddNextHop)
191{
192 FibAddNextHopCommand command;
Junxiao Shi5ec80222014-03-25 20:08:05 -0700193
194 ControlParameters p1;
195 p1.setName("ndn:/")
196 .setFaceId(22);
197 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
198 BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
Junxiao Shi5de006b2014-10-26 20:20:52 -0700199 Name n1;
200 BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1));
201 BOOST_CHECK(Name("ndn:/PREFIX/fib/add-nexthop").isPrefixOf(n1));
Junxiao Shi5ec80222014-03-25 20:08:05 -0700202
203 ControlParameters p2;
204 p2.setName("ndn:/example")
205 .setFaceId(0)
206 .setCost(6);
207 BOOST_CHECK_NO_THROW(command.validateRequest(p2));
Davide Pesaventof8503d22017-02-17 01:19:10 -0500208 p2.setFaceId(INVALID_FACE_ID);
Junxiao Shi5ec80222014-03-25 20:08:05 -0700209 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
210
211 command.applyDefaultsToRequest(p1);
212 BOOST_REQUIRE(p1.hasCost());
213 BOOST_CHECK_EQUAL(p1.getCost(), 0);
Junxiao Shicaac54e2014-05-20 15:27:01 -0700214
215 p1.unsetFaceId();
216 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
217 command.applyDefaultsToRequest(p1);
218 BOOST_REQUIRE(p1.hasFaceId());
219 BOOST_CHECK_EQUAL(p1.getFaceId(), 0);
Junxiao Shi5ec80222014-03-25 20:08:05 -0700220}
221
222BOOST_AUTO_TEST_CASE(FibRemoveNextHop)
223{
224 FibRemoveNextHopCommand command;
Junxiao Shi5ec80222014-03-25 20:08:05 -0700225
226 ControlParameters p1;
227 p1.setName("ndn:/")
228 .setFaceId(22);
229 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
230 BOOST_CHECK_NO_THROW(command.validateResponse(p1));
Junxiao Shi5de006b2014-10-26 20:20:52 -0700231 Name n1;
232 BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1));
233 BOOST_CHECK(Name("ndn:/PREFIX/fib/remove-nexthop").isPrefixOf(n1));
Junxiao Shi5ec80222014-03-25 20:08:05 -0700234
235 ControlParameters p2;
236 p2.setName("ndn:/example")
237 .setFaceId(0);
238 BOOST_CHECK_NO_THROW(command.validateRequest(p2));
Davide Pesaventof8503d22017-02-17 01:19:10 -0500239 p2.setFaceId(INVALID_FACE_ID);
Junxiao Shi5ec80222014-03-25 20:08:05 -0700240 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
Junxiao Shicaac54e2014-05-20 15:27:01 -0700241
242 p1.unsetFaceId();
243 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
244 command.applyDefaultsToRequest(p1);
245 BOOST_REQUIRE(p1.hasFaceId());
246 BOOST_CHECK_EQUAL(p1.getFaceId(), 0);
Junxiao Shi5ec80222014-03-25 20:08:05 -0700247}
248
Junxiao Shi22f85682018-01-22 19:23:22 +0000249BOOST_AUTO_TEST_CASE(CsConfigRequest)
250{
251 CsConfigCommand command;
252
253 // good empty request
254 ControlParameters p1;
255 command.validateRequest(p1);
256 BOOST_CHECK(Name("/PREFIX/cs/config").isPrefixOf(command.getRequestName("/PREFIX", p1)));
257
258 // good full request
259 ControlParameters p2;
260 p2.setCapacity(1574);
261 p2.setFlagBit(BIT_CS_ENABLE_ADMIT, true);
262 p2.setFlagBit(BIT_CS_ENABLE_SERVE, true);
263 command.validateRequest(p2);
264
265 // bad request: Flags but no Mask
266 ControlParameters p3(p2);
267 p3.unsetMask();
268 BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError);
269
270 // bad request: Mask but no Flags
271 ControlParameters p4(p2);
272 p4.unsetFlags();
273 BOOST_CHECK_THROW(command.validateRequest(p4), ControlCommand::ArgumentError);
274
275 // bad request: forbidden field
276 ControlParameters p5(p2);
277 p5.setName("/example");
278 BOOST_CHECK_THROW(command.validateRequest(p5), ControlCommand::ArgumentError);
279}
280
281BOOST_AUTO_TEST_CASE(CsConfigResponse)
282{
283 CsConfigCommand command;
284
285 // bad empty response
286 ControlParameters p1;
287 BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
288
289 // bad response: Mask not allowed
290 ControlParameters p2;
291 p2.setCapacity(1574);
292 p2.setFlagBit(BIT_CS_ENABLE_ADMIT, true);
293 p2.setFlagBit(BIT_CS_ENABLE_SERVE, true);
294 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
295
296 // good response
297 ControlParameters p3(p2);
298 p3.unsetMask();
299 command.validateResponse(p3);
300}
301
Junxiao Shi5ec80222014-03-25 20:08:05 -0700302BOOST_AUTO_TEST_CASE(StrategyChoiceSet)
303{
304 StrategyChoiceSetCommand command;
Junxiao Shi5ec80222014-03-25 20:08:05 -0700305
306 ControlParameters p1;
307 p1.setName("ndn:/")
308 .setStrategy("ndn:/strategy/P");
309 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
310 BOOST_CHECK_NO_THROW(command.validateResponse(p1));
Junxiao Shi5de006b2014-10-26 20:20:52 -0700311 Name n1;
312 BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1));
313 BOOST_CHECK(Name("ndn:/PREFIX/strategy-choice/set").isPrefixOf(n1));
Junxiao Shi5ec80222014-03-25 20:08:05 -0700314
315 ControlParameters p2;
316 p2.setName("ndn:/example");
317 BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError);
318 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
319}
320
321BOOST_AUTO_TEST_CASE(StrategyChoiceUnset)
322{
323 StrategyChoiceUnsetCommand command;
Junxiao Shi5ec80222014-03-25 20:08:05 -0700324
325 ControlParameters p1;
326 p1.setName("ndn:/example");
327 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
328 BOOST_CHECK_NO_THROW(command.validateResponse(p1));
Junxiao Shi5de006b2014-10-26 20:20:52 -0700329 Name n1;
330 BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1));
331 BOOST_CHECK(Name("ndn:/PREFIX/strategy-choice/unset").isPrefixOf(n1));
Junxiao Shi5ec80222014-03-25 20:08:05 -0700332
333 ControlParameters p2;
334 p2.setName("ndn:/example")
335 .setStrategy("ndn:/strategy/P");
336 BOOST_CHECK_THROW(command.validateRequest(p2), ControlCommand::ArgumentError);
337 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
338
339 ControlParameters p3;
340 p3.setName("ndn:/");
341 BOOST_CHECK_THROW(command.validateRequest(p3), ControlCommand::ArgumentError);
342 BOOST_CHECK_THROW(command.validateResponse(p3), ControlCommand::ArgumentError);
343}
344
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700345BOOST_AUTO_TEST_CASE(RibRegister)
346{
347 RibRegisterCommand command;
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700348
349 ControlParameters p1;
350 p1.setName("ndn:/");
351 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
352 BOOST_CHECK_THROW(command.validateResponse(p1), ControlCommand::ArgumentError);
Junxiao Shi5de006b2014-10-26 20:20:52 -0700353 Name n1;
354 BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1));
355 BOOST_CHECK(Name("ndn:/PREFIX/rib/register").isPrefixOf(n1));
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700356
357 command.applyDefaultsToRequest(p1);
358 BOOST_REQUIRE(p1.hasOrigin());
Davide Pesaventoe8e48c22017-04-13 00:35:33 -0400359 BOOST_CHECK_EQUAL(p1.getOrigin(), ROUTE_ORIGIN_APP);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700360 BOOST_REQUIRE(p1.hasCost());
361 BOOST_CHECK_EQUAL(p1.getCost(), 0);
362 BOOST_REQUIRE(p1.hasFlags());
363 BOOST_CHECK_EQUAL(p1.getFlags(), static_cast<uint64_t>(ROUTE_FLAG_CHILD_INHERIT));
Alexander Afanasyev21f13b02014-07-17 16:17:34 -0700364 BOOST_CHECK_EQUAL(p1.hasExpirationPeriod(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700365
366 ControlParameters p2;
367 p2.setName("ndn:/example")
368 .setFaceId(2)
369 .setCost(6);
370 BOOST_CHECK_NO_THROW(command.validateRequest(p2));
371 command.applyDefaultsToRequest(p2);
Alexander Afanasyev21f13b02014-07-17 16:17:34 -0700372 BOOST_CHECK_EQUAL(p2.hasExpirationPeriod(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700373 BOOST_CHECK_NO_THROW(command.validateResponse(p2));
374}
375
376BOOST_AUTO_TEST_CASE(RibUnregister)
377{
378 RibUnregisterCommand command;
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700379
380 ControlParameters p1;
381 p1.setName("ndn:/")
382 .setFaceId(22)
383 .setOrigin(ROUTE_ORIGIN_STATIC);
384 BOOST_CHECK_NO_THROW(command.validateRequest(p1));
385 BOOST_CHECK_NO_THROW(command.validateResponse(p1));
Junxiao Shi5de006b2014-10-26 20:20:52 -0700386 Name n1;
387 BOOST_CHECK_NO_THROW(n1 = command.getRequestName("/PREFIX", p1));
388 BOOST_CHECK(Name("ndn:/PREFIX/rib/unregister").isPrefixOf(n1));
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700389
390 ControlParameters p2;
391 p2.setName("ndn:/example")
392 .setFaceId(0)
393 .setOrigin(ROUTE_ORIGIN_APP);
394 BOOST_CHECK_NO_THROW(command.validateRequest(p2));
Davide Pesaventof8503d22017-02-17 01:19:10 -0500395 p2.setFaceId(INVALID_FACE_ID);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700396 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
397
398 p2.unsetFaceId();
399 BOOST_CHECK_NO_THROW(command.validateRequest(p2));
400 BOOST_CHECK_THROW(command.validateResponse(p2), ControlCommand::ArgumentError);
401}
402
Junxiao Shi7357ef22016-09-07 02:39:37 +0000403BOOST_AUTO_TEST_SUITE_END() // TestControlCommand
404BOOST_AUTO_TEST_SUITE_END() // Nfd
405BOOST_AUTO_TEST_SUITE_END() // Mgmt
Junxiao Shi5ec80222014-03-25 20:08:05 -0700406
Spyridon Mastorakis429634f2015-02-19 17:35:33 -0800407} // namespace tests
Junxiao Shi5ec80222014-03-25 20:08:05 -0700408} // namespace nfd
409} // namespace ndn