clients: Change iterative-query-controller to use Link
Change-Id: I3b4fe73a467fb38c4fcde87481d1f84ec19c16c0
diff --git a/tests/unit/clients/query.cpp b/tests/unit/clients/query.cpp
index 0e4a1e4..c57be49 100644
--- a/tests/unit/clients/query.cpp
+++ b/tests/unit/clients/query.cpp
@@ -21,14 +21,19 @@
#include "test-common.hpp"
+#include <boost/lexical_cast.hpp>
+#include <string>
+#include <ndn-cxx/security/key-chain.hpp>
+
namespace ndn {
namespace ndns {
namespace tests {
BOOST_AUTO_TEST_SUITE(Query)
-BOOST_AUTO_TEST_CASE(TestCase)
+BOOST_FIXTURE_TEST_CASE(TestCase, IdentityManagementFixture)
{
+ Name certName = m_keyChain.createIdentity("/cert/name");
Name zone("/net");
name::Component qType = ndns::label::NDNS_ITERATIVE_QUERY;
ndns::Query q(zone, qType);
@@ -42,7 +47,18 @@
q.setRrType(ndns::label::CERT_RR_TYPE);
BOOST_CHECK_EQUAL(q.getRrType(), label::CERT_RR_TYPE);
+ auto link = make_shared<Link>("/ndn/link/NDNS/test/NS");
+ for (int i = 1; i <= 5; i++) {
+ link->addDelegation(i, std::string("/link/") + to_string(i));
+ }
+ // link has to be signed first, then wireDecode
+ m_keyChain.sign(*link, certName);
+
+ q.setLink(link->wireEncode());
+ BOOST_CHECK_EQUAL(Link(q.getLink()), *link);
+
Interest interest = q.toInterest();
+ BOOST_CHECK_EQUAL(interest.getLink(), *link);
ndns::Query q2(zone, qType);
BOOST_CHECK_EQUAL(q2.fromInterest(zone, interest), true);