security: Fix a bug of Validator, making checkPolicy methods pure abstract
This commit also includes fixes to unit tests.
Change-Id: If92569fc9dabaa08714d458e5195b6a83acb8701
diff --git a/tests/test-validator.cpp b/tests/test-validator.cpp
new file mode 100644
index 0000000..1b24a3d
--- /dev/null
+++ b/tests/test-validator.cpp
@@ -0,0 +1,51 @@
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi0@cs.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include "security/validator-null.hpp"
+#include "security/key-chain.hpp"
+#include "util/time.hpp"
+
+
+using namespace std;
+
+namespace ndn {
+
+BOOST_AUTO_TEST_SUITE(TestValidator)
+
+void
+onValidated(const shared_ptr<const Data>& data)
+{ BOOST_CHECK(true); }
+
+void
+onValidationFailed(const shared_ptr<const Data>& data)
+{ BOOST_CHECK(false); }
+
+BOOST_AUTO_TEST_CASE (Null)
+{
+ KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
+ Name identity(string("/TestValidator/Null/") + boost::lexical_cast<std::string>(time::now()));
+ keyChain.createIdentity(identity);
+
+ Name dataName = identity;
+ dataName.append("1");
+ shared_ptr<Data> data = make_shared<Data>(dataName);
+
+ keyChain.signByIdentity(*data, identity);
+
+ ValidatorNull validator;
+
+ validator.validate(data,
+ bind(&onValidated, _1),
+ bind(&onValidationFailed, _1));
+
+ keyChain.deleteIdentity(identity);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn