blob: d4a733d35e3f7f1f3d89c720703aa23aced24a8c [file] [log] [blame]
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento914d05f2019-07-13 16:20:19 -04002/*
Davide Pesavento0dc02012021-11-23 22:55:03 -05003 * Copyright (c) 2017-2021, Regents of the University of California.
Zhiyi Zhangf5246c42017-01-26 09:39:20 -08004 *
5 * This file is part of ndncert, a certificate management system based on NDN.
6 *
7 * ndncert is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * ndncert 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 General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License along with
16 * ndncert, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ndncert authors and contributors.
19 */
20
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080021#include "ca-module.hpp"
Zhiyi Zhang84e11842020-11-19 20:03:23 -080022#include "challenge/challenge-module.hpp"
23#include "challenge/challenge-email.hpp"
24#include "challenge/challenge-pin.hpp"
Zhiyi Zhang062be6d2020-10-14 17:13:43 -070025#include "detail/info-encoder.hpp"
tylerliu4140fe82021-01-27 15:45:44 -080026#include "requester-request.hpp"
Zhiyi Zhang5d80e1e2020-09-25 11:34:54 -070027#include "test-common.hpp"
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080028
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080029namespace ndncert {
30namespace tests {
31
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070032using namespace ca;
Davide Pesavento0dc02012021-11-23 22:55:03 -050033using ndn::util::DummyClientFace;
34using ndn::security::verifySignature;
Zhiyi Zhang32d4b4e2020-10-28 22:10:49 -070035
Zhiyi Zhangae123bf2017-04-14 12:24:53 -070036BOOST_FIXTURE_TEST_SUITE(TestCaModule, DatabaseFixture)
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080037
38BOOST_AUTO_TEST_CASE(Initialization)
39{
Davide Pesavento0dc02012021-11-23 22:55:03 -050040 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -070041 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080042 BOOST_CHECK_EQUAL(ca.getCaConf().caProfile.caPrefix, "/ndn");
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080043
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080044 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070045 BOOST_CHECK_EQUAL(ca.m_registeredPrefixHandles.size(), 1); // removed local discovery registration
Zhiyi Zhang696cd042020-10-07 21:27:36 -070046 BOOST_CHECK_EQUAL(ca.m_interestFilterHandles.size(), 5); // infoMeta, onProbe, onNew, onChallenge, onRevoke
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080047}
48
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070049BOOST_AUTO_TEST_CASE(HandleProfileFetching)
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070050{
51 auto identity = addIdentity(Name("/ndn"));
52 auto key = identity.getDefaultKey();
53 auto cert = key.getDefaultCertificate();
54
Davide Pesavento0dc02012021-11-23 22:55:03 -050055 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -070056 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070057 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhangcd57da82020-10-08 20:35:40 -070058 auto profileData = ca.getCaProfileData();
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070059
Davide Pesavento0dc02012021-11-23 22:55:03 -050060 Interest interest = ndn::MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
61 std::shared_ptr<Interest> infoInterest = nullptr;
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070062
Zhiyi Zhang696cd042020-10-07 21:27:36 -070063 face.setInterestFilter(
Davide Pesavento0dc02012021-11-23 22:55:03 -050064 ndn::InterestFilter("/ndn/CA/INFO"),
Zhiyi Zhang696cd042020-10-07 21:27:36 -070065 [&](const auto&, const Interest& interest) {
Zhiyi Zhangcd57da82020-10-08 20:35:40 -070066 if (interest.getName() == profileData.getName()) {
67 face.put(profileData);
68 }
69 },
70 nullptr, nullptr);
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070071 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -070072
73 int count = 0;
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -070074 face.onSendData.connect([&](const Data& response) {
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070075 if (count == 0) {
76 count++;
77 auto block = response.getContent();
78 block.parse();
Davide Pesavento0dc02012021-11-23 22:55:03 -050079 infoInterest = std::make_shared<Interest>(Name(block.get(ndn::tlv::Name)).appendSegment(0));
Zhiyi Zhangcd57da82020-10-08 20:35:40 -070080 infoInterest->setCanBePrefix(false);
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070081 }
82 else {
83 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -050084 BOOST_CHECK(verifySignature(response, cert));
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070085 auto contentBlock = response.getContent();
86 contentBlock.parse();
Zhiyi Zhangf22ae242020-11-17 10:51:15 -080087 auto caItem = infotlv::decodeDataContent(contentBlock);
Zhiyi Zhang44c6a352020-12-14 10:57:17 -080088 BOOST_CHECK_EQUAL(caItem.caPrefix, "/ndn");
89 BOOST_CHECK_EQUAL(caItem.probeParameterKeys.size(), 1);
90 BOOST_CHECK_EQUAL(caItem.probeParameterKeys.front(), "full name");
91 BOOST_CHECK_EQUAL(caItem.cert->wireEncode(), cert.wireEncode());
92 BOOST_CHECK_EQUAL(caItem.caInfo, "ndn testbed ca");
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070093 }
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -070094 });
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080095 face.receive(interest);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -080096 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhangfbcab842020-10-07 15:17:13 -070097 face.receive(*infoInterest);
98 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhangcd57da82020-10-08 20:35:40 -070099
Zhiyi Zhangfbcab842020-10-07 15:17:13 -0700100 BOOST_CHECK_EQUAL(count, 2);
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800101}
102
Zhiyi Zhang6f395812020-09-29 14:42:03 -0700103BOOST_AUTO_TEST_CASE(HandleProbe)
104{
105 auto identity = addIdentity(Name("/ndn"));
106 auto key = identity.getDefaultKey();
107 auto cert = key.getDefaultCertificate();
108
Davide Pesavento0dc02012021-11-23 22:55:03 -0500109 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700110 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
Zhiyi Zhang6f395812020-09-29 14:42:03 -0700111 advanceClocks(time::milliseconds(20), 60);
112
113 Interest interest("/ndn/CA/PROBE");
114 interest.setCanBePrefix(false);
115
Davide Pesavento0dc02012021-11-23 22:55:03 -0500116 Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
117 paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
118 paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
Zhiyi Zhang6f395812020-09-29 14:42:03 -0700119 paramTLV.encode();
120
121 interest.setApplicationParameters(paramTLV);
122
123 int count = 0;
124 face.onSendData.connect([&](const Data& response) {
125 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500126 BOOST_CHECK(verifySignature(response, cert));
Zhiyi Zhang6f395812020-09-29 14:42:03 -0700127 Block contentBlock = response.getContent();
128 contentBlock.parse();
tylerliu50d679e2020-10-14 14:08:39 -0700129 Block probeResponse = contentBlock.get(tlv::ProbeResponse);
Zhiyi Zhang6f395812020-09-29 14:42:03 -0700130 probeResponse.parse();
131 Name caName;
Zhiyi Zhang8f1ade32020-10-14 16:42:57 -0700132 caName.wireDecode(probeResponse.get(ndn::tlv::Name));
Zhiyi Zhang8683ec92020-10-07 18:18:35 -0700133 BOOST_CHECK_EQUAL(caName.size(), 2);
Zhiyi Zhang6f395812020-09-29 14:42:03 -0700134 });
135 face.receive(interest);
136
137 advanceClocks(time::milliseconds(20), 60);
138 BOOST_CHECK_EQUAL(count, 1);
139}
140
Zhiyi Zhanga63b7372017-05-17 14:14:34 -0700141BOOST_AUTO_TEST_CASE(HandleProbeUsingDefaultHandler)
142{
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700143 auto identity = addIdentity(Name("/ndn"));
Zhiyi Zhanga63b7372017-05-17 14:14:34 -0700144 auto key = identity.getDefaultKey();
145 auto cert = key.getDefaultCertificate();
146
Davide Pesavento0dc02012021-11-23 22:55:03 -0500147 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700148 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
Zhiyi Zhanga63b7372017-05-17 14:14:34 -0700149 advanceClocks(time::milliseconds(20), 60);
150
swa770de007bc2020-03-24 21:26:21 -0700151 Interest interest("/ndn/CA/PROBE");
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700152 interest.setCanBePrefix(false);
Suyong Won7968f7a2020-05-12 01:01:25 -0700153
Davide Pesavento0dc02012021-11-23 22:55:03 -0500154 Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
155 paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
156 paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
Suyong Won7968f7a2020-05-12 01:01:25 -0700157 paramTLV.encode();
158
159 interest.setApplicationParameters(paramTLV);
Zhiyi Zhanga63b7372017-05-17 14:14:34 -0700160
161 int count = 0;
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700162 face.onSendData.connect([&](const Data& response) {
163 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500164 BOOST_CHECK(verifySignature(response, cert));
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700165 auto contentBlock = response.getContent();
166 contentBlock.parse();
tylerliu50d679e2020-10-14 14:08:39 -0700167 auto probeResponseBlock = contentBlock.get(tlv::ProbeResponse);
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700168 probeResponseBlock.parse();
169 Name caPrefix;
Zhiyi Zhang8f1ade32020-10-14 16:42:57 -0700170 caPrefix.wireDecode(probeResponseBlock.get(ndn::tlv::Name));
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700171 BOOST_CHECK(caPrefix != "");
172 });
Zhiyi Zhanga63b7372017-05-17 14:14:34 -0700173 face.receive(interest);
174
175 advanceClocks(time::milliseconds(20), 60);
176 BOOST_CHECK_EQUAL(count, 1);
177}
178
Suyong Wone2afeb52020-10-04 03:05:39 +0900179BOOST_AUTO_TEST_CASE(HandleProbeRedirection)
180{
181 auto identity = addIdentity(Name("/ndn"));
182 auto key = identity.getDefaultKey();
183 auto cert = key.getDefaultCertificate();
184
Davide Pesavento0dc02012021-11-23 22:55:03 -0500185 DummyClientFace face(io, m_keyChain, {true, true});
Suyong Wone2afeb52020-10-04 03:05:39 +0900186 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-5", "ca-storage-memory");
Suyong Wone2afeb52020-10-04 03:05:39 +0900187 advanceClocks(time::milliseconds(20), 60);
188
189 Interest interest("/ndn/CA/PROBE");
190 interest.setCanBePrefix(false);
191
Davide Pesavento0dc02012021-11-23 22:55:03 -0500192 Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
193 paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
194 paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
Suyong Wone2afeb52020-10-04 03:05:39 +0900195 paramTLV.encode();
196
197 interest.setApplicationParameters(paramTLV);
198
199 int count = 0;
200 face.onSendData.connect([&](const Data& response) {
201 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500202 BOOST_CHECK(verifySignature(response, cert));
Suyong Wone2afeb52020-10-04 03:05:39 +0900203 Block contentBlock = response.getContent();
204 contentBlock.parse();
205
206 // Test CA sent redirections
Zhiyi Zhang34a8d432020-10-03 22:14:25 -0700207 std::vector<Name> redirectionItems;
208 for (auto item : contentBlock.elements()) {
tylerliu50d679e2020-10-14 14:08:39 -0700209 if (item.type() == tlv::ProbeRedirect) {
Zhiyi Zhang34a8d432020-10-03 22:14:25 -0700210 redirectionItems.push_back(Name(item.blockFromValue()));
211 }
Suyong Wone2afeb52020-10-04 03:05:39 +0900212 }
Zhiyi Zhang34a8d432020-10-03 22:14:25 -0700213 BOOST_CHECK_EQUAL(redirectionItems.size(), 2);
Davide Pesavento0dc02012021-11-23 22:55:03 -0500214 BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[0].getPrefix(-1)), "/ndn/site1");
215 BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[1].getPrefix(-1)), "/ndn/site1");
Suyong Wone2afeb52020-10-04 03:05:39 +0900216 });
217 face.receive(interest);
218 advanceClocks(time::milliseconds(20), 60);
219 BOOST_CHECK_EQUAL(count, 1);
220}
221
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800222BOOST_AUTO_TEST_CASE(HandleNew)
223{
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700224 auto identity = addIdentity(Name("/ndn"));
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800225 auto key = identity.getDefaultKey();
226 auto cert = key.getDefaultCertificate();
227
Davide Pesavento0dc02012021-11-23 22:55:03 -0500228 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700229 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800230 advanceClocks(time::milliseconds(20), 60);
231
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700232 CaProfile item;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800233 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500234 item.cert = std::make_shared<Certificate>(cert);
tylerliu4140fe82021-01-27 15:45:44 -0800235 requester::Request state(m_keyChain, item, RequestType::NEW);
236 auto interest = state.genNewInterest(Name("/ndn/zhiyi"),
237 time::system_clock::now(),
238 time::system_clock::now() + time::days(1));
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800239
240 int count = 0;
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700241 face.onSendData.connect([&](const Data& response) {
242 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500243 BOOST_CHECK(verifySignature(response, cert));
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700244 auto contentBlock = response.getContent();
245 contentBlock.parse();
Suyong Won7968f7a2020-05-12 01:01:25 -0700246
tylerliu50d679e2020-10-14 14:08:39 -0700247 BOOST_CHECK(readString(contentBlock.get(tlv::EcdhPub)) != "");
248 BOOST_CHECK(readString(contentBlock.get(tlv::Salt)) != "");
249 BOOST_CHECK(readString(contentBlock.get(tlv::RequestId)) != "");
Suyong Won7968f7a2020-05-12 01:01:25 -0700250
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700251 auto challengeBlockCount = 0;
252 for (auto const& element : contentBlock.elements()) {
tylerliu50d679e2020-10-14 14:08:39 -0700253 if (element.type() == tlv::Challenge) {
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700254 challengeBlockCount++;
Suyong Won7968f7a2020-05-12 01:01:25 -0700255 }
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700256 }
Suyong Won7968f7a2020-05-12 01:01:25 -0700257
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700258 BOOST_CHECK(challengeBlockCount != 0);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700259
tylerliu4140fe82021-01-27 15:45:44 -0800260 auto challengeList = state.onNewRenewRevokeResponse(response);
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -0700261 RequestId requestId;
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700262 std::memcpy(requestId.data(), contentBlock.get(tlv::RequestId).value(), contentBlock.get(tlv::RequestId).value_size());
tylerliu7b9185c2020-11-24 12:15:18 -0800263 auto ca_encryption_key = ca.getCaStorage()->getRequest(requestId).encryptionKey;
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800264 BOOST_CHECK_EQUAL_COLLECTIONS(state.m_aesKey.begin(), state.m_aesKey.end(),
Zhiyi Zhang1f9551b2020-10-30 10:30:43 -0700265 ca_encryption_key.begin(), ca_encryption_key.end());
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700266 });
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700267 face.receive(*interest);
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800268
269 advanceClocks(time::milliseconds(20), 60);
270 BOOST_CHECK_EQUAL(count, 1);
271}
272
Zhiyi Zhang1a735bc2019-07-04 21:36:49 -0700273BOOST_AUTO_TEST_CASE(HandleNewWithInvalidValidityPeriod1)
274{
275 auto identity = addIdentity(Name("/ndn"));
276 auto key = identity.getDefaultKey();
277 auto cert = key.getDefaultCertificate();
278
Davide Pesavento0dc02012021-11-23 22:55:03 -0500279 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700280 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1");
Zhiyi Zhang1a735bc2019-07-04 21:36:49 -0700281 advanceClocks(time::milliseconds(20), 60);
282
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700283 CaProfile item;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800284 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500285 item.cert = std::make_shared<Certificate>(cert);
tylerliu4140fe82021-01-27 15:45:44 -0800286 requester::Request state(m_keyChain, item, RequestType::NEW);
Zhiyi Zhang1a735bc2019-07-04 21:36:49 -0700287 auto current_tp = time::system_clock::now();
tylerliu4140fe82021-01-27 15:45:44 -0800288 auto interest1 = state.genNewInterest(Name("/ndn/zhiyi"), current_tp, current_tp - time::hours(1));
289 auto interest2 = state.genNewInterest(Name("/ndn/zhiyi"), current_tp, current_tp + time::days(361));
290 auto interest3 = state.genNewInterest(Name("/ndn/zhiyi"), current_tp - time::hours(1), current_tp + time::hours(2));
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700291 face.onSendData.connect([&](const Data& response) {
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700292 auto contentTlv = response.getContent();
293 contentTlv.parse();
tylerliu50d679e2020-10-14 14:08:39 -0700294 auto errorCode = static_cast<ErrorCode>(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode)));
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700295 BOOST_CHECK(errorCode != ErrorCode::NO_ERROR);
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700296 });
Zhiyi Zhang1a735bc2019-07-04 21:36:49 -0700297 face.receive(*interest1);
298 face.receive(*interest2);
299 face.receive(*interest3);
300
301 advanceClocks(time::milliseconds(20), 60);
302}
303
tylerliuf62cfeb2021-01-28 11:01:33 -0800304BOOST_AUTO_TEST_CASE(HandleNewWithServerBadValidity)
305{
306 auto identity = addIdentity(Name("/ndn"));
307 auto key = identity.getDefaultKey();
308
309 //build expired cert
Davide Pesavento0dc02012021-11-23 22:55:03 -0500310 Certificate cert;
tylerliuf62cfeb2021-01-28 11:01:33 -0800311 cert.setName(Name(key.getName()).append("self-sign").appendVersion());
312 cert.setContentType(ndn::tlv::ContentType_Key);
313 cert.setContent(key.getPublicKey().data(), key.getPublicKey().size());
314 SignatureInfo signatureInfo;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500315 signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now() - time::days(1),
316 time::system_clock::now() - time::seconds(1)));
tylerliuf62cfeb2021-01-28 11:01:33 -0800317 m_keyChain.sign(cert, signingByKey(key.getName()).setSignatureInfo(signatureInfo));
318 m_keyChain.setDefaultCertificate(key, cert);
319
Davide Pesavento0dc02012021-11-23 22:55:03 -0500320 DummyClientFace face(io, m_keyChain, {true, true});
tylerliuf62cfeb2021-01-28 11:01:33 -0800321 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
322 advanceClocks(time::milliseconds(20), 60);
323
324 CaProfile item;
325 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500326 item.cert = std::make_shared<Certificate>(cert);
tylerliuf62cfeb2021-01-28 11:01:33 -0800327 requester::Request state(m_keyChain, item, RequestType::NEW);
328 auto interest = state.genNewInterest(Name("/ndn/zhiyi"),
329 time::system_clock::now(),
330 time::system_clock::now() + time::days(1));
331
332 int count = 0;
333 face.onSendData.connect([&](const Data& response) {
334 auto contentTlv = response.getContent();
335 contentTlv.parse();
336 auto errorCode = static_cast<ErrorCode>(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode)));
337 BOOST_CHECK(errorCode != ErrorCode::NO_ERROR);
338 count ++;
339 });
340 face.receive(*interest);
341
342 advanceClocks(time::milliseconds(20), 60);
343 BOOST_CHECK_EQUAL(count, 1);
344}
345
tylerliu0b6d0db2020-09-28 17:52:02 -0700346BOOST_AUTO_TEST_CASE(HandleNewWithLongSuffix)
347{
348 auto identity = addIdentity(Name("/ndn"));
349 auto key = identity.getDefaultKey();
350 auto cert = key.getDefaultCertificate();
351
Davide Pesavento0dc02012021-11-23 22:55:03 -0500352 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700353 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
tylerliu0b6d0db2020-09-28 17:52:02 -0700354 advanceClocks(time::milliseconds(20), 60);
355
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700356 CaProfile item;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800357 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500358 item.cert = std::make_shared<Certificate>(cert);
tylerliu4140fe82021-01-27 15:45:44 -0800359 requester::Request state(m_keyChain, item, RequestType::NEW);
tylerliu0b6d0db2020-09-28 17:52:02 -0700360
tylerliu4140fe82021-01-27 15:45:44 -0800361 auto interest1 = state.genNewInterest(Name("/ndn/a"), time::system_clock::now(),
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700362 time::system_clock::now() + time::days(1));
tylerliu4140fe82021-01-27 15:45:44 -0800363 auto interest2 = state.genNewInterest(Name("/ndn/a/b"), time::system_clock::now(),
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700364 time::system_clock::now() + time::days(1));
tylerliu4140fe82021-01-27 15:45:44 -0800365 auto interest3 = state.genNewInterest(Name("/ndn/a/b/c/d"), time::system_clock::now(),
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700366 time::system_clock::now() + time::days(1));
tylerliu0b6d0db2020-09-28 17:52:02 -0700367
tylerliu0b6d0db2020-09-28 17:52:02 -0700368 face.onSendData.connect([&](const Data& response) {
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700369 auto contentTlv = response.getContent();
370 contentTlv.parse();
371 if (interest3->getName().isPrefixOf(response.getName())) {
tylerliu50d679e2020-10-14 14:08:39 -0700372 auto errorCode = static_cast<ErrorCode>(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode)));
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700373 BOOST_CHECK(errorCode != ErrorCode::NO_ERROR);
374 }
375 else {
376 // should successfully get responses
Davide Pesavento0dc02012021-11-23 22:55:03 -0500377 BOOST_CHECK_THROW(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode)), std::runtime_error);
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700378 }
tylerliu0b6d0db2020-09-28 17:52:02 -0700379 });
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700380 face.receive(*interest1);
381 face.receive(*interest2);
382 face.receive(*interest3);
tylerliu0b6d0db2020-09-28 17:52:02 -0700383 advanceClocks(time::milliseconds(20), 60);
tylerliu0b6d0db2020-09-28 17:52:02 -0700384}
385
tylerliu0b6d0db2020-09-28 17:52:02 -0700386BOOST_AUTO_TEST_CASE(HandleNewWithInvalidLength1)
387{
388 auto identity = addIdentity(Name("/ndn"));
389 auto key = identity.getDefaultKey();
390 auto cert = key.getDefaultCertificate();
391
Davide Pesavento0dc02012021-11-23 22:55:03 -0500392 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700393 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1");
tylerliu0b6d0db2020-09-28 17:52:02 -0700394 advanceClocks(time::milliseconds(20), 60);
395
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700396 CaProfile item;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800397 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500398 item.cert = std::make_shared<Certificate>(cert);
tylerliu4140fe82021-01-27 15:45:44 -0800399 requester::Request state(m_keyChain, item, RequestType::NEW);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700400
tylerliu0b6d0db2020-09-28 17:52:02 -0700401 auto current_tp = time::system_clock::now();
tylerliu4140fe82021-01-27 15:45:44 -0800402 auto interest1 = state.genNewInterest(Name("/ndn"), current_tp, current_tp + time::days(1));
403 auto interest2 = state.genNewInterest(Name("/ndn/a/b/c/d"), current_tp, current_tp + time::days(1));
tylerliu0b6d0db2020-09-28 17:52:02 -0700404 face.onSendData.connect([&](const Data& response) {
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700405 auto contentTlv = response.getContent();
406 contentTlv.parse();
tylerliu50d679e2020-10-14 14:08:39 -0700407 auto errorCode = static_cast<ErrorCode>(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode)));
Zhiyi Zhang01e91a32020-09-29 12:10:00 -0700408 BOOST_CHECK(errorCode != ErrorCode::NO_ERROR);
tylerliu0b6d0db2020-09-28 17:52:02 -0700409 });
410 face.receive(*interest1);
411 face.receive(*interest2);
412
413 advanceClocks(time::milliseconds(20), 60);
414}
415
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700416BOOST_AUTO_TEST_CASE(HandleChallenge)
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800417{
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700418 auto identity = addIdentity(Name("/ndn"));
419 auto key = identity.getDefaultKey();
420 auto cert = key.getDefaultCertificate();
421
Davide Pesavento0dc02012021-11-23 22:55:03 -0500422 DummyClientFace face(io, m_keyChain, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700423 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800424 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700425
426 // generate NEW Interest
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700427 CaProfile item;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800428 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500429 item.cert = std::make_shared<Certificate>(cert);
tylerliu4140fe82021-01-27 15:45:44 -0800430 requester::Request state(m_keyChain, item, RequestType::NEW);
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700431
tylerliu4140fe82021-01-27 15:45:44 -0800432 auto newInterest = state.genNewInterest(Name("/ndn/zhiyi"), time::system_clock::now(),
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700433 time::system_clock::now() + time::days(1));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700434
435 // generate CHALLENGE Interest
Davide Pesavento0dc02012021-11-23 22:55:03 -0500436 std::shared_ptr<Interest> challengeInterest;
437 std::shared_ptr<Interest> challengeInterest2;
438 std::shared_ptr<Interest> challengeInterest3;
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800439
440 int count = 0;
Zhiyi Zhangfc1678a2020-05-12 16:52:14 -0700441 face.onSendData.connect([&](const Data& response) {
swa770de007bc2020-03-24 21:26:21 -0700442 if (Name("/ndn/CA/NEW").isPrefixOf(response.getName())) {
tylerliu4140fe82021-01-27 15:45:44 -0800443 auto challengeList = state.onNewRenewRevokeResponse(response);
444 auto paramList = state.selectOrContinueChallenge("pin");
445 challengeInterest = state.genChallengeInterest(std::move(paramList));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700446 }
swa770de007bc2020-03-24 21:26:21 -0700447 else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 0) {
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800448 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500449 BOOST_CHECK(verifySignature(response, cert));
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800450
tylerliu4140fe82021-01-27 15:45:44 -0800451 state.onChallengeResponse(response);
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800452 BOOST_CHECK(state.m_status == Status::CHALLENGE);
453 BOOST_CHECK_EQUAL(state.m_challengeStatus, ChallengePin::NEED_CODE);
tylerliu4140fe82021-01-27 15:45:44 -0800454 auto paramList = state.selectOrContinueChallenge("pin");
455 challengeInterest2 = state.genChallengeInterest(std::move(paramList));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700456 }
swa770de007bc2020-03-24 21:26:21 -0700457 else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 1) {
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700458 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500459 BOOST_CHECK(verifySignature(response, cert));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700460
tylerliu4140fe82021-01-27 15:45:44 -0800461 state.onChallengeResponse(response);
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800462 BOOST_CHECK(state.m_status == Status::CHALLENGE);
463 BOOST_CHECK_EQUAL(state.m_challengeStatus, ChallengePin::WRONG_CODE);
Davide Pesavento914d05f2019-07-13 16:20:19 -0400464
tylerliu4140fe82021-01-27 15:45:44 -0800465 auto paramList = state.selectOrContinueChallenge("pin");
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700466 auto request = ca.getCertificateRequest(*challengeInterest2);
tylerliu7b9185c2020-11-24 12:15:18 -0800467 auto secret = request->challengeState->secrets.get(ChallengePin::PARAMETER_KEY_CODE, "");
tylerliu40226332020-11-11 15:37:16 -0800468 paramList.begin()->second = secret;
tylerliu4140fe82021-01-27 15:45:44 -0800469 challengeInterest3 = state.genChallengeInterest(std::move(paramList));
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700470 }
swa770de007bc2020-03-24 21:26:21 -0700471 else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 2) {
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700472 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500473 BOOST_CHECK(verifySignature(response, cert));
tylerliu4140fe82021-01-27 15:45:44 -0800474 state.onChallengeResponse(response);
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800475 BOOST_CHECK(state.m_status == Status::SUCCESS);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700476 }
Davide Pesavento914d05f2019-07-13 16:20:19 -0400477 });
478
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700479 face.receive(*newInterest);
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800480 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhangaf7c2902019-03-14 22:13:21 -0700481 face.receive(*challengeInterest);
482 advanceClocks(time::milliseconds(20), 60);
483 face.receive(*challengeInterest2);
484 advanceClocks(time::milliseconds(20), 60);
485 face.receive(*challengeInterest3);
486 advanceClocks(time::milliseconds(20), 60);
487 BOOST_CHECK_EQUAL(count, 3);
Zhiyi Zhang1c0bd372017-12-18 18:32:55 +0800488}
489
tylerliu182bc532020-09-25 01:54:45 -0700490BOOST_AUTO_TEST_CASE(HandleRevoke)
491{
492 auto identity = addIdentity(Name("/ndn"));
493 auto key = identity.getDefaultKey();
494 auto cert = key.getDefaultCertificate();
495
Davide Pesavento0dc02012021-11-23 22:55:03 -0500496 DummyClientFace face(io, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700497 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
tylerliu182bc532020-09-25 01:54:45 -0700498 advanceClocks(time::milliseconds(20), 60);
499
500 //generate a certificate
501 auto clientIdentity = m_keyChain.createIdentity("/ndn/qwerty");
502 auto clientKey = clientIdentity.getDefaultKey();
Davide Pesavento0dc02012021-11-23 22:55:03 -0500503 Certificate clientCert;
tylerliu182bc532020-09-25 01:54:45 -0700504 clientCert.setName(Name(clientKey.getName()).append("cert-request").appendVersion());
Zhiyi Zhang8f1ade32020-10-14 16:42:57 -0700505 clientCert.setContentType(ndn::tlv::ContentType_Key);
tylerliu182bc532020-09-25 01:54:45 -0700506 clientCert.setFreshnessPeriod(time::hours(24));
507 clientCert.setContent(clientKey.getPublicKey().data(), clientKey.getPublicKey().size());
508 SignatureInfo signatureInfo;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500509 signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
510 time::system_clock::now() + time::hours(10)));
tylerliu182bc532020-09-25 01:54:45 -0700511 m_keyChain.sign(clientCert, signingByKey(clientKey.getName()).setSignatureInfo(signatureInfo));
Zhiyi Zhang1f5e86e2020-12-04 15:07:57 -0800512 RequestId requestId = {{101}};
513 RequestState certRequest;
514 certRequest.caPrefix = Name("/ndn");
515 certRequest.requestId = requestId;
516 certRequest.requestType = RequestType::NEW;
517 certRequest.status = Status::SUCCESS;
518 certRequest.cert = clientCert;
tylerliu182bc532020-09-25 01:54:45 -0700519 auto issuedCert = ca.issueCertificate(certRequest);
520
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700521 CaProfile item;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800522 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500523 item.cert = std::make_shared<Certificate>(cert);
tylerliu4140fe82021-01-27 15:45:44 -0800524 requester::Request state(m_keyChain, item, RequestType::REVOKE);
tylerliu182bc532020-09-25 01:54:45 -0700525
tylerliu4140fe82021-01-27 15:45:44 -0800526 auto interest = state.genRevokeInterest(issuedCert);
tylerliu182bc532020-09-25 01:54:45 -0700527
528 int count = 0;
Zhiyi Zhang46049832020-09-28 17:08:12 -0700529 face.onSendData.connect([&](const Data& response) {
tylerliu182bc532020-09-25 01:54:45 -0700530 count++;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500531 BOOST_CHECK(verifySignature(response, cert));
tylerliu182bc532020-09-25 01:54:45 -0700532 auto contentBlock = response.getContent();
533 contentBlock.parse();
534
tylerliu50d679e2020-10-14 14:08:39 -0700535 BOOST_CHECK(readString(contentBlock.get(tlv::EcdhPub)) != "");
536 BOOST_CHECK(readString(contentBlock.get(tlv::Salt)) != "");
537 BOOST_CHECK(readString(contentBlock.get(tlv::RequestId)) != "");
tylerliu182bc532020-09-25 01:54:45 -0700538
539 auto challengeBlockCount = 0;
540 for (auto const& element : contentBlock.elements()) {
tylerliu50d679e2020-10-14 14:08:39 -0700541 if (element.type() == tlv::Challenge) {
Zhiyi Zhang46049832020-09-28 17:08:12 -0700542 challengeBlockCount++;
543 }
tylerliu182bc532020-09-25 01:54:45 -0700544 }
545
546 BOOST_CHECK(challengeBlockCount != 0);
547
tylerliu4140fe82021-01-27 15:45:44 -0800548 auto challengeList = state.onNewRenewRevokeResponse(response);
Zhiyi Zhangc9ada1b2020-10-29 19:13:15 -0700549 RequestId requestId;
Zhiyi Zhang8fdb36b2020-10-18 11:58:51 -0700550 std::memcpy(requestId.data(), contentBlock.get(tlv::RequestId).value(), contentBlock.get(tlv::RequestId).value_size());
tylerliu7b9185c2020-11-24 12:15:18 -0800551 auto ca_encryption_key = ca.getCaStorage()->getRequest(requestId).encryptionKey;
Zhiyi Zhang6499edd2021-02-17 22:37:21 -0800552 BOOST_CHECK_EQUAL_COLLECTIONS(state.m_aesKey.begin(), state.m_aesKey.end(),
Zhiyi Zhang1f9551b2020-10-30 10:30:43 -0700553 ca_encryption_key.begin(), ca_encryption_key.end());
tylerliu182bc532020-09-25 01:54:45 -0700554 });
555 face.receive(*interest);
556
557 advanceClocks(time::milliseconds(20), 60);
558 BOOST_CHECK_EQUAL(count, 1);
559}
560
561BOOST_AUTO_TEST_CASE(HandleRevokeWithBadCert)
562{
563 auto identity = addIdentity(Name("/ndn"));
564 auto key = identity.getDefaultKey();
565 auto cert = key.getDefaultCertificate();
566
Davide Pesavento0dc02012021-11-23 22:55:03 -0500567 DummyClientFace face(io, {true, true});
Zhiyi Zhang9829da92020-09-30 16:19:34 -0700568 CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
tylerliu182bc532020-09-25 01:54:45 -0700569 advanceClocks(time::milliseconds(20), 60);
570
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700571 // generate a certificate
tylerliu182bc532020-09-25 01:54:45 -0700572 auto clientIdentity = m_keyChain.createIdentity("/ndn/qwerty");
573 auto clientKey = clientIdentity.getDefaultKey();
Davide Pesavento0dc02012021-11-23 22:55:03 -0500574 Certificate clientCert;
575 clientCert.setName(Name(clientKey.getName()).append("NDNCERT").append("1473283247810732701"));
Zhiyi Zhang8f1ade32020-10-14 16:42:57 -0700576 clientCert.setContentType(ndn::tlv::ContentType_Key);
tylerliu182bc532020-09-25 01:54:45 -0700577 clientCert.setFreshnessPeriod(time::hours(24));
578 clientCert.setContent(clientKey.getPublicKey().data(), clientKey.getPublicKey().size());
579 SignatureInfo signatureInfo;
Davide Pesavento0dc02012021-11-23 22:55:03 -0500580 signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
581 time::system_clock::now() + time::hours(10)));
tylerliu182bc532020-09-25 01:54:45 -0700582 m_keyChain.sign(clientCert, signingByKey(clientKey.getName()).setSignatureInfo(signatureInfo));
583
Zhiyi Zhang1d3dcd22020-10-01 22:25:43 -0700584 CaProfile item;
Zhiyi Zhang44c6a352020-12-14 10:57:17 -0800585 item.caPrefix = Name("/ndn");
Davide Pesavento0dc02012021-11-23 22:55:03 -0500586 item.cert = std::make_shared<Certificate>(cert);
tylerliu4140fe82021-01-27 15:45:44 -0800587 requester::Request state(m_keyChain, item, RequestType::NEW);
tylerliu182bc532020-09-25 01:54:45 -0700588
tylerliu4140fe82021-01-27 15:45:44 -0800589 auto interest = state.genRevokeInterest(clientCert);
tylerliu182bc532020-09-25 01:54:45 -0700590
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700591 bool receiveData = false;
Zhiyi Zhang46049832020-09-28 17:08:12 -0700592 face.onSendData.connect([&](const Data& response) {
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700593 receiveData = true;
594 auto contentTlv = response.getContent();
595 contentTlv.parse();
tylerliu50d679e2020-10-14 14:08:39 -0700596 BOOST_CHECK(static_cast<ErrorCode>(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode))) != ErrorCode::NO_ERROR);
tylerliu182bc532020-09-25 01:54:45 -0700597 });
598 face.receive(*interest);
599
600 advanceClocks(time::milliseconds(20), 60);
Zhiyi Zhang3e8ca252020-09-30 17:18:38 -0700601 BOOST_CHECK_EQUAL(receiveData, true);
tylerliu182bc532020-09-25 01:54:45 -0700602}
603
Davide Pesavento0dc02012021-11-23 22:55:03 -0500604BOOST_AUTO_TEST_SUITE_END() // TestCaModule
Zhiyi Zhangf5246c42017-01-26 09:39:20 -0800605
Zhiyi Zhange4891b72020-10-10 15:11:57 -0700606} // namespace tests
607} // namespace ndncert