Convert to v2::security and adapt to ndn-cxx changes
Change-Id: I54f1b758cfb8f3f6cbc66a1aec5120ae1640b0ec
refs: #3964
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 9156c7b..4b702fc 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -30,6 +30,9 @@
#include <ndn-cxx/util/dummy-client-face.hpp>
#include <ndn-cxx/security/key-chain.hpp>
+#include <ndn-cxx/security/pib/identity.hpp>
+
+#include <ndn-cxx/util/io.hpp>
#include <boost/filesystem.hpp>
@@ -42,13 +45,16 @@
{
public:
PublisherFixture()
- : face(g_ioService, keyChain, {true, true})
- , nlsr(g_ioService, g_scheduler, face, g_keyChain)
+ : face(m_ioService, m_keyChain, {true, true})
+ , nlsr(m_ioService, m_scheduler, face, m_keyChain)
, lsdb(nlsr.getLsdb())
{
- INIT_LOGGERS("/tmp/","TRACE");
+ INIT_LOGGERS("/tmp/", "TRACE");
nlsr.getConfParameter().setNetwork("/ndn");
nlsr.getConfParameter().setRouterName("/This/Router");
+
+ routerId = addIdentity("/ndn/This/Router");
+
nlsr.initialize();
face.processEvents(ndn::time::milliseconds(100));
}
@@ -56,7 +62,7 @@
void
addAdjacency(AdjLsa& lsa, const std::string& name, const std::string& faceUri, double cost)
{
- Adjacent adjacency(name, ndn::util::FaceUri(faceUri), cost, Adjacent::STATUS_ACTIVE, 0, 0);
+ Adjacent adjacency(name, ndn::FaceUri(faceUri), cost, Adjacent::STATUS_ACTIVE, 0, 0);
lsa.addAdjacent(std::move(adjacency));
}
@@ -148,10 +154,11 @@
public:
ndn::util::DummyClientFace face;
- ndn::KeyChain keyChain;
Nlsr nlsr;
Lsdb& lsdb;
+
+ ndn::security::pib::Identity routerId;
};
} // namespace test
diff --git a/tests/publisher/test-segment-publisher.cpp b/tests/publisher/test-segment-publisher.cpp
index c6b4fba..e1a7232 100644
--- a/tests/publisher/test-segment-publisher.cpp
+++ b/tests/publisher/test-segment-publisher.cpp
@@ -26,6 +26,7 @@
#include "publisher/segment-publisher.hpp"
#include "../boost-test.hpp"
+#include "../test-common.hpp"
#include <ndn-cxx/encoding/tlv.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -36,14 +37,17 @@
namespace nlsr {
namespace tests {
+using namespace nlsr::test;
+
template<int64_t N=10000>
class TestSegmentPublisher : public SegmentPublisher<ndn::util::DummyClientFace>
{
public:
TestSegmentPublisher(ndn::util::DummyClientFace& face,
ndn::KeyChain& keyChain,
+ ndn::security::SigningInfo& signingInfo,
const ndn::time::milliseconds freshnessPeriod)
- : SegmentPublisher(face, keyChain, freshnessPeriod)
+ : SegmentPublisher(face, keyChain, signingInfo, freshnessPeriod)
, m_totalPayloadLength(0)
{
@@ -72,10 +76,10 @@
generate(ndn::EncodingBuffer& outBuffer)
{
size_t totalLength = 0;
- for (int64_t i = 0; i < N; i++)
- {
+ for (int64_t i = 0; i < N; i++) {
totalLength += prependNonNegativeIntegerBlock(outBuffer, ndn::tlv::Content, i);
- }
+ }
+
m_totalPayloadLength += totalLength;
return totalLength;
}
@@ -85,13 +89,13 @@
};
template<int64_t N>
-class SegmentPublisherFixture
+class SegmentPublisherFixture : public BaseFixture
{
public:
SegmentPublisherFixture()
- : m_face(std::make_shared<ndn::util::DummyClientFace>())
+ : m_face(std::make_shared<ndn::util::DummyClientFace>(m_ioService, m_keyChain))
, m_expectedFreshnessPeriod(ndn::time::milliseconds(111))
- , m_publisher(*m_face, m_keyChain, m_expectedFreshnessPeriod)
+ , m_publisher(*m_face, m_keyChain, m_signingInfo, m_expectedFreshnessPeriod)
, m_publishingPrefix("/localhost/nfd/SegmentPublisherFixture")
{
}
@@ -106,10 +110,9 @@
m_buffer.appendByteArray(payload.value(), payload.value_size());
// uint64_t segmentNo = data.getName()[-1].toSegment();
- if (data.getFinalBlockId() != data.getName()[-1])
- {
+ if (data.getFinalBlockId() != data.getName()[-1]) {
return;
- }
+ }
// wrap data in a single Content TLV for easy parsing
m_buffer.prependVarNumber(m_buffer.size());
@@ -138,7 +141,7 @@
const ndn::time::milliseconds m_expectedFreshnessPeriod;
TestSegmentPublisher<N> m_publisher;
ndn::EncodingBuffer m_buffer;
- ndn::KeyChain m_keyChain;
+ ndn::security::SigningInfo m_signingInfo;
const ndn::Name m_publishingPrefix;
};