blob: 19e2b7812f9c724e28e0919b65cd86f317eb39bd [file] [log] [blame]
Yingdi Yu9a335352014-01-31 11:57:46 -08001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Yingdi Yu <yingdi0@cs.ucla.edu>
4 * See COPYING for copyright and distribution information.
5 */
6
7#include <boost/test/unit_test.hpp>
8
9#include "security/validator-null.hpp"
10#include "security/key-chain.hpp"
11#include "util/time.hpp"
12
13
14using namespace std;
15
16namespace ndn {
17
18BOOST_AUTO_TEST_SUITE(TestValidator)
19
20void
21onValidated(const shared_ptr<const Data>& data)
22{ BOOST_CHECK(true); }
23
24void
25onValidationFailed(const shared_ptr<const Data>& data)
26{ BOOST_CHECK(false); }
27
28BOOST_AUTO_TEST_CASE (Null)
29{
30 KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
31 Name identity(string("/TestValidator/Null/") + boost::lexical_cast<std::string>(time::now()));
32 keyChain.createIdentity(identity);
33
34 Name dataName = identity;
35 dataName.append("1");
36 shared_ptr<Data> data = make_shared<Data>(dataName);
37
38 keyChain.signByIdentity(*data, identity);
39
40 ValidatorNull validator;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080041
42 // data must be a shared pointer
43 validator.validate(*data,
Yingdi Yu9a335352014-01-31 11:57:46 -080044 bind(&onValidated, _1),
45 bind(&onValidationFailed, _1));
46
47 keyChain.deleteIdentity(identity);
48}
49
50BOOST_AUTO_TEST_SUITE_END()
51
52} // namespace ndn