update profile fetching
Change-Id: I788ece8371f7e24c87918a57062673be1d866e5b
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 28850a8..09986c6 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -19,9 +19,9 @@
*/
#include "ca-module.hpp"
-#include "requester.hpp"
#include "challenge-modules/challenge-pin.hpp"
#include "protocol-detail/info.hpp"
+#include "requester.hpp"
#include "test-common.hpp"
namespace ndn {
@@ -38,12 +38,26 @@
util::DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
+ auto metaData = ca.generateCaConfigMetaData();
+ auto profileData = ca.generateCaConfigData();
advanceClocks(time::milliseconds(20), 60);
Interest interest = MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
std::cout << "CA Config discovery Interest Size: " << interest.wireEncode().size() << std::endl;
shared_ptr<Interest> infoInterest = nullptr;
+ face.setInterestFilter(InterestFilter("/ndn/CA/INFO"),
+ [&](const auto&, const Interest& interest) {
+ if (interest.matchesData(*metaData)) {
+ face.put(*metaData);
+ }
+ else {
+ BOOST_CHECK(interest.matchesData(*profileData));
+ face.put(*profileData);
+ }
+ }, nullptr, nullptr);
+ advanceClocks(time::milliseconds(20), 60);
+
int count = 0;
face.onSendData.connect([&](const Data& response) {
if (count == 0) {
@@ -55,7 +69,6 @@
interest.setCanBePrefix(true);
infoInterest = make_shared<Interest>(interest);
std::cout << "CA Config fetch Interest Size: " << infoInterest->wireEncode().size() << std::endl;
-
}
else {
count++;
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 7abb727..774484d 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -39,11 +39,11 @@
BOOST_CHECK_EQUAL(ca.getCaConf().m_caItem.m_caPrefix, "/ndn");
advanceClocks(time::milliseconds(20), 60);
- BOOST_CHECK_EQUAL(ca.m_registeredPrefixHandles.size(), 2);
- BOOST_CHECK_EQUAL(ca.m_interestFilterHandles.size(), 5); // onInfo, onProbe, onNew, onChallenge, onRevoke
+ BOOST_CHECK_EQUAL(ca.m_registeredPrefixHandles.size(), 1); // removed local discovery registration
+ BOOST_CHECK_EQUAL(ca.m_interestFilterHandles.size(), 4); // onProbe, onNew, onChallenge, onRevoke
}
-BOOST_AUTO_TEST_CASE(HandleInfo)
+BOOST_AUTO_TEST_CASE(HandleProfileFetching)
{
auto identity = addIdentity(Name("/ndn"));
auto key = identity.getDefaultKey();
@@ -51,27 +51,53 @@
util::DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
+ auto metaData = ca.generateCaConfigMetaData();
+ auto profileData = ca.generateCaConfigData();
advanceClocks(time::milliseconds(20), 60);
- Interest interest("/ndn/CA/INFO");
- interest.setCanBePrefix(false);
+ Interest interest = MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
+ shared_ptr<Interest> infoInterest = nullptr;
+
+ face.setInterestFilter(InterestFilter("/ndn/CA/INFO"),
+ [&](const auto&, const Interest& interest) {
+ if (interest.matchesData(*metaData)) {
+ face.put(*metaData);
+ }
+ else {
+ BOOST_CHECK(interest.matchesData(*profileData));
+ face.put(*profileData);
+ }
+ }, nullptr, nullptr);
+ advanceClocks(time::milliseconds(20), 60);
int count = 0;
face.onSendData.connect([&](const Data& response) {
- count++;
- BOOST_CHECK(security::verifySignature(response, cert));
- auto contentBlock = response.getContent();
- contentBlock.parse();
- auto caItem = INFO::decodeDataContent(contentBlock);
- BOOST_CHECK_EQUAL(caItem.m_caPrefix, "/ndn");
- BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.size(), 1);
- BOOST_CHECK_EQUAL(caItem.m_cert->wireEncode(), cert.wireEncode());
- BOOST_CHECK_EQUAL(caItem.m_caInfo, "ndn testbed ca");
+ if (count == 0) {
+ count++;
+ auto block = response.getContent();
+ block.parse();
+ Interest interest(Name(block.get(tlv::Name)));
+ interest.setCanBePrefix(true);
+ infoInterest = make_shared<Interest>(interest);
+ }
+ else {
+ count++;
+ BOOST_CHECK(security::verifySignature(response, cert));
+ auto contentBlock = response.getContent();
+ contentBlock.parse();
+ auto caItem = INFO::decodeDataContent(contentBlock);
+ BOOST_CHECK_EQUAL(caItem.m_caPrefix, "/ndn");
+ BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.size(), 1);
+ BOOST_CHECK_EQUAL(caItem.m_probeParameterKeys.front(), "full name");
+ BOOST_CHECK_EQUAL(caItem.m_cert->wireEncode(), cert.wireEncode());
+ BOOST_CHECK_EQUAL(caItem.m_caInfo, "ndn testbed ca");
+ }
});
face.receive(interest);
-
advanceClocks(time::milliseconds(20), 60);
- BOOST_CHECK_EQUAL(count, 1);
+ face.receive(*infoInterest);
+ advanceClocks(time::milliseconds(20), 60);
+ BOOST_CHECK_EQUAL(count, 2);
}
BOOST_AUTO_TEST_CASE(HandleProbe)