blob: 69cef48ccaaa51f27f6354b9faaf5c4cb5b64775 [file] [log] [blame]
Alexander Afanasyev6dfeffe2017-01-30 22:40:32 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
Davide Pesavento74daf742018-11-23 18:14:13 -05003 * Copyright (c) 2013-2018 Regents of the University of California.
Alexander Afanasyev6dfeffe2017-01-30 22:40:32 -08004 *
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 Shi2bea5c42017-08-14 20:10:32 +000026#include "make-interest-data.hpp"
Alexander Afanasyev6dfeffe2017-01-30 22:40:32 -080027
28namespace ndn {
29namespace security {
30namespace tests {
31
32using namespace ndn::tests;
33
34BOOST_AUTO_TEST_SUITE(Security)
35BOOST_FIXTURE_TEST_SUITE(TestValidatorNull, IdentityManagementFixture)
36
37BOOST_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
49BOOST_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
61BOOST_AUTO_TEST_SUITE_END() // TestValidatorNull
62BOOST_AUTO_TEST_SUITE_END() // Security
63
64} // namespace tests
65} // namespace security
66} // namespace ndn