switch to ndn-cxx KeyChain v2

ValidatorConfig is temporarily disabled. All commands are
authorized without validation.

refs #4091

Change-Id: I4eea8cd954761424d2d084bda4e8510320b5fb46
diff --git a/tests/integrated/test-basic-command-watch.cpp b/tests/integrated/test-basic-command-watch.cpp
index 8c4c13e..8b8f327 100644
--- a/tests/integrated/test-basic-command-watch.cpp
+++ b/tests/integrated/test-basic-command-watch.cpp
@@ -19,13 +19,12 @@
 
 #include "handles/watch-handle.hpp"
 #include "storage/sqlite-storage.hpp"
-#include "common.hpp"
 
+#include "command-fixture.hpp"
 #include "../repo-storage-fixture.hpp"
 #include "../dataset-fixtures.hpp"
 
 #include <ndn-cxx/util/random.hpp>
-#include <ndn-cxx/util/io.hpp>
 
 #include <boost/test/unit_test.hpp>
 #include <fstream>
@@ -44,26 +43,16 @@
 const static uint8_t content[8] = {3, 1, 4, 1, 5, 9, 2, 6};
 
 template<class Dataset>
-class Fixture : public RepoStorageFixture, public Dataset
+class Fixture : public CommandFixture, public RepoStorageFixture, public Dataset
 {
 public:
   Fixture()
-    : scheduler(repoFace.getIoService())
-    , validator(repoFace)
-    , watchHandle(repoFace, *handle, keyChain, scheduler, validator)
+    : watchHandle(repoFace, *handle, keyChain, scheduler, validator)
     , watchFace(repoFace.getIoService())
   {
     watchHandle.listen(Name("/repo/command"));
   }
 
-  ~Fixture()
-  {
-    repoFace.getIoService().stop();
-  }
-
-  void
-  generateDefaultCertificateFile();
-
   void
   scheduleWatchEvent();
 
@@ -77,9 +66,6 @@
   delayedInterest();
 
   void
-  stopFaceProcess();
-
-  void
   onWatchData(const Interest& interest, const Data& data);
 
   void
@@ -98,38 +84,18 @@
   checkWatchOk(const Interest& interest);
 
 public:
-  Face repoFace;
-  Scheduler scheduler;
-  ValidatorConfig validator;
-  KeyChain keyChain;
   WatchHandle watchHandle;
   Face watchFace;
   std::map<Name, EventId> watchEvents;
 };
 
-template<class T>  void
-Fixture<T>::generateDefaultCertificateFile()
-{
-  Name defaultIdentity = keyChain.getDefaultIdentity();
-  Name defaultKeyname = keyChain.getDefaultKeyNameForIdentity(defaultIdentity);
-  Name defaultCertficateName = keyChain.getDefaultCertificateNameForKey(defaultKeyname);
-  shared_ptr<ndn::IdentityCertificate> defaultCertficate =
-  keyChain.getCertificate(defaultCertficateName);
-  //test-integrated should run in root directory of repo-ng.
-  //certificate file should be removed after tests for security issue.
-  std::fstream certificateFile("tests/integrated/insert-delete-test.cert",
-                               std::ios::out | std::ios::binary | std::ios::trunc);
-  ndn::io::save(*defaultCertficate, certificateFile);
-  certificateFile.close();
-}
-
 template<class T> void
 Fixture<T>::onWatchInterest(const Interest& interest)
 {
   shared_ptr<Data> data = make_shared<Data>(Name(interest.getName()).appendNumber(random::generateWord64()+100));
   data->setContent(content, sizeof(content));
   data->setFreshnessPeriod(milliseconds(0));
-  keyChain.signByIdentity(*data, keyChain.getDefaultIdentity());
+  keyChain.sign(*data);
   watchFace.put(*data);
 
   // schedule an event 50ms later to check whether watch is Ok
@@ -152,12 +118,6 @@
 }
 
 template<class T> void
-Fixture<T>::stopFaceProcess()
-{
-  repoFace.getIoService().stop();
-}
-
-template<class T> void
 Fixture<T>::onWatchData(const Interest& interest, const Data& data)
 {
   RepoCommandResponse response;
@@ -226,7 +186,7 @@
   watchParameter.setWatchTimeout(milliseconds(1000000000));
   watchCommandName.append(watchParameter.wireEncode());
   Interest watchInterest(watchCommandName);
-  keyChain.signByIdentity(watchInterest, keyChain.getDefaultIdentity());
+  keyChain.sign(watchInterest);
   //schedule a job to express watchInterest
   scheduler.scheduleEvent(milliseconds(1000),
                           bind(&Fixture<T>::sendWatchStartInterest, this, watchInterest));
@@ -235,7 +195,7 @@
   RepoCommandParameter watchStopParameter;
   watchStopName.append(watchStopParameter.wireEncode());
   Interest watchStopInterest(watchStopName);
-  keyChain.signByIdentity(watchStopInterest, keyChain.getDefaultIdentity());
+  keyChain.sign(watchStopInterest);
 
  // scheduler.scheduleEvent(milliseconds(10000),
   //                        bind(&Fixture<T>::sendWatchStopInterest, this, watchStopInterest));
@@ -250,17 +210,11 @@
 
 BOOST_FIXTURE_TEST_CASE_TEMPLATE(WatchDelete, T, Dataset, Fixture<T>)
 {
-  this->generateDefaultCertificateFile();
-  this->validator.load("tests/integrated/insert-delete-validator-config.conf");
-
   // schedule events
   this->scheduler.scheduleEvent(seconds(0),
                                 bind(&Fixture<T>::scheduleWatchEvent, this));
 
-  // schedule an event to terminate IO
-  this->scheduler.scheduleEvent(seconds(500),
-                                bind(&Fixture<T>::stopFaceProcess, this));
-  this->repoFace.getIoService().run();
+  this->repoFace.processEvents(seconds(500));
 }
 
 BOOST_AUTO_TEST_SUITE_END()