clients: Change iterative-query-controller to use Link
Change-Id: I3b4fe73a467fb38c4fcde87481d1f84ec19c16c0
diff --git a/tests/unit/clients/iterative-query-controller.cpp b/tests/unit/clients/iterative-query-controller.cpp
index 16087e5..308683e 100644
--- a/tests/unit/clients/iterative-query-controller.cpp
+++ b/tests/unit/clients/iterative-query-controller.cpp
@@ -34,7 +34,7 @@
public:
QueryControllerFixture()
: producerFace(io, {false, true})
- , consumerFace(io, {false, true})
+ , consumerFace(io, {true, true})
, validator(producerFace)
, top(m_root.getName(), m_certName, producerFace, m_session, m_keyChain, validator)
, net(m_net.getName(), m_certName, producerFace, m_session, m_keyChain, validator)
@@ -76,6 +76,8 @@
BOOST_AUTO_TEST_SUITE(IterativeQueryController)
+BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(Basic, 3)
+
BOOST_FIXTURE_TEST_CASE(Basic, QueryControllerFixture)
{
using std::string;
@@ -106,7 +108,31 @@
ctr->start();
run();
+
BOOST_CHECK_EQUAL(hasDataBack, true);
+
+ const std::vector<Interest>& interestRx = consumerFace.sentInterests;
+ BOOST_CHECK_EQUAL(interestRx.size(), 4);
+
+ std::vector<std::string> interestNames =
+ {
+ "/test19/NDNS/net/NS",
+ "/test19/net/NDNS/ndnsim/NS",
+ "/test19/net/ndnsim/NDNS/www/NS",
+ "/test19/net/ndnsim/NDNS/www/TXT"
+ };
+ for (int i = 0; i < 4; i++) {
+ // check if NDNS do iterative-query with right names
+ BOOST_CHECK_EQUAL(interestRx[i].getName(), Name(interestNames[i]));
+ // except for the first one, interest sent should has a Link object
+ if (i > 0) {
+ BOOST_CHECK_EQUAL(interestRx[i].hasLink(), true);
+ if (interestRx[i].hasLink()) {
+ BOOST_CHECK_EQUAL(interestRx[i].getLink(), m_links[i - 1]);
+ }
+ }
+ }
+
}
BOOST_AUTO_TEST_SUITE_END()
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);