Update validation related codes to security v2

Change-Id: I5467b87092820666c04f22623f0f1665ce9a1194
diff --git a/tests/unit/clients/iterative-query-controller.cpp b/tests/unit/clients/iterative-query-controller.cpp
index 453e743..307ce8b 100644
--- a/tests/unit/clients/iterative-query-controller.cpp
+++ b/tests/unit/clients/iterative-query-controller.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -35,10 +35,10 @@
   QueryControllerFixture()
     : producerFace(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)
-    , ndnsim(m_ndnsim.getName(), m_certName, producerFace, m_session, m_keyChain, validator)
+    , validator(NdnsValidatorBuilder::create(producerFace))
+    , top(m_test.getName(), m_certName, producerFace, m_session, m_keyChain, *validator)
+    , net(m_net.getName(), m_certName, producerFace, m_session, m_keyChain, *validator)
+    , ndnsim(m_ndnsim.getName(), m_certName, producerFace, m_session, m_keyChain, *validator)
   {
     run();
     producerFace.onSendInterest.connect([this] (const Interest& interest) {
@@ -67,7 +67,7 @@
   ndn::util::DummyClientFace producerFace;
   ndn::util::DummyClientFace consumerFace;
 
-  Validator validator;
+  unique_ptr<security::v2::Validator> validator;
   ndns::NameServer top;
   ndns::NameServer net;
   ndns::NameServer ndnsim;
@@ -124,9 +124,9 @@
     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_CHECK_EQUAL(!interestRx[i].getForwardingHint().empty(), true);
+      if (!interestRx[i].getForwardingHint().empty()) {
+        BOOST_CHECK_EQUAL(interestRx[i].getForwardingHint(), m_links[i - 1].getDelegationList());
       }
     }
   }
diff --git a/tests/unit/clients/query.cpp b/tests/unit/clients/query.cpp
index c57be49..f7ed478 100644
--- a/tests/unit/clients/query.cpp
+++ b/tests/unit/clients/query.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016, Regents of the University of California.
+/*
+ * Copyright (c) 2014-2017, Regents of the University of California.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -23,7 +23,6 @@
 
 #include <boost/lexical_cast.hpp>
 #include <string>
-#include <ndn-cxx/security/key-chain.hpp>
 
 namespace ndn {
 namespace ndns {
@@ -33,7 +32,7 @@
 
 BOOST_FIXTURE_TEST_CASE(TestCase, IdentityManagementFixture)
 {
-  Name certName = m_keyChain.createIdentity("/cert/name");
+  security::Identity certIdentity = addIdentity("/cert/name");
   Name zone("/net");
   name::Component qType = ndns::label::NDNS_ITERATIVE_QUERY;
   ndns::Query q(zone, qType);
@@ -52,13 +51,13 @@
     link->addDelegation(i, std::string("/link/") + to_string(i));
   }
   // link has to be signed first, then wireDecode
-  m_keyChain.sign(*link, certName);
+  m_keyChain.sign(*link, security::signingByIdentity(certIdentity));
 
-  q.setLink(link->wireEncode());
-  BOOST_CHECK_EQUAL(Link(q.getLink()), *link);
+  q.setDelegationListFromLink(*link);
+  BOOST_CHECK_EQUAL(q.getDelegationList(), link->getDelegationList());
 
   Interest interest = q.toInterest();
-  BOOST_CHECK_EQUAL(interest.getLink(), *link);
+  BOOST_CHECK_EQUAL(interest.getForwardingHint(), link->getDelegationList());
 
   ndns::Query q2(zone, qType);
   BOOST_CHECK_EQUAL(q2.fromInterest(zone, interest), true);