blob: 49e7e2c6f4672048790ec7f326dda3d8a3407c29 [file] [log] [blame]
Yingdi Yu77627ab2015-07-21 16:13:49 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Davide Pesavento013de9b2016-09-01 12:06:56 +00003 * Copyright (c) 2014-2016, Regents of the University of California.
Yingdi Yu77627ab2015-07-21 16:13:49 -07004 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07005 * This file is part of ndn-tools (Named Data Networking Essential Tools).
6 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
Yingdi Yu77627ab2015-07-21 16:13:49 -07007 *
Yingdi Yu0a312e52015-07-22 13:14:53 -07008 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Yingdi Yu77627ab2015-07-21 16:13:49 -070011 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070012 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Yingdi Yu77627ab2015-07-21 16:13:49 -070015 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070016 * You should have received a copy of the GNU General Public License along with
17 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Yingdi Yu77627ab2015-07-21 16:13:49 -070018 *
Yingdi Yu0a312e52015-07-22 13:14:53 -070019 * @author Yingdi Yu <yingdi@cs.ucla.edu>
Yingdi Yu77627ab2015-07-21 16:13:49 -070020 */
21
22#include "tools/pib/pib-db.hpp"
Davide Pesavento013de9b2016-09-01 12:06:56 +000023
24#include "tests/identity-management-fixture.hpp"
Yingdi Yu77627ab2015-07-21 16:13:49 -070025
26#include <boost/filesystem.hpp>
27
Yingdi Yu77627ab2015-07-21 16:13:49 -070028namespace ndn {
29namespace pib {
30namespace tests {
31
Yingdi Yu0a312e52015-07-22 13:14:53 -070032class PibDbTestFixture : public ndn::tests::IdentityManagementTimeFixture
Yingdi Yu77627ab2015-07-21 16:13:49 -070033{
34public:
35 PibDbTestFixture()
36 : tmpPath(boost::filesystem::path(TMP_TESTS_PATH) / "DbTest")
37 , db(tmpPath.c_str())
38 {
39 }
40
41 ~PibDbTestFixture()
42 {
43 boost::filesystem::remove_all(tmpPath);
44 }
45
46 boost::asio::io_service io;
47 boost::filesystem::path tmpPath;
48 PibDb db;
49 std::vector<Name> deletedIds;
50 std::vector<Name> deletedKeys;
51 std::vector<Name> deletedCerts;
52 std::vector<Name> insertedCerts;
53};
54
55
Davide Pesavento013de9b2016-09-01 12:06:56 +000056BOOST_AUTO_TEST_SUITE(Pib)
57BOOST_FIXTURE_TEST_SUITE(TestPibDb, PibDbTestFixture)
Yingdi Yu77627ab2015-07-21 16:13:49 -070058
59BOOST_AUTO_TEST_CASE(MgmtTest)
60{
61 Name testUser("/localhost/pib/test/mgmt");
62 addIdentity(testUser);
63 Name testUserCertName = m_keyChain.getDefaultCertificateNameForIdentity(testUser);
64 shared_ptr<IdentityCertificate> testUserCert = m_keyChain.getCertificate(testUserCertName);
65
66
67 BOOST_CHECK_EQUAL(db.getOwnerName(), "");
68 BOOST_CHECK(db.getMgmtCertificate() == nullptr);
69
70 db.updateMgmtCertificate(*testUserCert);
71 BOOST_CHECK_EQUAL(db.getOwnerName(), "test");
72 BOOST_REQUIRE(db.getMgmtCertificate() != nullptr);
73 BOOST_CHECK_EQUAL(db.getMgmtCertificate()->getName(), testUserCertName);
74
75 db.setTpmLocator("tpmLocator");
76 BOOST_CHECK_EQUAL(db.getTpmLocator(), "tpmLocator");
77
78 Name testUser2("/localhost/pib/test2/mgmt");
79 addIdentity(testUser2);
80 Name testUser2CertName = m_keyChain.getDefaultCertificateNameForIdentity(testUser2);
81 shared_ptr<IdentityCertificate> testUser2Cert = m_keyChain.getCertificate(testUser2CertName);
82
83 BOOST_CHECK_THROW(db.updateMgmtCertificate(*testUser2Cert), PibDb::Error);
84
85 Name testUserKeyName2 = m_keyChain.generateRsaKeyPairAsDefault(testUser);
86 shared_ptr<IdentityCertificate> testUserCert2 = m_keyChain.selfSign(testUserKeyName2);
87
88 BOOST_CHECK_NO_THROW(db.updateMgmtCertificate(*testUserCert2));
89 BOOST_REQUIRE(db.getMgmtCertificate() != nullptr);
90 BOOST_CHECK_EQUAL(db.getMgmtCertificate()->getName(),
91 testUserCert2->getName());
92}
93
94BOOST_AUTO_TEST_CASE(IdentityTest)
95{
96 db.identityDeleted.connect([this] (const Name& id) {
97 this->deletedIds.push_back(id);
98 });
99
100 Name identity("/test/identity");
101 Name identity2("/test/identity2");
102
103 // Add an identity: /test/identity
104 // Since there is no default identity,
105 // the new added identity will be set as the default identity.
106 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), PibDb::NON_EXISTING_IDENTITY);
107 db.addIdentity(identity);
108 BOOST_CHECK(db.hasIdentity(identity));
109 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), identity);
110
111 // Add the second identity: /test/identity2
112 // Since the default identity exists,
113 // the new added identity will not be set as the default identity.
114 db.addIdentity(identity2);
115 BOOST_CHECK_EQUAL(db.hasIdentity(identity2), true);
116 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), identity);
117
118 // Set the second identity: /test/identity2 as default explicitly
119 db.setDefaultIdentity(identity2);
120 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), identity2);
121
122 // Delete identity /test/identity2, which is also the default one
123 // This will trigger the identityDeleted signal
124 // and also causes no default identity.
125 db.deleteIdentity(identity2);
126 BOOST_CHECK_EQUAL(db.hasIdentity(identity2), false);
127 BOOST_CHECK_EQUAL(db.hasIdentity(identity), true);
128 BOOST_CHECK_EQUAL(deletedIds.size(), 1);
129 BOOST_CHECK_EQUAL(deletedIds[0], identity2);
130 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), PibDb::NON_EXISTING_IDENTITY);
131 deletedIds.clear();
132
133 // Add the second identity back
134 // Since there is no default identity (though another identity still exists),
135 // the second identity will be set as default.
136 db.addIdentity(identity2);
137 BOOST_CHECK_EQUAL(db.hasIdentity(identity2), true);
138 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), identity2);
139
140 // Delete identity /test/identity
141 db.deleteIdentity(identity);
142 BOOST_CHECK_EQUAL(db.hasIdentity(identity), false);
143 BOOST_CHECK_EQUAL(db.hasIdentity(identity2), true);
144 BOOST_CHECK_EQUAL(deletedIds.size(), 1);
145 BOOST_CHECK_EQUAL(deletedIds[0], identity);
146 deletedIds.clear();
147
148 // Delete identity /test/identity2
149 db.deleteIdentity(identity2);
150 BOOST_CHECK_EQUAL(db.hasIdentity(identity), false);
151 BOOST_CHECK_EQUAL(db.hasIdentity(identity2), false);
152 BOOST_CHECK_EQUAL(deletedIds.size(), 1);
153 BOOST_CHECK_EQUAL(deletedIds[0], identity2);
154 deletedIds.clear();
155}
156
157
158BOOST_AUTO_TEST_CASE(KeyTest)
159{
160 db.identityDeleted.connect([this] (const Name& id) {
161 this->deletedIds.push_back(id);
162 });
163
164 db.keyDeleted.connect([this] (const Name& key) {
165 this->deletedKeys.push_back(key);
166 });
167
168 // Initialize id1
169 Name id1("/test/identity");
170 addIdentity(id1);
171 Name certName111 = m_keyChain.getDefaultCertificateNameForIdentity(id1);
172 shared_ptr<IdentityCertificate> cert111 = m_keyChain.getCertificate(certName111);
173 Name keyName11 = cert111->getPublicKeyName();
174 PublicKey& key11 = cert111->getPublicKeyInfo();
175
176 advanceClocks(io, time::milliseconds(100));
177 Name keyName12 = m_keyChain.generateRsaKeyPairAsDefault(id1);
178 shared_ptr<IdentityCertificate> cert121 = m_keyChain.selfSign(keyName12);
179 PublicKey& key12 = cert121->getPublicKeyInfo();
180
181 // Initialize id2
182 advanceClocks(io, time::milliseconds(100));
183 Name id2("/test/identity2");
184 addIdentity(id2);
185 Name certName211 = m_keyChain.getDefaultCertificateNameForIdentity(id2);
186 shared_ptr<IdentityCertificate> cert211 = m_keyChain.getCertificate(certName211);
187 Name keyName21 = cert211->getPublicKeyName();
188 PublicKey& key21 = cert211->getPublicKeyInfo();
189
190 advanceClocks(io, time::milliseconds(100));
191 Name keyName22 = m_keyChain.generateRsaKeyPairAsDefault(id2);
192 shared_ptr<IdentityCertificate> cert221 = m_keyChain.selfSign(keyName22);
193 PublicKey& key22 = cert221->getPublicKeyInfo();
194
195 // Add a key, the corresponding identity should be added as well
196 // Since the PIB does not have any default identity set before,
197 // the added identity will be set as default.
198 // Since there is no default key for the identity,
199 // the added key will be set as default.
200 BOOST_CHECK_EQUAL(db.getDefaultKeyNameOfIdentity(id1), PibDb::NON_EXISTING_KEY);
201 BOOST_CHECK(db.getKey(keyName11) == nullptr);
202 db.addKey(keyName11, key11);
203 BOOST_CHECK(db.hasIdentity(id1));
204 BOOST_CHECK(db.getKey(keyName11) != nullptr);
205 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), id1);
206 BOOST_CHECK_EQUAL(db.getDefaultKeyNameOfIdentity(id1), keyName11);
207
208 // Add the second key of /test/identity.
209 // Since the default key of /test/identity has been set,
210 // The new added key will not be set as default.
211 db.addKey(keyName12, key12);
212 BOOST_CHECK(db.getKey(keyName12) != nullptr);
213 BOOST_CHECK_EQUAL(db.getDefaultKeyNameOfIdentity(id1), keyName11);
214
215 // Explicitly set the second key as the default key of /test/identity
216 db.setDefaultKeyNameOfIdentity(keyName12);
217 BOOST_CHECK_EQUAL(db.getDefaultKeyNameOfIdentity(id1), keyName12);
218
219 // Delete the second key which is also the default key.
220 // This will trigger the keyDeleted signal.
221 // This will also cause no default key for /test/identity
222 db.deleteKey(keyName12);
223 BOOST_CHECK_EQUAL(db.hasKey(keyName12), false);
224 BOOST_CHECK_EQUAL(db.hasKey(keyName11), true);
225 BOOST_CHECK_EQUAL(db.hasKey(keyName22), false);
226 BOOST_CHECK_EQUAL(db.hasKey(keyName21), false);
227 BOOST_CHECK_EQUAL(deletedKeys.size(), 1);
228 BOOST_CHECK_EQUAL(deletedKeys[0], keyName12);
229 deletedKeys.clear();
230
231 // Add the second key back.
232 // Since there is no default key of /test/identity (although another key still exists)
233 // The second key will be set as the default key of /test/identity
234 BOOST_CHECK_EQUAL(db.getDefaultKeyNameOfIdentity(id1), PibDb::NON_EXISTING_KEY);
235 db.addKey(keyName12, key12);
236 BOOST_CHECK_EQUAL(db.getDefaultKeyNameOfIdentity(id1), keyName12);
237
238 // Prepare test for identity deletion
239 db.addKey(keyName21, key21);
240 db.addKey(keyName22, key22);
241 BOOST_CHECK_EQUAL(db.hasKey(keyName12), true);
242 BOOST_CHECK_EQUAL(db.hasKey(keyName22), true);
243 BOOST_CHECK_EQUAL(db.hasKey(keyName21), true);
244 BOOST_CHECK_EQUAL(db.hasIdentity(id2), true);
245
246 // Delete the identity.
247 // All keys of the identity should also be deleted,
248 // and the keyDeleted signal should be triggered twice.
249 db.deleteIdentity(id1);
250 BOOST_CHECK_EQUAL(db.hasIdentity(id1), false);
251 BOOST_CHECK_EQUAL(db.hasIdentity(id2), true);
252 BOOST_CHECK_EQUAL(db.hasKey(keyName11), false);
253 BOOST_CHECK_EQUAL(db.hasKey(keyName12), false);
254 BOOST_CHECK_EQUAL(db.hasKey(keyName21), true);
255 BOOST_CHECK_EQUAL(db.hasKey(keyName22), true);
256 BOOST_CHECK_EQUAL(deletedKeys.size(), 2);
257 BOOST_CHECK(std::find(deletedKeys.begin(), deletedKeys.end(), keyName11) !=
258 deletedKeys.end());
259 BOOST_CHECK(std::find(deletedKeys.begin(), deletedKeys.end(), keyName12) !=
260 deletedKeys.end());
261 BOOST_CHECK_EQUAL(deletedIds.size(), 1);
262 BOOST_CHECK_EQUAL(deletedIds[0], id1);
263}
264
265BOOST_AUTO_TEST_CASE(CertTest)
266{
267 db.identityDeleted.connect([this] (const Name& id) {
268 this->deletedIds.push_back(id);
269 });
270
271 db.keyDeleted.connect([this] (const Name& key) {
272 this->deletedKeys.push_back(key);
273 });
274
275 db.certificateDeleted.connect([this] (const Name& certificate) {
276 this->deletedCerts.push_back(certificate);
277 });
278
279 db.certificateInserted.connect([this] (const Name& certificate) {
280 this->insertedCerts.push_back(certificate);
281 });
282
283 // Initialize id1
284 Name id1("/test/identity");
285 addIdentity(id1);
286 Name certName111 = m_keyChain.getDefaultCertificateNameForIdentity(id1);
287 shared_ptr<IdentityCertificate> cert111 = m_keyChain.getCertificate(certName111);
288 Name keyName11 = cert111->getPublicKeyName();
289
290 advanceClocks(io, time::milliseconds(100));
291 shared_ptr<IdentityCertificate> cert112 = m_keyChain.selfSign(keyName11);
292 Name certName112 = cert112->getName();
293
294 advanceClocks(io, time::milliseconds(100));
295 Name keyName12 = m_keyChain.generateRsaKeyPairAsDefault(id1);
296 shared_ptr<IdentityCertificate> cert121 = m_keyChain.selfSign(keyName12);
297 Name certName121 = cert121->getName();
298
299 advanceClocks(io, time::milliseconds(100));
300 shared_ptr<IdentityCertificate> cert122 = m_keyChain.selfSign(keyName12);
301 Name certName122 = cert122->getName();
302
303 // Initialize id2
304 advanceClocks(io, time::milliseconds(100));
305 Name id2("/test/identity2");
306 addIdentity(id2);
307 Name certName211 = m_keyChain.getDefaultCertificateNameForIdentity(id2);
308 shared_ptr<IdentityCertificate> cert211 = m_keyChain.getCertificate(certName211);
309 Name keyName21 = cert211->getPublicKeyName();
310
311 advanceClocks(io, time::milliseconds(100));
312 shared_ptr<IdentityCertificate> cert212 = m_keyChain.selfSign(keyName21);
313 Name certName212 = cert212->getName();
314
315 advanceClocks(io, time::milliseconds(100));
316 Name keyName22 = m_keyChain.generateRsaKeyPairAsDefault(id2);
317 shared_ptr<IdentityCertificate> cert221 = m_keyChain.selfSign(keyName22);
318 Name certName221 = cert221->getName();
319
320 advanceClocks(io, time::milliseconds(100));
321 shared_ptr<IdentityCertificate> cert222 = m_keyChain.selfSign(keyName22);
322 Name certName222 = cert222->getName();
323
324 // Add a certificate
325 // This will also add the corresponding key and identity.
326 // Since there is no default setting before,
327 // The certificate will be set as the default one of the key, and so be the key and identity
328 BOOST_CHECK_EQUAL(db.hasCertificate(certName111), false);
329 BOOST_CHECK_EQUAL(db.hasKey(keyName11), false);
330 BOOST_CHECK_EQUAL(db.hasIdentity(id1), false);
331 BOOST_CHECK_EQUAL(db.getDefaultCertNameOfKey(keyName11), PibDb::NON_EXISTING_CERTIFICATE);
332 db.addCertificate(*cert111);
333 BOOST_CHECK_EQUAL(db.hasCertificate(certName111), true);
334 BOOST_CHECK_EQUAL(db.hasKey(keyName11), true);
335 BOOST_CHECK_EQUAL(db.hasIdentity(id1), true);
336 BOOST_CHECK_EQUAL(db.getDefaultIdentity(), id1);
337 BOOST_CHECK_EQUAL(db.getDefaultKeyNameOfIdentity(id1), keyName11);
338 BOOST_CHECK_EQUAL(db.getDefaultCertNameOfKey(keyName11), certName111);
339 BOOST_CHECK_EQUAL(insertedCerts.size(), 1);
340 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName111) !=
341 insertedCerts.end());
342 insertedCerts.clear();
343
344 // Add the second certificate of the same key
345 // Since default certificate already exists, no default setting changes.
346 BOOST_CHECK(db.getCertificate(certName112) == nullptr);
347 db.addCertificate(*cert112);
348 BOOST_CHECK(db.getCertificate(certName112) != nullptr);
349 BOOST_CHECK_EQUAL(db.getDefaultCertNameOfKey(keyName11), certName111);
350 BOOST_CHECK_EQUAL(insertedCerts.size(), 1);
351 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName112) !=
352 insertedCerts.end());
353 insertedCerts.clear();
354
355 // Explicitly set the second certificate as the default one of the key.
356 db.setDefaultCertNameOfKey(certName112);
357 BOOST_CHECK_EQUAL(db.getDefaultCertNameOfKey(keyName11), certName112);
358
359 // Delete the default certificate
360 // This will trigger certificateDeleted signal
361 // and also causes no default certificate for the key.
362 db.deleteCertificate(certName112);
363 BOOST_CHECK_EQUAL(db.hasCertificate(certName112), false);
364 BOOST_CHECK_EQUAL(db.hasCertificate(certName111), true);
365 BOOST_CHECK_EQUAL(deletedCerts.size(), 1);
366 BOOST_CHECK_EQUAL(deletedCerts[0], certName112);
367 BOOST_CHECK_EQUAL(db.getDefaultCertNameOfKey(keyName11), PibDb::NON_EXISTING_CERTIFICATE);
368 deletedCerts.clear();
369
370 // Add the second certificate back
371 // Since there is no default certificate of the key (though another certificate still exists),
372 // the new added certificate will be set as default
373 db.addCertificate(*cert112);
374 BOOST_CHECK(db.getCertificate(certName112) != nullptr);
375 BOOST_CHECK_EQUAL(db.getDefaultCertNameOfKey(keyName11), certName112);
376 insertedCerts.clear();
377
378 // Add entries for delete tests
379 db.addCertificate(*cert111); // already exists no certInserted signal emitted
380 db.addCertificate(*cert112); // already exists no certInserted signal emitted
381 db.addCertificate(*cert121);
382 db.addCertificate(*cert122);
383 db.addCertificate(*cert211);
384 db.addCertificate(*cert212);
385 db.addCertificate(*cert221);
386 db.addCertificate(*cert222);
387 BOOST_CHECK_EQUAL(insertedCerts.size(), 6);
388 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName121) !=
389 insertedCerts.end());
390 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName122) !=
391 insertedCerts.end());
392 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName211) !=
393 insertedCerts.end());
394 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName212) !=
395 insertedCerts.end());
396 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName221) !=
397 insertedCerts.end());
398 BOOST_CHECK(std::find(insertedCerts.begin(), insertedCerts.end(), certName222) !=
399 insertedCerts.end());
400 insertedCerts.clear();
401
402 // Delete the key.
403 // All the related certificates will be deleted as well.
404 db.deleteKey(keyName11);
405 BOOST_CHECK_EQUAL(db.hasCertificate(certName112), false);
406 BOOST_CHECK_EQUAL(db.hasCertificate(certName111), false);
407 BOOST_CHECK_EQUAL(db.hasCertificate(certName122), true);
408 BOOST_CHECK_EQUAL(db.hasCertificate(certName121), true);
409 BOOST_CHECK_EQUAL(db.hasCertificate(certName212), true);
410 BOOST_CHECK_EQUAL(db.hasCertificate(certName211), true);
411 BOOST_CHECK_EQUAL(db.hasCertificate(certName222), true);
412 BOOST_CHECK_EQUAL(db.hasCertificate(certName221), true);
413 BOOST_CHECK_EQUAL(db.hasKey(keyName11), false);
414 BOOST_CHECK_EQUAL(db.hasKey(keyName12), true);
415 BOOST_CHECK_EQUAL(db.hasKey(keyName21), true);
416 BOOST_CHECK_EQUAL(db.hasKey(keyName22), true);
417 BOOST_CHECK_EQUAL(deletedCerts.size(), 2);
418 BOOST_CHECK(std::find(deletedCerts.begin(), deletedCerts.end(), certName111) !=
419 deletedCerts.end());
420 BOOST_CHECK(std::find(deletedCerts.begin(), deletedCerts.end(), certName112) !=
421 deletedCerts.end());
422 BOOST_CHECK_EQUAL(deletedKeys.size(), 1);
423 BOOST_CHECK_EQUAL(deletedKeys[0], keyName11);
424 deletedCerts.clear();
425 deletedKeys.clear();
426
427 // Recover deleted entries
428 db.addCertificate(*cert111);
429 db.addCertificate(*cert112);
430
431 // Delete the identity
432 // All the related certificates and keys will be deleted as well.
433 BOOST_CHECK_EQUAL(db.hasCertificate(certName111), true);
434 BOOST_CHECK_EQUAL(db.hasCertificate(certName112), true);
435 BOOST_CHECK_EQUAL(db.hasKey(keyName11), true);
436 BOOST_CHECK_EQUAL(db.hasIdentity(id1), true);
437 db.deleteIdentity(id1);
438 BOOST_CHECK_EQUAL(db.hasCertificate(certName112), false);
439 BOOST_CHECK_EQUAL(db.hasCertificate(certName111), false);
440 BOOST_CHECK_EQUAL(db.hasCertificate(certName122), false);
441 BOOST_CHECK_EQUAL(db.hasCertificate(certName121), false);
442 BOOST_CHECK_EQUAL(db.hasCertificate(certName212), true);
443 BOOST_CHECK_EQUAL(db.hasCertificate(certName211), true);
444 BOOST_CHECK_EQUAL(db.hasCertificate(certName222), true);
445 BOOST_CHECK_EQUAL(db.hasCertificate(certName221), true);
446 BOOST_CHECK_EQUAL(db.hasKey(keyName11), false);
447 BOOST_CHECK_EQUAL(db.hasKey(keyName12), false);
448 BOOST_CHECK_EQUAL(db.hasKey(keyName21), true);
449 BOOST_CHECK_EQUAL(db.hasKey(keyName22), true);
450 BOOST_CHECK_EQUAL(db.hasIdentity(id1), false);
451 BOOST_CHECK_EQUAL(db.hasIdentity(id2), true);
452 BOOST_CHECK_EQUAL(deletedCerts.size(), 4);
453 BOOST_CHECK(std::find(deletedCerts.begin(), deletedCerts.end(), certName111) !=
454 deletedCerts.end());
455 BOOST_CHECK(std::find(deletedCerts.begin(), deletedCerts.end(), certName112) !=
456 deletedCerts.end());
457 BOOST_CHECK(std::find(deletedCerts.begin(), deletedCerts.end(), certName121) !=
458 deletedCerts.end());
459 BOOST_CHECK(std::find(deletedCerts.begin(), deletedCerts.end(), certName122) !=
460 deletedCerts.end());
461 BOOST_CHECK_EQUAL(deletedKeys.size(), 2);
462 BOOST_CHECK(std::find(deletedKeys.begin(), deletedKeys.end(), keyName11) !=
463 deletedKeys.end());
464 BOOST_CHECK(std::find(deletedKeys.begin(), deletedKeys.end(), keyName12) !=
465 deletedCerts.end());
466 BOOST_CHECK_EQUAL(deletedIds.size(), 1);
467 BOOST_CHECK_EQUAL(deletedIds[0], id1);
468}
469
Davide Pesavento013de9b2016-09-01 12:06:56 +0000470BOOST_AUTO_TEST_SUITE_END() // TestPibDb
471BOOST_AUTO_TEST_SUITE_END() // Pib
Yingdi Yu77627ab2015-07-21 16:13:49 -0700472
473} // namespace tests
474} // namespace pib
475} // namespace ndn