security: Adding supports to signed interest
refs: #1161
Change-Id: I042381b171d44417f296397d872cd639935a89e9
diff --git a/tests/test-signed-interest.cpp b/tests/test-signed-interest.cpp
new file mode 100644
index 0000000..5c7e684
--- /dev/null
+++ b/tests/test-signed-interest.cpp
@@ -0,0 +1,40 @@
+/**
+ * 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/key-chain.hpp"
+#include "security/verifier.hpp"
+#include <iostream>
+
+using namespace std;
+using namespace ndn;
+
+
+BOOST_AUTO_TEST_SUITE(TestSignedInterest)
+
+BOOST_AUTO_TEST_CASE (SignVerify)
+{
+ KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
+
+ Name identityName("/test");
+ Name keyName = keyChain.createIdentity(identityName);
+
+ Interest interest("/test/interest");
+ keyChain.signByIdentity(interest, identityName);
+
+ Block interestBlock(interest.wireEncode().wire(), interest.wireEncode().size());
+
+ Interest interest2;
+ interest2.wireDecode(interestBlock);
+
+ ptr_lib::shared_ptr<PublicKey> publicKey = keyChain.getPublicKeyFromTpm(keyName);
+ bool result = Verifier::verifySignature(interest2, *publicKey);
+
+ BOOST_REQUIRE_EQUAL(result, true);
+}
+
+BOOST_AUTO_TEST_SUITE_END()