tests: sync common testing infrastructure with ndn-cxx

Change-Id: I6feab5247231abc35b8daa96bca21ad17c9cc4b3
diff --git a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
index 9c8b87a..616b6e8 100644
--- a/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
+++ b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019,  Regents of the University of California,
+ * Copyright (c) 2014-2020,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -30,6 +30,9 @@
 #include "tests/daemon/global-io-fixture.hpp"
 #include "tests/daemon/rib/fib-updates-common.hpp"
 
+#include <ndn-cxx/security/transform/base64-encode.hpp>
+#include <ndn-cxx/security/transform/buffer-source.hpp>
+#include <ndn-cxx/security/transform/stream-sink.hpp>
 #include <ndn-cxx/util/dummy-client-face.hpp>
 
 #include <boost/property_tree/info_parser.hpp>
@@ -137,7 +140,7 @@
   /** \brief Lookup a route with PREFIXANN origin.
    */
   Route*
-  findAnnRoute(const Name& name, uint64_t faceId)
+  findAnnRoute(const Name& name, uint64_t faceId) const
   {
     Route routeQuery;
     routeQuery.faceId = faceId;
@@ -145,6 +148,21 @@
     return rib.find(name, routeQuery);
   }
 
+  /** \brief Retrieve an identity certificate as a base64 string.
+   */
+  std::string
+  getIdentityCertificateBase64(const Name& identity) const
+  {
+    auto cert = m_keyChain.getPib().getIdentity(identity).getDefaultKey().getDefaultCertificate();
+    const auto& block = cert.wireEncode();
+
+    namespace tr = ndn::security::transform;
+    std::ostringstream oss;
+    tr::bufferSource(block.wire(), block.size()) >> tr::base64Encode(false) >> tr::streamSink(oss);
+
+    return oss.str();
+  }
+
 private:
   void
   loadDefaultPaConfig()
@@ -158,7 +176,7 @@
     manager->applyPaConfig(makeSection(CONFIG), "default");
   }
 
-public:
+protected:
   rib::Rib rib;
   unique_ptr<RibManager> manager;