Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2012 University of California, Los Angeles |
| 4 | */ |
| 5 | |
| 6 | #include <boost/test/unit_test.hpp> |
| 7 | #include "sync-validator.h" |
| 8 | |
| 9 | BOOST_AUTO_TEST_SUITE(TestSyncValidator) |
| 10 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 11 | void |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 12 | onValidated(const ndn::shared_ptr<const ndn::Data>& data) |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 13 | { |
| 14 | BOOST_CHECK(true); |
| 15 | } |
| 16 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 17 | void |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 18 | onValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, |
| 19 | const std::string& failureInfo) |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 20 | { |
| 21 | BOOST_CHECK(false); |
| 22 | } |
| 23 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 24 | void |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 25 | onValidated2(const ndn::shared_ptr<const ndn::Data>& data) |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 26 | { |
| 27 | BOOST_CHECK(false); |
| 28 | } |
| 29 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 30 | void |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 31 | onValidationFailed2(const ndn::shared_ptr<const ndn::Data>& data, |
| 32 | const std::string& failureInfo) |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 33 | { |
| 34 | BOOST_CHECK(true); |
| 35 | } |
| 36 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 37 | void |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 38 | publishData(const uint8_t* buf, size_t len, int freshness) |
| 39 | { |
| 40 | } |
| 41 | |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 42 | BOOST_AUTO_TEST_CASE (Graph) |
| 43 | { |
| 44 | using namespace Sync; |
| 45 | using namespace ndn; |
| 46 | |
| 47 | Name prefix("/Sync/TestSyncValidator/AddEdge"); |
| 48 | KeyChain keychain; |
| 49 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 50 | Name identity1("/TestSyncValidator/AddEdge-1/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 51 | Name certName1 = keychain.createIdentity(identity1); |
| 52 | shared_ptr<IdentityCertificate> anchor = keychain.getCertificate(certName1); |
| 53 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 54 | Name identity2("/TestSyncValidator/AddEdge-2/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 55 | Name certName2 = keychain.createIdentity(identity2); |
| 56 | shared_ptr<IdentityCertificate> introducer = keychain.getCertificate(certName2); |
| 57 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 58 | Name identity3("/TestSyncValidator/AddEdge-3/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 59 | Name certName3 = keychain.createIdentity(identity3); |
| 60 | shared_ptr<IdentityCertificate> introducee = keychain.getCertificate(certName3); |
| 61 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 62 | Name identity4("/TestSyncValidator/AddEdge-4/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 63 | Name certName4 = keychain.createIdentity(identity4); |
| 64 | shared_ptr<IdentityCertificate> introducer2 = keychain.getCertificate(certName4); |
| 65 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 66 | Name identity5("/TestSyncValidator/AddEdge-5/" + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 67 | Name certName5 = keychain.createIdentity(identity5); |
| 68 | shared_ptr<IdentityCertificate> introducee2 = keychain.getCertificate(certName5); |
| 69 | |
| 70 | shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>(); |
| 71 | shared_ptr<Face> face = make_shared<Face>(ioService); |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 72 | shared_ptr<SecRuleRelative> rule; |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 73 | SyncValidator validator(prefix, *anchor, *face, |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 74 | bind(&publishData, _1, _2, _3), |
| 75 | rule); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 76 | |
| 77 | validator.addParticipant(*introducer); |
| 78 | BOOST_CHECK(validator.canTrust(certName2)); |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 79 | |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 80 | IntroCertificate introCert(prefix, *introducee, certName2.getPrefix(-1)); |
| 81 | keychain.sign(introCert, certName2); |
| 82 | validator.addParticipant(introCert); |
| 83 | BOOST_CHECK(validator.canTrust(certName3)); |
| 84 | |
| 85 | IntroCertificate introCert1(prefix, *anchor, certName3.getPrefix(-1)); |
| 86 | keychain.sign(introCert1, certName3); |
| 87 | validator.addParticipant(introCert1); |
| 88 | validator.setAnchor(*introducer); |
| 89 | BOOST_CHECK(validator.canTrust(certName2)); |
| 90 | BOOST_CHECK(validator.canTrust(certName3)); |
| 91 | BOOST_CHECK(validator.canTrust(certName1)); |
| 92 | |
| 93 | IntroCertificate introCert2(prefix, *introducee2, certName4.getPrefix(-1)); |
| 94 | keychain.sign(introCert2, certName4); |
| 95 | validator.addParticipant(introCert2); |
| 96 | BOOST_CHECK(validator.canTrust(certName5) == false); |
| 97 | BOOST_CHECK(validator.canTrust(certName4) == false); |
| 98 | |
| 99 | IntroCertificate introCert3(prefix, *introducee, certName5.getPrefix(-1)); |
| 100 | keychain.sign(introCert3, certName5); |
| 101 | validator.addParticipant(introCert3); |
| 102 | BOOST_CHECK(validator.canTrust(certName5) == false); |
| 103 | BOOST_CHECK(validator.canTrust(certName4) == false); |
| 104 | |
| 105 | validator.setAnchor(*introducee2); |
| 106 | BOOST_CHECK(validator.canTrust(certName1)); |
| 107 | BOOST_CHECK(validator.canTrust(certName2)); |
| 108 | BOOST_CHECK(validator.canTrust(certName3)); |
| 109 | BOOST_CHECK(validator.canTrust(certName4) == false); |
| 110 | BOOST_CHECK(validator.canTrust(certName5)); |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 111 | |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 112 | |
| 113 | keychain.deleteIdentity(identity1); |
| 114 | keychain.deleteIdentity(identity2); |
| 115 | keychain.deleteIdentity(identity3); |
| 116 | keychain.deleteIdentity(identity4); |
| 117 | keychain.deleteIdentity(identity5); |
| 118 | } |
| 119 | |
| 120 | BOOST_AUTO_TEST_CASE (OfflineValidate) |
| 121 | { |
| 122 | using namespace Sync; |
| 123 | using namespace ndn; |
| 124 | |
| 125 | Name prefix("/Sync/TestSyncValidator/OfflineValidate"); |
| 126 | KeyChain keychain; |
| 127 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 128 | Name identity1("/TestSyncValidator/OfflineValidate-1/" |
| 129 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 130 | Name certName1 = keychain.createIdentity(identity1); |
| 131 | shared_ptr<IdentityCertificate> anchor = keychain.getCertificate(certName1); |
| 132 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 133 | Name identity2("/TestSyncValidator/OfflineValidate-2/" |
| 134 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 135 | Name certName2 = keychain.createIdentity(identity2); |
| 136 | shared_ptr<IdentityCertificate> introducer = keychain.getCertificate(certName2); |
| 137 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 138 | Name identity3("/TestSyncValidator/OfflineValidate-3/" |
| 139 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 140 | Name certName3 = keychain.createIdentity(identity3); |
| 141 | shared_ptr<IdentityCertificate> introducee = keychain.getCertificate(certName3); |
| 142 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 143 | Name identity4("/TestSyncValidator/OfflineValidate-4/" |
| 144 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 145 | Name certName4 = keychain.createIdentity(identity4); |
| 146 | shared_ptr<IdentityCertificate> introducer2 = keychain.getCertificate(certName4); |
| 147 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 148 | Name identity5("/TestSyncValidator/OfflineValidate-5/" |
| 149 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 150 | Name certName5 = keychain.createIdentity(identity5); |
| 151 | shared_ptr<IdentityCertificate> introducee2 = keychain.getCertificate(certName5); |
| 152 | |
| 153 | shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>(); |
| 154 | shared_ptr<Face> face = make_shared<Face>(ioService); |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 155 | shared_ptr<SecRuleRelative> rule; |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 156 | SyncValidator validator(prefix, *anchor, *face, |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 157 | bind(&publishData, _1, _2, _3), |
| 158 | rule); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 159 | |
| 160 | validator.addParticipant(*introducer); |
| 161 | BOOST_CHECK(validator.canTrust(certName2)); |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 162 | |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 163 | IntroCertificate introCert(prefix, *introducee, certName2.getPrefix(-1)); |
| 164 | keychain.sign(introCert, certName2); |
| 165 | validator.addParticipant(introCert); |
| 166 | BOOST_CHECK(validator.canTrust(certName3)); |
| 167 | |
| 168 | IntroCertificate introCert2(prefix, *introducee2, certName4.getPrefix(-1)); |
| 169 | keychain.sign(introCert2, certName4); |
| 170 | validator.addParticipant(introCert2); |
| 171 | BOOST_CHECK(validator.canTrust(certName5) == false); |
| 172 | BOOST_CHECK(validator.canTrust(certName4) == false); |
| 173 | |
| 174 | validator.setAnchor(*introducer2); |
| 175 | BOOST_CHECK(validator.canTrust(certName1) == false); |
| 176 | BOOST_CHECK(validator.canTrust(certName2) == false); |
| 177 | BOOST_CHECK(validator.canTrust(certName3) == false); |
| 178 | BOOST_CHECK(validator.canTrust(certName4)); |
| 179 | BOOST_CHECK(validator.canTrust(certName5)); |
| 180 | |
| 181 | Name dataName1 = prefix; |
| 182 | dataName1.append("data-1"); |
| 183 | shared_ptr<Data> data1 = make_shared<Data>(dataName1); |
| 184 | keychain.sign(*data1, certName5); |
| 185 | |
| 186 | validator.validate(*data1, |
| 187 | bind(&onValidated, _1), |
| 188 | bind(&onValidationFailed, _1, _2)); |
| 189 | |
| 190 | Name dataName2 = prefix; |
| 191 | dataName2.append("data-2"); |
| 192 | shared_ptr<Data> data2 = make_shared<Data>(dataName2); |
| 193 | keychain.sign(*data2, certName1); |
| 194 | |
| 195 | validator.validate(*data2, |
| 196 | bind(&onValidated2, _1), |
| 197 | bind(&onValidationFailed2, _1, _2)); |
| 198 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 199 | // ioService->run(); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 200 | |
| 201 | keychain.deleteIdentity(identity1); |
| 202 | keychain.deleteIdentity(identity2); |
| 203 | keychain.deleteIdentity(identity3); |
| 204 | keychain.deleteIdentity(identity4); |
| 205 | keychain.deleteIdentity(identity5); |
| 206 | } |
| 207 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 208 | struct FacesFixture |
| 209 | { |
| 210 | FacesFixture() |
| 211 | : regPrefixId(0) |
| 212 | , regPrefixId2(0) |
| 213 | {} |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 214 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 215 | void |
| 216 | onInterest(ndn::shared_ptr<ndn::Face> face, ndn::shared_ptr<ndn::Data> data) |
| 217 | { |
| 218 | face->put(*data); |
| 219 | face->unsetInterestFilter(regPrefixId); |
| 220 | } |
| 221 | |
| 222 | void |
| 223 | onInterest2(ndn::shared_ptr<ndn::Face> face, ndn::shared_ptr<ndn::Data> data) |
| 224 | { |
| 225 | face->put(*data); |
| 226 | face->unsetInterestFilter(regPrefixId2); |
| 227 | } |
| 228 | |
| 229 | void |
| 230 | onRegFailed() |
| 231 | {} |
| 232 | |
| 233 | void |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 234 | validate(ndn::shared_ptr<Sync::SyncValidator> validator, ndn::shared_ptr<ndn::Data> data, |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 235 | const ndn::Name& certName3, const ndn::Name& certName4) |
| 236 | { |
| 237 | validator->validate(*data, |
| 238 | bind(&onValidated, _1), |
| 239 | bind(&onValidationFailed, _1, _2)); |
| 240 | |
| 241 | |
| 242 | BOOST_CHECK(validator->canTrust(certName3)); |
| 243 | BOOST_CHECK(validator->canTrust(certName4)); |
| 244 | } |
| 245 | |
| 246 | void |
| 247 | terminate(ndn::shared_ptr<ndn::Face> face) |
| 248 | { |
| 249 | face->ioService()->stop(); |
| 250 | } |
| 251 | |
| 252 | const ndn::RegisteredPrefixId* regPrefixId; |
| 253 | const ndn::RegisteredPrefixId* regPrefixId2; |
| 254 | }; |
| 255 | |
| 256 | BOOST_FIXTURE_TEST_CASE(OnlineValidate, FacesFixture) |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 257 | { |
| 258 | using namespace Sync; |
| 259 | using namespace ndn; |
| 260 | |
| 261 | Name prefix("/Sync/TestSyncValidator/OnlineValidate"); |
| 262 | KeyChain keychain; |
| 263 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 264 | Name identity1("/TestSyncValidator/OnlineValidate-1/" |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 265 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 266 | Name certName1 = keychain.createIdentity(identity1); |
| 267 | shared_ptr<IdentityCertificate> anchor = keychain.getCertificate(certName1); |
| 268 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 269 | Name identity2("/TestSyncValidator/OnlineValidate-2/" |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 270 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 271 | Name certName2 = keychain.createIdentity(identity2); |
| 272 | shared_ptr<IdentityCertificate> introducer = keychain.getCertificate(certName2); |
| 273 | |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 274 | Name identity3("/TestSyncValidator/OnlineValidate-3/" |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 275 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 276 | Name certName3 = keychain.createIdentity(identity3); |
| 277 | shared_ptr<IdentityCertificate> introducee = keychain.getCertificate(certName3); |
| 278 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 279 | Name identity4("/TestSyncValidator/OnlineValidate-4/" |
| 280 | + boost::lexical_cast<std::string>(ndn::time::toUnixTimestamp(ndn::time::system_clock::now()).count())); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 281 | Name certName4 = keychain.createIdentity(identity4); |
| 282 | shared_ptr<IdentityCertificate> introducee2 = keychain.getCertificate(certName4); |
| 283 | |
| 284 | shared_ptr<boost::asio::io_service> ioService = make_shared<boost::asio::io_service>(); |
| 285 | shared_ptr<Face> face = make_shared<Face>(ioService); |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 286 | shared_ptr<Face> face2 = make_shared<Face>(ioService); |
| 287 | |
Yingdi Yu | 3da10fe | 2014-02-27 16:37:34 -0800 | [diff] [blame] | 288 | shared_ptr<SecRuleRelative> rule; |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 289 | shared_ptr<SyncValidator> validator = shared_ptr<SyncValidator> |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 290 | (new SyncValidator(prefix, *anchor, *face2, bind(&publishData, _1, _2, _3), rule)); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 291 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 292 | validator->addParticipant(*introducer); |
| 293 | BOOST_CHECK(validator->canTrust(certName2)); |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 294 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 295 | shared_ptr<IntroCertificate> introCert = shared_ptr<IntroCertificate>(new IntroCertificate(prefix, *introducee, certName2.getPrefix(-1))); |
| 296 | keychain.sign(*introCert, certName2); |
| 297 | BOOST_CHECK(validator->canTrust(certName3) == false); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 298 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 299 | shared_ptr<IntroCertificate> introCert2 = shared_ptr<IntroCertificate>(new IntroCertificate(prefix, *introducee2, certName3.getPrefix(-1))); |
| 300 | keychain.sign(*introCert2, certName3); |
| 301 | BOOST_CHECK(validator->canTrust(certName4) == false); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 302 | |
| 303 | Name dataName1 = prefix; |
| 304 | dataName1.append("data-1"); |
| 305 | shared_ptr<Data> data1 = make_shared<Data>(dataName1); |
| 306 | keychain.sign(*data1, certName4); |
| 307 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 308 | ndn::Scheduler scheduler(*ioService); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 309 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 310 | scheduler.scheduleEvent(time::seconds(1), |
| 311 | bind(&FacesFixture::terminate, this, face)); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 312 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 313 | regPrefixId = face->setInterestFilter(introCert->getName().getPrefix(-1), |
| 314 | bind(&FacesFixture::onInterest, this, face, introCert), |
| 315 | bind(&FacesFixture::onRegFailed, this)); |
Yingdi Yu | a873d64 | 2014-04-15 21:31:33 -0700 | [diff] [blame] | 316 | |
Yingdi Yu | 6e1c9cd | 2014-03-25 10:26:54 -0700 | [diff] [blame] | 317 | regPrefixId2 = face->setInterestFilter(introCert2->getName().getPrefix(-1), |
| 318 | bind(&FacesFixture::onInterest2, this, face, introCert2), |
| 319 | bind(&FacesFixture::onRegFailed, this)); |
| 320 | |
| 321 | scheduler.scheduleEvent(time::milliseconds(200), |
| 322 | bind(&FacesFixture::validate, this, |
| 323 | validator, data1, certName3, certName4)); |
Yingdi Yu | 0eee600 | 2014-02-11 15:54:17 -0800 | [diff] [blame] | 324 | |
| 325 | keychain.deleteIdentity(identity1); |
| 326 | keychain.deleteIdentity(identity2); |
| 327 | keychain.deleteIdentity(identity3); |
| 328 | keychain.deleteIdentity(identity4); |
| 329 | } |
| 330 | |
| 331 | BOOST_AUTO_TEST_SUITE_END() |