face: Enable KeyChain customization in DummyClientFace

This feature also required two new Face constructors

Change-Id: I25c6d9d0d94a065176ed348d25e7b99a6c7999c0
Refs: #3435
diff --git a/src/util/dummy-client-face.cpp b/src/util/dummy-client-face.cpp
index 8cdb9dc..cc593ef 100644
--- a/src/util/dummy-client-face.cpp
+++ b/src/util/dummy-client-face.cpp
@@ -89,6 +89,19 @@
 #ifdef NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
   , sentDatas(sentData)
 #endif // NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+  , m_internalKeyChain(new KeyChain)
+  , m_keyChain(*m_internalKeyChain)
+{
+  this->construct(options);
+}
+
+DummyClientFace::DummyClientFace(KeyChain& keyChain,
+                                 const Options& options/* = DummyClientFace::DEFAULT_OPTIONS*/)
+  : Face(make_shared<DummyClientFace::Transport>(), keyChain)
+#ifdef NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+  , sentDatas(sentData)
+#endif // NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+  , m_keyChain(keyChain)
 {
   this->construct(options);
 }
@@ -99,6 +112,19 @@
 #ifdef NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
   , sentDatas(sentData)
 #endif // NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+  , m_internalKeyChain(new KeyChain)
+  , m_keyChain(*m_internalKeyChain)
+{
+  this->construct(options);
+}
+
+DummyClientFace::DummyClientFace(boost::asio::io_service& ioService, KeyChain& keyChain,
+                                 const Options& options/* = DummyClientFace::DEFAULT_OPTIONS*/)
+  : Face(make_shared<DummyClientFace::Transport>(), ioService, keyChain)
+#ifdef NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+  , sentDatas(sentData)
+#endif // NDN_UTIL_DUMMY_FACE_KEEP_DEPRECATED
+  , m_keyChain(keyChain)
 {
   this->construct(options);
 }
@@ -186,8 +212,7 @@
     shared_ptr<Data> data = make_shared<Data>(interest.getName());
     data->setContent(resp.wireEncode());
 
-    KeyChain keyChain;
-    keyChain.sign(*data, security::SigningInfo(security::SigningInfo::SIGNER_TYPE_SHA256));
+    m_keyChain.sign(*data, security::SigningInfo(security::SigningInfo::SIGNER_TYPE_SHA256));
 
     this->getIoService().post([this, data] { this->receive(*data); });
   });
diff --git a/src/util/dummy-client-face.hpp b/src/util/dummy-client-face.hpp
index b5ec7d7..c9ea6fc 100644
--- a/src/util/dummy-client-face.hpp
+++ b/src/util/dummy-client-face.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -56,9 +56,21 @@
   DummyClientFace(const Options& options = DummyClientFace::DEFAULT_OPTIONS);
 
   /**
+   * @brief Create a dummy face with internal IO service and the specified KeyChain
+   */
+  DummyClientFace(KeyChain& keyChain, const Options& options = DummyClientFace::DEFAULT_OPTIONS);
+
+  /**
    * @brief Create a dummy face with the provided IO service
    */
-  DummyClientFace(boost::asio::io_service& ioService, const Options& options = DummyClientFace::DEFAULT_OPTIONS);
+  DummyClientFace(boost::asio::io_service& ioService,
+                  const Options& options = DummyClientFace::DEFAULT_OPTIONS);
+
+  /**
+   * @brief Create a dummy face with the provided IO service and the specified KeyChain
+   */
+  DummyClientFace(boost::asio::io_service& ioService, KeyChain& keyChain,
+                  const Options& options = DummyClientFace::DEFAULT_OPTIONS);
 
   /** \brief cause the Face to receive a packet
    *  \tparam Packet either Interest or Data
@@ -133,6 +145,10 @@
    *  After .put, .processEvents must be called before this signal would be emitted.
    */
   Signal<DummyClientFace, lp::Nack> onSendNack;
+
+private:
+  std::unique_ptr<KeyChain> m_internalKeyChain;
+  KeyChain& m_keyChain;
 };
 
 template<>