Alexander Afanasyev | 6dfeffe | 2017-01-30 22:40:32 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 6 | * |
| 7 | * 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. |
| 20 | */ |
| 21 | |
| 22 | #include "security/validator-null.hpp" |
| 23 | |
| 24 | #include "boost-test.hpp" |
| 25 | #include "identity-management-fixture.hpp" |
Junxiao Shi | 2bea5c4 | 2017-08-14 20:10:32 +0000 | [diff] [blame] | 26 | #include "make-interest-data.hpp" |
Alexander Afanasyev | 6dfeffe | 2017-01-30 22:40:32 -0800 | [diff] [blame] | 27 | |
| 28 | namespace ndn { |
| 29 | namespace security { |
| 30 | namespace tests { |
| 31 | |
| 32 | using namespace ndn::tests; |
| 33 | |
| 34 | BOOST_AUTO_TEST_SUITE(Security) |
| 35 | BOOST_FIXTURE_TEST_SUITE(TestValidatorNull, IdentityManagementFixture) |
| 36 | |
| 37 | BOOST_AUTO_TEST_CASE(ValidateData) |
| 38 | { |
| 39 | auto identity = addIdentity("/TestValidator/Null"); |
| 40 | Data data("/Some/Other/Data/Name"); |
| 41 | m_keyChain.sign(data, signingByIdentity(identity)); |
| 42 | |
| 43 | ValidatorNull validator; |
| 44 | validator.validate(data, |
| 45 | bind([] { BOOST_CHECK_MESSAGE(true, "Validation should succeed"); }), |
| 46 | bind([] { BOOST_CHECK_MESSAGE(false, "Validation should not have failed"); })); |
| 47 | } |
| 48 | |
| 49 | BOOST_AUTO_TEST_CASE(ValidateInterest) |
| 50 | { |
| 51 | auto identity = addIdentity("/TestValidator/Null"); |
| 52 | Interest interest("/Some/Other/Interest/Name"); |
| 53 | m_keyChain.sign(interest, signingByIdentity(identity)); |
| 54 | |
| 55 | ValidatorNull validator; |
| 56 | validator.validate(interest, |
| 57 | bind([] { BOOST_CHECK_MESSAGE(true, "Validation should succeed"); }), |
| 58 | bind([] { BOOST_CHECK_MESSAGE(false, "Validation should not have failed"); })); |
| 59 | } |
| 60 | |
| 61 | BOOST_AUTO_TEST_SUITE_END() // TestValidatorNull |
| 62 | BOOST_AUTO_TEST_SUITE_END() // Security |
| 63 | |
| 64 | } // namespace tests |
| 65 | } // namespace security |
| 66 | } // namespace ndn |