**breaking change**: Switch Face and related classes to v2::KeyChain
security::v2::KeyChain is now exposed as ndn::KeyChain, which should
ensure that dependent code can be mostly compiled. However, expect code
that explicitly uses the old KeyChain interface to be broken.
Change-Id: I7330d0250d92f3f0f2570ab6d0214ab3dfdd18cc
Refs: #3098
diff --git a/tests/unit-tests/security/command-interest-validator.t.cpp b/tests/unit-tests/security/command-interest-validator.t.cpp
index cb01b36..e8c4eeb 100644
--- a/tests/unit-tests/security/command-interest-validator.t.cpp
+++ b/tests/unit-tests/security/command-interest-validator.t.cpp
@@ -20,6 +20,7 @@
*/
#include "security/command-interest-validator.hpp"
+#include "security/command-interest-signer.hpp"
#include "security/signing-helpers.hpp"
#include "boost-test.hpp"
@@ -35,10 +36,11 @@
using namespace ndn::tests;
-class CommandInterestValidatorFixture : public IdentityManagementV1TimeFixture
+class CommandInterestValidatorFixture : public IdentityManagementTimeFixture
{
protected:
CommandInterestValidatorFixture()
+ : signer(m_keyChain)
{
this->initialize(CommandInterestValidator::Options{});
}
@@ -63,10 +65,8 @@
shared_ptr<Interest>
makeCommandInterest(uint64_t identity = 0)
{
- auto interest = makeInterest("/CommandInterestPrefix");
- m_keyChain.sign(*interest, signingByIdentity(makeIdentity(identity)));
- BOOST_TEST_MESSAGE("makeCommandInterest " << interest->getName());
- return interest;
+ auto interest = signer.makeCommandInterest("/CommandInterestPrefix", signingByIdentity(makeIdentity(identity)));
+ return make_shared<Interest>(std::move(interest));
}
/** \brief check that validator accepts interest
@@ -75,7 +75,6 @@
void
assertAccept(const Interest& interest)
{
- BOOST_TEST_MESSAGE("assertAccept " << interest.getName());
int nAccepts = 0;
validator->validate(interest,
[&nAccepts] (const shared_ptr<const Interest>&) { ++nAccepts; },
@@ -93,7 +92,6 @@
void
assertReject(const Interest& interest, CommandInterestValidator::ErrorCode error)
{
- BOOST_TEST_MESSAGE("assertReject " << interest.getName());
int nRejects = 0;
validator->validate(interest,
[] (const shared_ptr<const Interest>&) {
@@ -109,6 +107,7 @@
}
protected:
+ CommandInterestSigner signer;
DummyValidator* inner;
unique_ptr<CommandInterestValidator> validator;
};
diff --git a/tests/unit-tests/security/v2/key-chain.t.cpp b/tests/unit-tests/security/v2/key-chain.t.cpp
index 4eaf75e..d1a954c 100644
--- a/tests/unit-tests/security/v2/key-chain.t.cpp
+++ b/tests/unit-tests/security/v2/key-chain.t.cpp
@@ -47,6 +47,12 @@
unsetenv("NDN_CLIENT_PIB");
unsetenv("NDN_CLIENT_TPM");
}
+
+ ~TestHomeAndPibFixture()
+ {
+ const_cast<std::string&>(KeyChain::getDefaultPibLocator()).clear();
+ const_cast<std::string&>(KeyChain::getDefaultTpmLocator()).clear();
+ }
};
struct PibPathConfigFileHome
diff --git a/tests/unit-tests/security/validator-config.t.cpp b/tests/unit-tests/security/validator-config.t.cpp
index 14ed721..74c29ae 100644
--- a/tests/unit-tests/security/validator-config.t.cpp
+++ b/tests/unit-tests/security/validator-config.t.cpp
@@ -49,12 +49,14 @@
{
public:
ValidatorConfigFixture()
- : face(nullptr, m_keyChain)
+ : m_v2KeyChain("pib-memory:", "tpm-memory:")
+ , face(nullptr, m_v2KeyChain)
, validator(face)
{
}
public:
+ v2::KeyChain m_v2KeyChain;
Face face;
ValidatorConfig validator;
};
@@ -1078,8 +1080,8 @@
struct FacesFixture : public ValidatorConfigFixture
{
FacesFixture()
- : face1(io, m_keyChain, {true, true})
- , face2(io, m_keyChain, {true, true})
+ : face1(io, m_v2KeyChain, {true, true})
+ , face2(io, m_v2KeyChain, {true, true})
, readInterestOffset1(0)
, readDataOffset1(0)
, readInterestOffset2(0)
@@ -1486,11 +1488,11 @@
advanceClocks(time::milliseconds(10), 20);
}
-class DirectCertFetchFixture : public IdentityManagementV1TimeFixture
+class DirectCertFetchFixture : public ValidatorConfigFixture
{
public:
DirectCertFetchFixture()
- : clientFace(io, m_keyChain, {true, true})
+ : clientFace(io, m_v2KeyChain, {true, true})
, validationResult(boost::logic::indeterminate)
{
auto certName = addIdentity(ca);