tests: refactor common test infrastructure and fixtures
Change-Id: I597c11130eefa2cc2846ee6655c85dc04f2f22ef
diff --git a/tests/unit/security/certificate-bundle-fetcher.t.cpp b/tests/unit/security/certificate-bundle-fetcher.t.cpp
index 1d0cee9..0c300b7 100644
--- a/tests/unit/security/certificate-bundle-fetcher.t.cpp
+++ b/tests/unit/security/certificate-bundle-fetcher.t.cpp
@@ -23,8 +23,7 @@
#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
#include "ndn-cxx/util/regex/regex-pattern-list-matcher.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
+#include "tests/test-common.hpp"
#include "tests/unit/security/validator-fixture.hpp"
namespace ndn {
diff --git a/tests/unit/security/certificate-cache.t.cpp b/tests/unit/security/certificate-cache.t.cpp
index 65614ac..7d60506 100644
--- a/tests/unit/security/certificate-cache.t.cpp
+++ b/tests/unit/security/certificate-cache.t.cpp
@@ -22,22 +22,23 @@
#include "ndn-cxx/security/certificate-cache.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
+#include "tests/unit/clock-fixture.hpp"
namespace ndn {
namespace security {
inline namespace v2 {
namespace tests {
-BOOST_AUTO_TEST_SUITE(Security)
+using namespace ndn::tests;
-class CertificateCacheFixture : public ndn::tests::IdentityManagementTimeFixture
+class CertificateCacheFixture : public ClockFixture, public KeyChainFixture
{
public:
CertificateCacheFixture()
: certCache(10_s)
{
- identity = addIdentity("/TestCertificateCache/");
+ identity = m_keyChain.createIdentity("/TestCertificateCache");
cert = identity.getDefaultKey().getDefaultCertificate();
}
@@ -47,6 +48,7 @@
Certificate cert;
};
+BOOST_AUTO_TEST_SUITE(Security)
BOOST_FIXTURE_TEST_SUITE(TestCertificateCache, CertificateCacheFixture)
BOOST_AUTO_TEST_CASE(RemovalTime)
diff --git a/tests/unit/security/certificate-fetcher-direct-fetch.t.cpp b/tests/unit/security/certificate-fetcher-direct-fetch.t.cpp
index 25e0be5..7757f5b 100644
--- a/tests/unit/security/certificate-fetcher-direct-fetch.t.cpp
+++ b/tests/unit/security/certificate-fetcher-direct-fetch.t.cpp
@@ -20,9 +20,10 @@
*/
#include "ndn-cxx/security/certificate-fetcher-direct-fetch.hpp"
-#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
+
#include "ndn-cxx/lp/nack.hpp"
#include "ndn-cxx/lp/tags.hpp"
+#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
#include "tests/boost-test.hpp"
#include "tests/unit/security/validator-fixture.hpp"
diff --git a/tests/unit/security/certificate-fetcher-from-network.t.cpp b/tests/unit/security/certificate-fetcher-from-network.t.cpp
index 8437c22..caf941a 100644
--- a/tests/unit/security/certificate-fetcher-from-network.t.cpp
+++ b/tests/unit/security/certificate-fetcher-from-network.t.cpp
@@ -20,8 +20,9 @@
*/
#include "ndn-cxx/security/certificate-fetcher-from-network.hpp"
-#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
+
#include "ndn-cxx/lp/nack.hpp"
+#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
#include "tests/boost-test.hpp"
#include "tests/unit/security/validator-fixture.hpp"
diff --git a/tests/unit/security/certificate.t.cpp b/tests/unit/security/certificate.t.cpp
index f645dbd..1069584 100644
--- a/tests/unit/security/certificate.t.cpp
+++ b/tests/unit/security/certificate.t.cpp
@@ -24,7 +24,7 @@
#include "ndn-cxx/security/certificate.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/unit-test-time-fixture.hpp"
+#include "tests/unit/clock-fixture.hpp"
#include <boost/lexical_cast.hpp>
@@ -36,7 +36,7 @@
using namespace ndn::tests;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_FIXTURE_TEST_SUITE(TestCertificate, UnitTestTimeFixture)
+BOOST_FIXTURE_TEST_SUITE(TestCertificate, ClockFixture)
const uint8_t PUBLIC_KEY[] = {
0x30, 0x81, 0x9d, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
diff --git a/tests/unit/security/detail/certificate-bundle-decoder.t.cpp b/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
index b6691ee..ae81c82 100644
--- a/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
+++ b/tests/unit/security/detail/certificate-bundle-decoder.t.cpp
@@ -22,24 +22,24 @@
#include "ndn-cxx/security/detail/certificate-bundle-decoder.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
namespace ndn {
namespace security {
namespace detail {
namespace tests {
-class CertificateBundleDecoderFixture : public ndn::tests::IdentityManagementFixture
+class CertificateBundleDecoderFixture : public ndn::tests::KeyChainFixture
{
protected:
CertificateBundleDecoderFixture()
{
- auto id1 = addIdentity("/hello/world1");
+ auto id1 = m_keyChain.createIdentity("/hello/world1");
auto cert1 = id1.getDefaultKey().getDefaultCertificate();
certBlock1 = cert1.wireEncode();
m_certs.push_back(certBlock1);
- auto id2 = addIdentity("/hello/world2");
+ auto id2 = m_keyChain.createIdentity("/hello/world2");
auto cert2 = id2.getDefaultKey().getDefaultCertificate();
certBlock2 = cert2.wireEncode();
m_certs.push_back(certBlock2);
@@ -54,7 +54,7 @@
CertificateBundleDecoder cbd;
Block certBlock1;
Block certBlock2;
- int nCertsCompleted = 0;
+ size_t nCertsCompleted = 0;
private:
std::vector<Block> m_certs;
diff --git a/tests/unit/security/digest-sha256.t.cpp b/tests/unit/security/digest-sha256.t.cpp
index 674aaf5..83d2ca7 100644
--- a/tests/unit/security/digest-sha256.t.cpp
+++ b/tests/unit/security/digest-sha256.t.cpp
@@ -25,16 +25,14 @@
#include "ndn-cxx/util/string-helper.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
namespace ndn {
namespace security {
namespace tests {
-using namespace ndn::tests;
-
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_FIXTURE_TEST_SUITE(TestDigestSha256, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_SUITE(TestDigestSha256, ndn::tests::KeyChainFixture)
BOOST_AUTO_TEST_CASE(Sha256)
{
diff --git a/tests/unit/security/interest-signer.t.cpp b/tests/unit/security/interest-signer.t.cpp
index 6d054ff..735668c 100644
--- a/tests/unit/security/interest-signer.t.cpp
+++ b/tests/unit/security/interest-signer.t.cpp
@@ -20,10 +20,10 @@
*/
#include "ndn-cxx/security/interest-signer.hpp"
-#include "ndn-cxx/security/signing-helpers.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
+#include "tests/unit/clock-fixture.hpp"
namespace ndn {
namespace security {
@@ -31,12 +31,16 @@
using namespace ndn::tests;
+class InterestSignerFixture : public ClockFixture, public KeyChainFixture
+{
+};
+
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_FIXTURE_TEST_SUITE(TestInterestSigner, IdentityManagementTimeFixture)
+BOOST_FIXTURE_TEST_SUITE(TestInterestSigner, InterestSignerFixture)
BOOST_AUTO_TEST_CASE(V02)
{
- addIdentity("/test");
+ m_keyChain.createIdentity("/test");
InterestSigner signer(m_keyChain);
Interest i1 = signer.makeCommandInterest("/hello/world");
@@ -67,7 +71,7 @@
BOOST_AUTO_TEST_CASE(V03)
{
- addIdentity("/test");
+ m_keyChain.createIdentity("/test");
InterestSigner signer(m_keyChain);
Interest i1("/hello/world");
diff --git a/tests/unit/security/key-chain.t.cpp b/tests/unit/security/key-chain.t.cpp
index b6dd0c6..a9e1eaf 100644
--- a/tests/unit/security/key-chain.t.cpp
+++ b/tests/unit/security/key-chain.t.cpp
@@ -20,12 +20,11 @@
*/
#include "ndn-cxx/security/key-chain.hpp"
-#include "ndn-cxx/security/signing-helpers.hpp"
-#include "ndn-cxx/security/verification-helpers.hpp"
#include "ndn-cxx/security/transform/private-key.hpp"
+#include "ndn-cxx/security/verification-helpers.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
#include "tests/unit/test-home-env-saver.hpp"
namespace ndn {
@@ -209,7 +208,7 @@
BOOST_CHECK_EQUAL(keyChain.getTpm().getTpmLocator(), "tpm-memory:");
}
-BOOST_FIXTURE_TEST_CASE(SigningWithCorruptedPibTpm, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(SigningWithCorruptedPibTpm, KeyChainFixture)
{
Identity id = m_keyChain.createIdentity("/test");
@@ -223,7 +222,7 @@
BOOST_CHECK_THROW(m_keyChain.sign(data, signingByIdentity(id)), KeyChain::InvalidSigningInfoError);
}
-BOOST_FIXTURE_TEST_CASE(Management, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(Management, KeyChainFixture)
{
Name identityName("/test/id");
Name identity2Name("/test/id2");
@@ -320,9 +319,9 @@
BOOST_CHECK(m_keyChain.getPib().getIdentities().find(identityName) == m_keyChain.getPib().getIdentities().end());
}
-BOOST_FIXTURE_TEST_CASE(GeneralSigningInterface, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(GeneralSigningInterface, KeyChainFixture)
{
- Identity id = addIdentity("/id");
+ Identity id = m_keyChain.createIdentity("/id");
Key key = id.getDefaultKey();
Certificate cert = key.getDefaultCertificate();
@@ -458,7 +457,7 @@
}
}
-BOOST_FIXTURE_TEST_CASE(PublicKeySigningDefaults, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(PublicKeySigningDefaults, KeyChainFixture)
{
Data data("/test/data");
@@ -466,7 +465,7 @@
BOOST_CHECK_THROW(m_keyChain.sign(data, signingByIdentity("/non-existing/identity")), KeyChain::InvalidSigningInfoError);
// Create identity with EC key and the corresponding self-signed certificate
- Identity id = addIdentity("/ndn/test/ec", EcKeyParams());
+ Identity id = m_keyChain.createIdentity("/ndn/test/ec", EcKeyParams());
BOOST_CHECK_NO_THROW(m_keyChain.sign(data, signingByIdentity(id.getName())));
BOOST_CHECK_EQUAL(data.getSignatureType(),
KeyChain::getSignatureType(EcKeyParams().getKeyType(), DigestAlgorithm::SHA256));
@@ -474,7 +473,7 @@
BOOST_CHECK(id.getName().isPrefixOf(data.getKeyLocator()->getName()));
// Create identity with RSA key and the corresponding self-signed certificate
- id = addIdentity("/ndn/test/rsa", RsaKeyParams());
+ id = m_keyChain.createIdentity("/ndn/test/rsa", RsaKeyParams());
BOOST_CHECK_NO_THROW(m_keyChain.sign(data, signingByIdentity(id.getName())));
BOOST_CHECK_EQUAL(data.getSignatureType(),
KeyChain::getSignatureType(RsaKeyParams().getKeyType(), DigestAlgorithm::SHA256));
@@ -482,7 +481,7 @@
BOOST_CHECK(id.getName().isPrefixOf(data.getKeyLocator()->getName()));
}
-BOOST_FIXTURE_TEST_CASE(ImportPrivateKey, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(ImportPrivateKey, KeyChainFixture)
{
Name keyName("/test/device2");
std::string rawKey("nPSNOHyZKsg2WLqHAs7MXGb0sjQb4zCT");
@@ -494,9 +493,9 @@
BOOST_CHECK_THROW(m_keyChain.importPrivateKey(keyName, key), KeyChain::Error);
}
-BOOST_FIXTURE_TEST_CASE(ExportImport, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(ExportImport, KeyChainFixture)
{
- Identity id = addIdentity("/TestKeyChain/ExportIdentity");
+ Identity id = m_keyChain.createIdentity("/TestKeyChain/ExportIdentity");
Certificate cert = id.getDefaultKey().getDefaultCertificate();
shared_ptr<SafeBag> exported = m_keyChain.exportSafeBag(cert, "1234", 4);
@@ -526,9 +525,9 @@
BOOST_CHECK_EQUAL(m_keyChain.getTpm().hasKey(cert.getKeyName()), false);
}
-BOOST_FIXTURE_TEST_CASE(SelfSignedCertValidity, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(SelfSignedCertValidity, KeyChainFixture)
{
- Certificate cert = addIdentity("/Security/TestKeyChain/SelfSignedCertValidity")
+ Certificate cert = m_keyChain.createIdentity("/Security/TestKeyChain/SelfSignedCertValidity")
.getDefaultKey()
.getDefaultCertificate();
BOOST_CHECK(cert.isValid());
diff --git a/tests/unit/security/pib/impl/key-impl.t.cpp b/tests/unit/security/pib/impl/key-impl.t.cpp
index b2dfd96..be986a1 100644
--- a/tests/unit/security/pib/impl/key-impl.t.cpp
+++ b/tests/unit/security/pib/impl/key-impl.t.cpp
@@ -24,7 +24,7 @@
#include "ndn-cxx/security/pib/pib.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
#include "tests/unit/security/pib/pib-data-fixture.hpp"
namespace ndn {
@@ -131,7 +131,7 @@
}
class OverwriteFixture : public ndn::security::tests::PibDataFixture,
- public ndn::tests::IdentityManagementFixture
+ public ndn::tests::KeyChainFixture
{
};
diff --git a/tests/unit/security/pib/pib-data-fixture.cpp b/tests/unit/security/pib/pib-data-fixture.cpp
index e88c48e..b641f31 100644
--- a/tests/unit/security/pib/pib-data-fixture.cpp
+++ b/tests/unit/security/pib/pib-data-fixture.cpp
@@ -21,11 +21,14 @@
#include "tests/unit/security/pib/pib-data-fixture.hpp"
-// #include "ndn-cxx/security/pib/pib-memory.hpp"
+// #include "ndn-cxx/security/pib/impl/pib-memory.hpp"
+// #include "ndn-cxx/security/tpm/impl/back-end-mem.hpp"
// #include "ndn-cxx/security/tpm/tpm.hpp"
-// #include "ndn-cxx/security/tpm/back-end-mem.hpp"
+// #include "ndn-cxx/util/string-helper.hpp"
-// #include <fstream>
+// #include "tests/boost-test.hpp"
+
+// #include <iostream>
namespace ndn {
namespace security {
@@ -50,7 +53,7 @@
// certName
// .append("issuer")
// .appendVersion(certVersion);
-// v2::Certificate cert;
+// Certificate cert;
// cert.setName(certName);
// cert.setFreshnessPeriod(1_h);
// cert.setContent(tpm.getPublicKey(keyName));
@@ -58,14 +61,13 @@
// // TODO: sign using KeyChain
// SignatureInfo info;
// info.setSignatureType(tlv::SignatureSha256WithEcdsa);
-// info.setKeyLocator(KeyLocator(keyName));
+// info.setKeyLocator(keyName);
// info.setValidityPeriod(ValidityPeriod(time::fromIsoString("20170102T000000"),
// time::fromIsoString("20180102T000000")));
// cert.setSignatureInfo(info);
// EncodingBuffer buf;
// cert.wireEncode(buf, true);
-
// cert.setSignatureValue(tpm.sign(buf.buf(), buf.size(), keyName, DigestAlgorithm::SHA256));
// printBytes(prefix + "_KEY" + to_string(keyId) + "_CERT" + to_string(certVersion),
@@ -83,7 +85,7 @@
// static void
// printBytes(const std::string& name, const Buffer& buffer)
// {
-// printBytes(name, buffer.buf(), buffer.size());
+// printBytes(name, buffer.data(), buffer.size());
// }
// static void
@@ -108,7 +110,7 @@
// << "};" << std::endl;
// }
-// public:
+// private:
// pib::PibMemory pib;
// Tpm tpm;
// };
diff --git a/tests/unit/security/pib/pib-data-fixture.hpp b/tests/unit/security/pib/pib-data-fixture.hpp
index 66e65eb..0009d0f 100644
--- a/tests/unit/security/pib/pib-data-fixture.hpp
+++ b/tests/unit/security/pib/pib-data-fixture.hpp
@@ -19,8 +19,8 @@
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
-#ifndef NDN_TESTS_UNIT_SECURITY_PIB_DATA_FIXTURE_HPP
-#define NDN_TESTS_UNIT_SECURITY_PIB_DATA_FIXTURE_HPP
+#ifndef NDN_CXX_TESTS_UNIT_SECURITY_PIB_PIB_DATA_FIXTURE_HPP
+#define NDN_CXX_TESTS_UNIT_SECURITY_PIB_PIB_DATA_FIXTURE_HPP
#include "ndn-cxx/security/certificate.hpp"
@@ -61,4 +61,4 @@
} // namespace security
} // namespace ndn
-#endif // NDN_TESTS_UNIT_SECURITY_PIB_DATA_FIXTURE_HPP
+#endif // NDN_CXX_TESTS_UNIT_SECURITY_PIB_PIB_DATA_FIXTURE_HPP
diff --git a/tests/unit/security/pib/pib-impl.t.cpp b/tests/unit/security/pib/pib-impl.t.cpp
index e16f658..971d995 100644
--- a/tests/unit/security/pib/pib-impl.t.cpp
+++ b/tests/unit/security/pib/pib-impl.t.cpp
@@ -52,20 +52,16 @@
class PibSqlite3Fixture : public PibDataFixture
{
public:
- PibSqlite3Fixture()
- : tmpPath(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "DbTest")
- , pib(tmpPath.c_str())
- {
- }
-
~PibSqlite3Fixture()
{
- boost::filesystem::remove_all(tmpPath);
+ boost::filesystem::remove_all(m_path);
}
+private:
+ const boost::filesystem::path m_path{boost::filesystem::path(UNIT_TESTS_TMPDIR) / "TestPibImpl"};
+
public:
- boost::filesystem::path tmpPath;
- PibSqlite3 pib;
+ PibSqlite3 pib{m_path.string()};
};
using PibImpls = boost::mpl::vector<PibMemoryFixture, PibSqlite3Fixture>;
diff --git a/tests/unit/security/signature-sha256-with-ecdsa.t.cpp b/tests/unit/security/signature-sha256-with-ecdsa.t.cpp
index 3881756..de5edb9 100644
--- a/tests/unit/security/signature-sha256-with-ecdsa.t.cpp
+++ b/tests/unit/security/signature-sha256-with-ecdsa.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,9 +23,8 @@
#include "ndn-cxx/security/verification-helpers.hpp"
#include "ndn-cxx/util/scheduler.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/test-common.hpp"
+#include "tests/unit/io-key-chain-fixture.hpp"
namespace ndn {
namespace security {
@@ -33,11 +32,11 @@
using namespace ndn::tests;
-class SignatureSha256EcdsaTimeFixture : public IdentityManagementTimeFixture
+class SignatureSha256EcdsaTimeFixture : public IoKeyChainFixture
{
public:
SignatureSha256EcdsaTimeFixture()
- : scheduler(io)
+ : scheduler(m_io)
{
}
@@ -108,7 +107,7 @@
BOOST_AUTO_TEST_CASE(DataSignature)
{
- Identity identity = addIdentity("/SecurityTestSignatureSha256WithEcdsa/DataSignature", EcKeyParams());
+ Identity identity = m_keyChain.createIdentity("/SecurityTestSignatureSha256WithEcdsa/DataSignature", EcKeyParams());
Data testData("/SecurityTestSignatureSha256WithEcdsa/DataSignature/Data1");
char content[5] = "1234";
@@ -123,7 +122,7 @@
BOOST_AUTO_TEST_CASE(InterestSignature)
{
- Identity identity = addIdentity("/SecurityTestSignatureSha256WithEcdsa/InterestSignature", EcKeyParams());
+ Identity identity = m_keyChain.createIdentity("/SecurityTestSignatureSha256WithEcdsa/InterestSignature", EcKeyParams());
auto interest = makeInterest("/SecurityTestSignatureSha256WithEcdsa/InterestSignature/Interest1");
auto interest11 = makeInterest("/SecurityTestSignatureSha256WithEcdsa/InterestSignature/Interest1");
diff --git a/tests/unit/security/signature-sha256-with-rsa.t.cpp b/tests/unit/security/signature-sha256-with-rsa.t.cpp
index 2363551..d52d923 100644
--- a/tests/unit/security/signature-sha256-with-rsa.t.cpp
+++ b/tests/unit/security/signature-sha256-with-rsa.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,9 +23,8 @@
#include "ndn-cxx/security/verification-helpers.hpp"
#include "ndn-cxx/util/scheduler.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/test-common.hpp"
+#include "tests/unit/io-key-chain-fixture.hpp"
namespace ndn {
namespace security {
@@ -33,11 +32,11 @@
using namespace ndn::tests;
-class SignatureSha256RsaTimeFixture : public IdentityManagementTimeFixture
+class SignatureSha256RsaTimeFixture : public IoKeyChainFixture
{
public:
SignatureSha256RsaTimeFixture()
- : scheduler(io)
+ : scheduler(m_io)
{
}
@@ -113,7 +112,7 @@
BOOST_AUTO_TEST_CASE(DataSignature)
{
- Identity identity = addIdentity("/SecurityTestSignatureSha256WithRsa/DataSignature", RsaKeyParams());
+ Identity identity = m_keyChain.createIdentity("/SecurityTestSignatureSha256WithRsa/DataSignature", RsaKeyParams());
Data testData("/SecurityTestSignatureSha256WithRsa/DataSignature/Data1");
char content[5] = "1234";
@@ -128,7 +127,7 @@
BOOST_AUTO_TEST_CASE(InterestSignature)
{
- Identity identity = addIdentity("/SecurityTestSignatureSha256WithRsa/InterestSignature", RsaKeyParams());
+ Identity identity = m_keyChain.createIdentity("/SecurityTestSignatureSha256WithRsa/InterestSignature", RsaKeyParams());
auto interest = makeInterest("/SecurityTestSignatureSha256WithRsa/InterestSignature/Interest1");
auto interest11 = makeInterest("/SecurityTestSignatureSha256WithRsa/InterestSignature/Interest1");
diff --git a/tests/unit/security/signing-helpers.t.cpp b/tests/unit/security/signing-helpers.t.cpp
index f4493fe..a515c16 100644
--- a/tests/unit/security/signing-helpers.t.cpp
+++ b/tests/unit/security/signing-helpers.t.cpp
@@ -30,8 +30,6 @@
BOOST_AUTO_TEST_SUITE(Security)
BOOST_AUTO_TEST_SUITE(TestSigningHelpers)
-// update of this test case deferred until the new IdentityManagementFixture is available
-
BOOST_AUTO_TEST_CASE(Identity)
{
Name identity("/identity");
diff --git a/tests/unit/security/tpm/back-end-wrapper-file.hpp b/tests/unit/security/tpm/back-end-wrapper-file.hpp
index 16b9bf2..2689e07 100644
--- a/tests/unit/security/tpm/back-end-wrapper-file.hpp
+++ b/tests/unit/security/tpm/back-end-wrapper-file.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2019 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -38,7 +38,7 @@
{
public:
BackEndWrapperFile()
- : m_tmpPath(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "TpmFileTest")
+ : m_tmpPath(boost::filesystem::path(UNIT_TESTS_TMPDIR) / "TpmBackEndFile")
, m_impl(make_unique<BackEndFile>(m_tmpPath.string()))
{
}
diff --git a/tests/unit/security/trust-anchor-container.t.cpp b/tests/unit/security/trust-anchor-container.t.cpp
index b25805f..18da58a 100644
--- a/tests/unit/security/trust-anchor-container.t.cpp
+++ b/tests/unit/security/trust-anchor-container.t.cpp
@@ -23,7 +23,8 @@
#include "ndn-cxx/util/io.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
+#include "tests/unit/clock-fixture.hpp"
#include <boost/filesystem.hpp>
@@ -34,47 +35,37 @@
using namespace ndn::tests;
-BOOST_AUTO_TEST_SUITE(Security)
-
/**
* This fixture creates a directory and prepares two certificates.
* cert1 is written to a file under the directory, while cert2 is not.
*/
-class AnchorContainerTestFixture : public IdentityManagementTimeFixture
+class TrustAnchorContainerFixture : public ClockFixture, public KeyChainFixture
{
public:
- AnchorContainerTestFixture()
+ TrustAnchorContainerFixture()
{
- namespace fs = boost::filesystem;
+ boost::filesystem::create_directories(certDirPath);
- fs::create_directory(fs::path(UNIT_TEST_CONFIG_PATH));
-
- certDirPath = fs::path(UNIT_TEST_CONFIG_PATH) / "test-cert-dir";
- fs::create_directory(certDirPath);
-
- certPath1 = fs::path(UNIT_TEST_CONFIG_PATH) / "test-cert-dir" / "trust-anchor-1.cert";
- certPath2 = fs::path(UNIT_TEST_CONFIG_PATH) / "test-cert-dir" / "trust-anchor-2.cert";
-
- identity1 = addIdentity("/TestAnchorContainer/First");
+ identity1 = m_keyChain.createIdentity("/TestAnchorContainer/First");
cert1 = identity1.getDefaultKey().getDefaultCertificate();
- saveCertToFile(cert1, certPath1.string());
+ saveCert(cert1, certPath1.string());
- identity2 = addIdentity("/TestAnchorContainer/Second");
+ identity2 = m_keyChain.createIdentity("/TestAnchorContainer/Second");
cert2 = identity2.getDefaultKey().getDefaultCertificate();
- saveCertToFile(cert2, certPath2.string());
+ saveCert(cert2, certPath2.string());
}
- ~AnchorContainerTestFixture()
+ ~TrustAnchorContainerFixture() override
{
- boost::filesystem::remove_all(UNIT_TEST_CONFIG_PATH);
+ boost::filesystem::remove_all(certDirPath);
}
public:
- TrustAnchorContainer anchorContainer;
+ const boost::filesystem::path certDirPath{boost::filesystem::path(UNIT_TESTS_TMPDIR) / "test-cert-dir"};
+ const boost::filesystem::path certPath1{certDirPath / "trust-anchor-1.cert"};
+ const boost::filesystem::path certPath2{certDirPath / "trust-anchor-2.cert"};
- boost::filesystem::path certDirPath;
- boost::filesystem::path certPath1;
- boost::filesystem::path certPath2;
+ TrustAnchorContainer anchorContainer;
Identity identity1;
Identity identity2;
@@ -83,7 +74,8 @@
Certificate cert2;
};
-BOOST_FIXTURE_TEST_SUITE(TestTrustAnchorContainer, AnchorContainerTestFixture)
+BOOST_AUTO_TEST_SUITE(Security)
+BOOST_FIXTURE_TEST_SUITE(TestTrustAnchorContainer, TrustAnchorContainerFixture)
// one static group and one dynamic group created from file
BOOST_AUTO_TEST_CASE(Insert)
@@ -138,7 +130,7 @@
BOOST_CHECK(anchorContainer.find(identity2.getName()) == nullptr);
BOOST_CHECK_EQUAL(anchorContainer.getGroup("group").size(), 1);
- saveCertToFile(cert2, certPath2.string());
+ saveCert(cert2, certPath2.string());
advanceClocks(100_ms, 11);
@@ -155,7 +147,7 @@
BOOST_CHECK_EQUAL(anchorContainer.getGroup("group").size(), 0);
}
-BOOST_FIXTURE_TEST_CASE(FindByInterest, AnchorContainerTestFixture)
+BOOST_AUTO_TEST_CASE(FindByInterest)
{
anchorContainer.insert("group1", certPath1.string(), 1_s);
Interest interest(identity1.getName());
@@ -165,9 +157,9 @@
Interest interest2(Name(identity1.getName()).appendVersion());
BOOST_CHECK(anchorContainer.find(interest2) == nullptr);
- Certificate cert3 = addCertificate(identity1.getDefaultKey(), "3");
- Certificate cert4 = addCertificate(identity1.getDefaultKey(), "4");
- Certificate cert5 = addCertificate(identity1.getDefaultKey(), "5");
+ auto cert3 = makeCert(identity1.getDefaultKey(), "3");
+ auto cert4 = makeCert(identity1.getDefaultKey(), "4");
+ auto cert5 = makeCert(identity1.getDefaultKey(), "5");
Certificate cert3Copy = cert3;
anchorContainer.insert("group2", std::move(cert3Copy));
diff --git a/tests/unit/security/validation-policy-accept-all.t.cpp b/tests/unit/security/validation-policy-accept-all.t.cpp
index 6a9f0f1..cd94cf7 100644
--- a/tests/unit/security/validation-policy-accept-all.t.cpp
+++ b/tests/unit/security/validation-policy-accept-all.t.cpp
@@ -40,7 +40,7 @@
public:
ValidationPolicyAcceptAllFixture()
{
- identity = addIdentity("/Security/TestValidationPolicyAcceptAll");
+ identity = m_keyChain.createIdentity("/Security/TestValidationPolicyAcceptAll");
// don't add trust anchors
}
diff --git a/tests/unit/security/validation-policy-command-interest.t.cpp b/tests/unit/security/validation-policy-command-interest.t.cpp
index 9f32056..9b8f360 100644
--- a/tests/unit/security/validation-policy-command-interest.t.cpp
+++ b/tests/unit/security/validation-policy-command-interest.t.cpp
@@ -20,13 +20,12 @@
*/
#include "ndn-cxx/security/validation-policy-command-interest.hpp"
+
#include "ndn-cxx/security/command-interest-signer.hpp"
-#include "ndn-cxx/security/signing-helpers.hpp"
#include "ndn-cxx/security/validation-policy-accept-all.hpp"
#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
+#include "tests/test-common.hpp"
#include "tests/unit/security/validator-fixture.hpp"
#include <boost/lexical_cast.hpp>
@@ -239,7 +238,7 @@
advanceClocks(1_s);
auto i3 = makeCommandInterest(identity); // signed at +2s
- systemClock->advance(-18_s); // verifying at -16s
+ m_systemClock->advance(-18_s); // verifying at -16s
VALIDATE_FAILURE(i1, "Should fail (timestamp outside the grace period)");
rewindClockAfterValidation();
@@ -277,11 +276,11 @@
advanceClocks(300_ms);
auto i4 = makeCommandInterest(identity); // signed at +1400ms
- systemClock->advance(-300_ms); // verifying at +1100ms
+ m_systemClock->advance(-300_ms); // verifying at +1100ms
VALIDATE_SUCCESS(i1, "Should succeed");
rewindClockAfterValidation();
- systemClock->advance(-1100_ms); // verifying at 0ms
+ m_systemClock->advance(-1100_ms); // verifying at 0ms
VALIDATE_FAILURE(i2, "Should fail (timestamp reordered)");
rewindClockAfterValidation();
@@ -400,7 +399,7 @@
BOOST_FIXTURE_TEST_CASE(UnlimitedRecords, ValidationPolicyCommandInterestFixture<UnlimitedRecordsOptions>)
{
std::vector<Identity> identities;
- for (int i = 0; i < 20; ++i) {
+ for (size_t i = 0; i < 20; ++i) {
Identity id = this->addSubCertificate("/Security/ValidatorFixture/Sub" + to_string(i), identity);
this->cache.insert(id.getDefaultKey().getDefaultCertificate());
identities.push_back(id);
@@ -408,7 +407,7 @@
auto i1 = makeCommandInterest(identities.at(0)); // signed at 0s
advanceClocks(1_s);
- for (int i = 0; i < 20; ++i) {
+ for (size_t i = 0; i < 20; ++i) {
auto i2 = makeCommandInterest(identities.at(i)); // signed at +1s
VALIDATE_SUCCESS(i2, "Should succeed");
@@ -462,7 +461,7 @@
advanceClocks(120_s);
auto i3 = makeCommandInterest(identity); // signed at +360s
- systemClock->advance(-360_s); // rewind system clock to 0s
+ m_systemClock->advance(-360_s); // rewind system clock to 0s
VALIDATE_SUCCESS(i1, "Should succeed");
rewindClockAfterValidation();
diff --git a/tests/unit/security/validation-policy-config.t.cpp b/tests/unit/security/validation-policy-config.t.cpp
index e660598..38c5986 100644
--- a/tests/unit/security/validation-policy-config.t.cpp
+++ b/tests/unit/security/validation-policy-config.t.cpp
@@ -20,10 +20,10 @@
*/
#include "ndn-cxx/security/validation-policy-config.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/logger.hpp"
#include "ndn-cxx/util/io.hpp"
#include "tests/boost-test.hpp"
@@ -91,7 +91,7 @@
{
public:
ValidationPolicyConfigFixture()
- : path(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "security" / "v2" / "validation-policy-config")
+ : path(boost::filesystem::path(UNIT_TESTS_TMPDIR) / "security" / "validation-policy-config")
{
boost::filesystem::create_directories(path);
baseConfig = R"CONF(
@@ -116,8 +116,7 @@
~ValidationPolicyConfigFixture()
{
- boost::system::error_code ec;
- boost::filesystem::remove_all(path, ec);
+ boost::filesystem::remove_all(path);
}
protected:
@@ -135,7 +134,7 @@
{
BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
- this->saveCertificate(this->identity, (this->path / "identity.ndncert").string());
+ this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
this->policy.load(this->baseConfig + R"CONF(
trust-anchor
{
@@ -167,7 +166,7 @@
)CONF";
}
- this->saveCertificate(this->identity, (this->path / "identity.ndncert").string());
+ this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
@@ -192,7 +191,7 @@
}
)CONF");
- this->saveCertificate(this->identity, (this->path / "identity.ndncert").string());
+ this->saveIdentityCert(this->identity, (this->path / "identity.ndncert").string());
BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
@@ -298,7 +297,7 @@
BOOST_CHECK_EQUAL(this->policy.m_isConfigured, false);
boost::filesystem::create_directories(this->path / "keys");
- this->saveCertificate(this->identity, (this->path / "keys" / "identity.ndncert").string());
+ this->saveIdentityCert(this->identity, (this->path / "keys" / "identity.ndncert").string());
this->policy.load(this->baseConfig + R"CONF(
trust-anchor
diff --git a/tests/unit/security/validation-policy-signed-interest.t.cpp b/tests/unit/security/validation-policy-signed-interest.t.cpp
index f46e5ad..d9cddb5 100644
--- a/tests/unit/security/validation-policy-signed-interest.t.cpp
+++ b/tests/unit/security/validation-policy-signed-interest.t.cpp
@@ -20,13 +20,12 @@
*/
#include "ndn-cxx/security/validation-policy-signed-interest.hpp"
+
#include "ndn-cxx/security/interest-signer.hpp"
-#include "ndn-cxx/security/signing-helpers.hpp"
#include "ndn-cxx/security/validation-policy-accept-all.hpp"
#include "ndn-cxx/security/validation-policy-simple-hierarchy.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/make-interest-data.hpp"
+#include "tests/test-common.hpp"
#include "tests/unit/security/validator-fixture.hpp"
#include <boost/lexical_cast.hpp>
@@ -188,7 +187,7 @@
BOOST_FIXTURE_TEST_CASE(UnlimitedRecords, ValidationPolicySignedInterestFixture<UnlimitedRecordsOptions>)
{
std::vector<Identity> identities;
- for (int i = 0; i < 20; ++i) {
+ for (size_t i = 0; i < 20; ++i) {
Identity id = addSubCertificate("/Security/ValidatorFixture/Sub" + to_string(i), identity);
cache.insert(id.getDefaultKey().getDefaultCertificate());
identities.push_back(id);
@@ -196,7 +195,7 @@
auto i1 = makeSignedInterest(identities.at(0)); // signed at 0s
advanceClocks(1_s);
- for (int i = 0; i < 20; ++i) {
+ for (size_t i = 0; i < 20; ++i) {
auto i2 = makeSignedInterest(identities.at(i)); // signed at +1s
VALIDATE_SUCCESS(i2, "Should succeed");
@@ -295,7 +294,7 @@
advanceClocks(1_s);
auto i3 = makeSignedInterest(identity); // signed at +2s
- systemClock->advance(-18_s); // verifying at -16s
+ m_systemClock->advance(-18_s); // verifying at -16s
VALIDATE_FAILURE(i1, "Should fail (timestamp outside the grace period)");
rewindClockAfterValidation();
@@ -334,11 +333,11 @@
advanceClocks(300_ms);
auto i4 = makeSignedInterest(identity); // signed at +1400ms
- systemClock->advance(-300_ms); // verifying at +1100ms
+ m_systemClock->advance(-300_ms); // verifying at +1100ms
VALIDATE_SUCCESS(i1, "Should succeed");
rewindClockAfterValidation();
- systemClock->advance(-1100_ms); // verifying at 0ms
+ m_systemClock->advance(-1100_ms); // verifying at 0ms
VALIDATE_FAILURE(i2, "Should fail (timestamp reordered)");
rewindClockAfterValidation();
diff --git a/tests/unit/security/validation-policy.t.cpp b/tests/unit/security/validation-policy.t.cpp
index 41cde4d..e982f72 100644
--- a/tests/unit/security/validation-policy.t.cpp
+++ b/tests/unit/security/validation-policy.t.cpp
@@ -22,21 +22,19 @@
#include "ndn-cxx/security/validation-policy.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
namespace ndn {
namespace security {
inline namespace v2 {
namespace tests {
-using namespace ndn::tests;
-
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_FIXTURE_TEST_SUITE(TestValidationPolicy, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_SUITE(TestValidationPolicy, ndn::tests::KeyChainFixture)
BOOST_AUTO_TEST_CASE(ExtractIdentityNameFromKeyLocator)
{
- auto id = addIdentity("/random/identity");
+ auto id = m_keyChain.createIdentity("/random/identity");
auto keyName = id.getDefaultKey().getName();
auto certName = id.getDefaultKey().getDefaultCertificate().getName();
diff --git a/tests/unit/security/validator-config.t.cpp b/tests/unit/security/validator-config.t.cpp
index dac6913..0f4f694 100644
--- a/tests/unit/security/validator-config.t.cpp
+++ b/tests/unit/security/validator-config.t.cpp
@@ -20,12 +20,13 @@
*/
#include "ndn-cxx/security/validator-config.hpp"
+
#include "ndn-cxx/security/certificate-fetcher-offline.hpp"
#include "ndn-cxx/security/command-interest-signer.hpp"
#include "ndn-cxx/util/dummy-client-face.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
+#include "tests/key-chain-fixture.hpp"
#include "tests/unit/security/validator-config/common.hpp"
namespace ndn {
@@ -35,7 +36,7 @@
using namespace ndn::tests;
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_FIXTURE_TEST_SUITE(TestValidatorConfig, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_SUITE(TestValidatorConfig, KeyChainFixture)
// This test only for API, actual tests are in ValidationPolicyConfig and corresponding CertificateFetchers
@@ -46,16 +47,16 @@
ValidatorConfig v1(face);
BOOST_CHECK_EQUAL(v1.m_policyConfig.m_isConfigured, false);
- ValidatorConfig v2(make_unique<v2::CertificateFetcherOffline>());
+ ValidatorConfig v2(make_unique<CertificateFetcherOffline>());
BOOST_CHECK_EQUAL(v2.m_policyConfig.m_isConfigured, false);
}
-class ValidatorConfigFixture : public IdentityManagementFixture
+class ValidatorConfigFixture : public KeyChainFixture
{
public:
ValidatorConfigFixture()
- : path(boost::filesystem::path(UNIT_TEST_CONFIG_PATH) / "security" / "validator-config")
- , validator(make_unique<v2::CertificateFetcherOffline>())
+ : path(boost::filesystem::path(UNIT_TESTS_TMPDIR) / "security" / "validator-config")
+ , validator(make_unique<CertificateFetcherOffline>())
{
boost::filesystem::create_directories(path);
config = R"CONF(
@@ -117,11 +118,11 @@
BOOST_AUTO_TEST_CASE(FromSection)
{
- validator.load(v2::validator_config::tests::makeSection(config), "config-file-from-section");
+ validator.load(validator_config::tests::makeSection(config), "config-file-from-section");
BOOST_CHECK_EQUAL(validator.m_policyConfig.m_isConfigured, true);
// should reload policy
- validator.load(v2::validator_config::tests::makeSection(config), "config-file-from-section");
+ validator.load(validator_config::tests::makeSection(config), "config-file-from-section");
BOOST_CHECK_EQUAL(validator.m_policyConfig.m_isConfigured, true);
}
diff --git a/tests/unit/security/validator-config/checker.t.cpp b/tests/unit/security/validator-config/checker.t.cpp
index 55e48a1..029996c 100644
--- a/tests/unit/security/validator-config/checker.t.cpp
+++ b/tests/unit/security/validator-config/checker.t.cpp
@@ -39,7 +39,7 @@
BOOST_AUTO_TEST_SUITE(Security)
BOOST_AUTO_TEST_SUITE(ValidatorConfig)
-class CheckerFixture : public IdentityManagementFixture
+class CheckerFixture : public KeyChainFixture
{
public:
CheckerFixture()
diff --git a/tests/unit/security/validator-config/common.hpp b/tests/unit/security/validator-config/common.hpp
index de72e3f..c4a4fe3 100644
--- a/tests/unit/security/validator-config/common.hpp
+++ b/tests/unit/security/validator-config/common.hpp
@@ -19,8 +19,8 @@
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
-#ifndef NDN_TESTS_SECURITY_V2_VALIDATOR_CONFIG_COMMON_HPP
-#define NDN_TESTS_SECURITY_V2_VALIDATOR_CONFIG_COMMON_HPP
+#ifndef NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_CONFIG_COMMON_HPP
+#define NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_CONFIG_COMMON_HPP
#include "ndn-cxx/security/validator-config/common.hpp"
@@ -47,4 +47,4 @@
} // namespace security
} // namespace ndn
-#endif // NDN_TESTS_SECURITY_V2_VALIDATOR_CONFIG_COMMON_HPP
+#endif // NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_CONFIG_COMMON_HPP
diff --git a/tests/unit/security/validator-config/filter.t.cpp b/tests/unit/security/validator-config/filter.t.cpp
index 9f6029e..5b77a12 100644
--- a/tests/unit/security/validator-config/filter.t.cpp
+++ b/tests/unit/security/validator-config/filter.t.cpp
@@ -22,7 +22,6 @@
#include "ndn-cxx/security/validator-config/filter.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
#include "tests/unit/security/validator-config/common.hpp"
#include "tests/unit/security/validator-fixture.hpp"
@@ -38,33 +37,35 @@
BOOST_AUTO_TEST_SUITE(Security)
BOOST_AUTO_TEST_SUITE(ValidatorConfig)
-BOOST_FIXTURE_TEST_SUITE(TestFilter, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_SUITE(TestFilter, KeyChainFixture)
#define CHECK_FOR_MATCHES(filter, same, longer, shorter, different) \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/foo/bar", m_keyChain), \
- InterestV02Pkt::makeState()), same); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/foo/bar", m_keyChain), \
- InterestV03Pkt::makeState()), same); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/foo/bar", m_keyChain), \
- DataPkt::makeState()), same); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/foo/bar/bar", m_keyChain), \
- InterestV02Pkt::makeState()), longer); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/foo/bar/bar", m_keyChain), \
- InterestV03Pkt::makeState()), longer); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/foo/bar/bar", m_keyChain), \
- DataPkt::makeState()), longer); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/foo", m_keyChain), \
- InterestV02Pkt::makeState()), shorter); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/foo", m_keyChain), \
- InterestV03Pkt::makeState()), shorter); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/foo", m_keyChain), \
- DataPkt::makeState()), shorter); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/other/prefix", m_keyChain), \
- InterestV02Pkt::makeState()), different); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/other/prefix", m_keyChain), \
- InterestV03Pkt::makeState()), different); \
- BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/other/prefix", m_keyChain), \
- DataPkt::makeState()), different);
+ do { \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/foo/bar", m_keyChain), \
+ InterestV02Pkt::makeState()), same); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/foo/bar", m_keyChain), \
+ InterestV03Pkt::makeState()), same); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/foo/bar", m_keyChain), \
+ DataPkt::makeState()), same); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/foo/bar/bar", m_keyChain), \
+ InterestV02Pkt::makeState()), longer); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/foo/bar/bar", m_keyChain), \
+ InterestV03Pkt::makeState()), longer); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/foo/bar/bar", m_keyChain), \
+ DataPkt::makeState()), longer); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/foo", m_keyChain), \
+ InterestV02Pkt::makeState()), shorter); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/foo", m_keyChain), \
+ InterestV03Pkt::makeState()), shorter); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/foo", m_keyChain), \
+ DataPkt::makeState()), shorter); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV02Pkt::makeName("/other/prefix", m_keyChain), \
+ InterestV02Pkt::makeState()), different); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Interest, InterestV03Pkt::makeName("/other/prefix", m_keyChain), \
+ InterestV03Pkt::makeState()), different); \
+ BOOST_CHECK_EQUAL(filter.match(tlv::Data, DataPkt::makeName("/other/prefix", m_keyChain), \
+ DataPkt::makeState()), different); \
+ } while (false)
BOOST_AUTO_TEST_CASE(RelationName)
{
@@ -90,7 +91,7 @@
CHECK_FOR_MATCHES(f3, false, true, false, false);
}
-BOOST_FIXTURE_TEST_SUITE(Create, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_SUITE(Create, KeyChainFixture)
BOOST_AUTO_TEST_CASE(Errors)
{
diff --git a/tests/unit/security/validator-config/rule.t.cpp b/tests/unit/security/validator-config/rule.t.cpp
index 75eb6dc..04c6e8d 100644
--- a/tests/unit/security/validator-config/rule.t.cpp
+++ b/tests/unit/security/validator-config/rule.t.cpp
@@ -40,7 +40,7 @@
BOOST_AUTO_TEST_SUITE(ValidatorConfig)
template<class Packet>
-class RuleFixture : public IdentityManagementFixture
+class RuleFixture : public KeyChainFixture
{
public:
RuleFixture()
diff --git a/tests/unit/security/validator-fixture.cpp b/tests/unit/security/validator-fixture.cpp
new file mode 100644
index 0000000..8bb4713
--- /dev/null
+++ b/tests/unit/security/validator-fixture.cpp
@@ -0,0 +1,103 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013-2020 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "tests/unit/security/validator-fixture.hpp"
+
+#include "ndn-cxx/security/additional-description.hpp"
+
+namespace ndn {
+namespace security {
+inline namespace v2 {
+namespace tests {
+
+const time::milliseconds ValidatorFixtureBase::s_mockPeriod{250};
+const int ValidatorFixtureBase::s_mockTimes = 200;
+
+ValidatorFixtureBase::ValidatorFixtureBase()
+{
+ processInterest = [this] (const Interest& interest) {
+ auto cert = cache.find(interest);
+ if (cert != nullptr) {
+ face.receive(*cert);
+ }
+ };
+}
+
+void
+ValidatorFixtureBase::mockNetworkOperations()
+{
+ util::signal::ScopedConnection conn = face.onSendInterest.connect([this] (const Interest& interest) {
+ if (processInterest) {
+ m_io.post(bind(processInterest, interest));
+ }
+ });
+ advanceClocks(s_mockPeriod, s_mockTimes);
+}
+
+Identity
+ValidatorFixtureBase::addSubCertificate(const Name& subIdentityName, const Identity& issuer)
+{
+ auto subId = m_keyChain.createIdentity(subIdentityName);
+ auto cert = subId.getDefaultKey().getDefaultCertificate();
+ cert.setName(cert.getKeyName()
+ .append("parent")
+ .appendVersion());
+
+ SignatureInfo info;
+ auto now = time::system_clock::now();
+ info.setValidityPeriod(ValidityPeriod(now, now + 90_days));
+
+ AdditionalDescription description;
+ description.set("type", "sub-certificate");
+ info.addCustomTlv(description.wireEncode());
+
+ m_keyChain.sign(cert, signingByIdentity(issuer).setSignatureInfo(info));
+ m_keyChain.setDefaultCertificate(subId.getDefaultKey(), cert);
+
+ return subId;
+}
+
+Name
+InterestV02Pkt::makeName(Name name, KeyChain& keyChain)
+{
+ Interest interest(name);
+ interest.setCanBePrefix(false);
+ SigningInfo params;
+ params.setSignedInterestFormat(SignedInterestFormat::V02);
+ keyChain.sign(interest, params);
+ return interest.getName();
+}
+
+Name
+InterestV03Pkt::makeName(Name name, KeyChain& keyChain)
+{
+ Interest interest(name);
+ interest.setCanBePrefix(false);
+ SigningInfo params;
+ params.setSignedInterestFormat(SignedInterestFormat::V03);
+ keyChain.sign(interest, params);
+ return interest.getName();
+}
+
+} // namespace tests
+} // inline namespace v2
+} // namespace security
+} // namespace ndn
diff --git a/tests/unit/security/validator-fixture.hpp b/tests/unit/security/validator-fixture.hpp
index e9e5d5b..8da34f0 100644
--- a/tests/unit/security/validator-fixture.hpp
+++ b/tests/unit/security/validator-fixture.hpp
@@ -19,15 +19,15 @@
* See AUTHORS.md for complete list of ndn-cxx authors and contributors.
*/
-#ifndef NDN_TESTS_UNIT_SECURITY_VALIDATOR_FIXTURE_HPP
-#define NDN_TESTS_UNIT_SECURITY_VALIDATOR_FIXTURE_HPP
+#ifndef NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_FIXTURE_HPP
+#define NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_FIXTURE_HPP
#include "ndn-cxx/security/validator.hpp"
#include "ndn-cxx/security/certificate-fetcher-from-network.hpp"
#include "ndn-cxx/util/dummy-client-face.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/identity-management-time-fixture.hpp"
+#include "tests/unit/io-key-chain-fixture.hpp"
#include <boost/lexical_cast.hpp>
@@ -36,27 +36,54 @@
inline namespace v2 {
namespace tests {
-template<class ValidationPolicy, class CertificateFetcher = CertificateFetcherFromNetwork>
-class ValidatorFixture : public ndn::tests::IdentityManagementTimeFixture
+class ValidatorFixtureBase : public ndn::tests::IoKeyChainFixture
{
-public:
- ValidatorFixture()
- : face(io, {true, true})
- , validator(make_unique<ValidationPolicy>(), make_unique<CertificateFetcher>(face))
- , policy(static_cast<ValidationPolicy&>(validator.getPolicy()))
- , cache(100_days)
- , lastError(ValidationError::Code::NO_ERROR)
+protected:
+ ValidatorFixtureBase();
+
+ void
+ mockNetworkOperations();
+
+ /** \brief undo clock advancement of mockNetworkOperations()
+ */
+ void
+ rewindClockAfterValidation()
{
- processInterest = [this] (const Interest& interest) {
- auto cert = cache.find(interest);
- if (cert != nullptr) {
- face.receive(*cert);
- }
- };
+ m_systemClock->advance(s_mockPeriod * s_mockTimes * -1);
}
- virtual
- ~ValidatorFixture() = default;
+ /**
+ * @brief Issues a certificate for @p subIdentityName signed by @p issuer
+ *
+ * If the identity does not exist, it is created.
+ * A new key is generated as the default key for the identity.
+ * A default certificate for the key is signed by the issuer using its default certificate.
+ *
+ * @return The sub-identity
+ */
+ Identity
+ addSubCertificate(const Name& subIdentityName, const Identity& issuer);
+
+protected:
+ util::DummyClientFace face{m_io, {true, true}};
+ std::function<void(const Interest&)> processInterest;
+ CertificateCache cache{100_days};
+ ValidationError lastError{ValidationError::Code::NO_ERROR};
+
+private:
+ const static time::milliseconds s_mockPeriod;
+ const static int s_mockTimes;
+};
+
+template<class ValidationPolicyT, class CertificateFetcherT = CertificateFetcherFromNetwork>
+class ValidatorFixture : public ValidatorFixtureBase
+{
+protected:
+ ValidatorFixture()
+ : validator(make_unique<ValidationPolicyT>(), make_unique<CertificateFetcherT>(face))
+ , policy(static_cast<ValidationPolicyT&>(validator.getPolicy()))
+ {
+ }
template<class Packet>
void
@@ -82,55 +109,21 @@
BOOST_CHECK_EQUAL(nCallbacks, 1);
}
- void
- mockNetworkOperations()
- {
- util::signal::ScopedConnection connection = face.onSendInterest.connect([this] (const Interest& interest) {
- if (processInterest != nullptr) {
- io.post(bind(processInterest, interest));
- }
- });
- advanceClocks(time::milliseconds(s_mockPeriod), s_mockTimes);
- }
-
- /** \brief undo clock advancement of mockNetworkOperations
- */
- void
- rewindClockAfterValidation()
- {
- this->systemClock->advance(time::milliseconds(s_mockPeriod * s_mockTimes * -1));
- }
-
-public:
- util::DummyClientFace face;
- std::function<void(const Interest& interest)> processInterest;
+protected:
Validator validator;
- ValidationPolicy& policy;
-
- CertificateCache cache;
- ValidationError lastError;
-
-private:
- const static int s_mockPeriod;
- const static int s_mockTimes;
+ ValidationPolicyT& policy;
};
-template<class ValidationPolicy, class CertificateFetcher>
-const int ValidatorFixture<ValidationPolicy, CertificateFetcher>::s_mockPeriod = 250;
-
-template<class ValidationPolicy, class CertificateFetcher>
-const int ValidatorFixture<ValidationPolicy, CertificateFetcher>::s_mockTimes = 200;
-
-template<class ValidationPolicy, class CertificateFetcher = CertificateFetcherFromNetwork>
-class HierarchicalValidatorFixture : public ValidatorFixture<ValidationPolicy, CertificateFetcher>
+template<class ValidationPolicyT, class CertificateFetcherT = CertificateFetcherFromNetwork>
+class HierarchicalValidatorFixture : public ValidatorFixture<ValidationPolicyT, CertificateFetcherT>
{
-public:
+protected:
HierarchicalValidatorFixture()
{
- identity = this->addIdentity("/Security/ValidatorFixture");
+ identity = this->m_keyChain.createIdentity("/Security/ValidatorFixture");
subIdentity = this->addSubCertificate("/Security/ValidatorFixture/Sub1", identity);
- subSelfSignedIdentity = this->addIdentity("/Security/ValidatorFixture/Sub1/Sub2");
- otherIdentity = this->addIdentity("/Security/OtherIdentity");
+ subSelfSignedIdentity = this->m_keyChain.createIdentity("/Security/ValidatorFixture/Sub1/Sub2");
+ otherIdentity = this->m_keyChain.createIdentity("/Security/OtherIdentity");
this->validator.loadAnchor("", Certificate(identity.getDefaultKey().getDefaultCertificate()));
@@ -140,34 +133,33 @@
this->cache.insert(otherIdentity.getDefaultKey().getDefaultCertificate());
}
-public:
+protected:
Identity identity;
Identity subIdentity;
Identity subSelfSignedIdentity;
Identity otherIdentity;
};
-#define VALIDATE_SUCCESS(packet, message) this->template validate(packet, message, true, __LINE__)
-#define VALIDATE_FAILURE(packet, message) this->template validate(packet, message, false, __LINE__)
+#define VALIDATE_SUCCESS(packet, message) this->validate(packet, message, true, __LINE__)
+#define VALIDATE_FAILURE(packet, message) this->validate(packet, message, false, __LINE__)
class DummyValidationState : public ValidationState
{
public:
- ~DummyValidationState()
+ ~DummyValidationState() override
{
m_outcome = false;
}
void
- fail(const ValidationError& error) override
+ fail(const ValidationError&) override
{
- // BOOST_TEST_MESSAGE(error);
m_outcome = false;
}
private:
void
- verifyOriginalPacket(const Certificate& trustedCert) override
+ verifyOriginalPacket(const Certificate&) override
{
// do nothing
}
@@ -179,17 +171,16 @@
}
};
-
struct DataPkt
{
- static uint32_t
+ static constexpr uint32_t
getType()
{
return tlv::Data;
}
static Name
- makeName(Name name, KeyChain& keyChain)
+ makeName(Name name, KeyChain&)
{
return name;
}
@@ -203,22 +194,14 @@
struct InterestV02Pkt
{
- static uint32_t
+ static constexpr uint32_t
getType()
{
return tlv::Interest;
}
static Name
- makeName(Name name, KeyChain& keyChain)
- {
- Interest interest(name);
- interest.setCanBePrefix(false);
- SigningInfo params;
- params.setSignedInterestFormat(SignedInterestFormat::V02);
- keyChain.sign(interest, params);
- return interest.getName();
- }
+ makeName(Name name, KeyChain& keyChain);
static shared_ptr<ValidationState>
makeState()
@@ -231,22 +214,14 @@
struct InterestV03Pkt
{
- static uint32_t
+ static constexpr uint32_t
getType()
{
return tlv::Interest;
}
static Name
- makeName(Name name, KeyChain& keyChain)
- {
- Interest interest(name);
- interest.setCanBePrefix(false);
- SigningInfo params;
- params.setSignedInterestFormat(SignedInterestFormat::V03);
- keyChain.sign(interest, params);
- return interest.getName();
- }
+ makeName(Name name, KeyChain& keyChain);
static shared_ptr<ValidationState>
makeState()
@@ -262,4 +237,4 @@
} // namespace security
} // namespace ndn
-#endif // NDN_TESTS_UNIT_SECURITY_VALIDATOR_FIXTURE_HPP
+#endif // NDN_CXX_TESTS_UNIT_SECURITY_VALIDATOR_FIXTURE_HPP
diff --git a/tests/unit/security/validator-null.t.cpp b/tests/unit/security/validator-null.t.cpp
index 103f8f7..9d04cb8 100644
--- a/tests/unit/security/validator-null.t.cpp
+++ b/tests/unit/security/validator-null.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,21 +22,18 @@
#include "ndn-cxx/security/validator-null.hpp"
#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
-#include "tests/make-interest-data.hpp"
+#include "tests/key-chain-fixture.hpp"
namespace ndn {
namespace security {
namespace tests {
-using namespace ndn::tests;
-
BOOST_AUTO_TEST_SUITE(Security)
-BOOST_FIXTURE_TEST_SUITE(TestValidatorNull, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_SUITE(TestValidatorNull, ndn::tests::KeyChainFixture)
BOOST_AUTO_TEST_CASE(ValidateData)
{
- auto identity = addIdentity("/TestValidator/Null");
+ auto identity = m_keyChain.createIdentity("/TestValidator/Null");
Data data("/Some/Other/Data/Name");
m_keyChain.sign(data, signingByIdentity(identity));
@@ -48,7 +45,7 @@
BOOST_AUTO_TEST_CASE(ValidateInterest)
{
- auto identity = addIdentity("/TestValidator/Null");
+ auto identity = m_keyChain.createIdentity("/TestValidator/Null");
Interest interest("/Some/Other/Interest/Name");
m_keyChain.sign(interest, signingByIdentity(identity));
diff --git a/tests/unit/security/validator.t.cpp b/tests/unit/security/validator.t.cpp
index faecf56..adf72d3 100644
--- a/tests/unit/security/validator.t.cpp
+++ b/tests/unit/security/validator.t.cpp
@@ -198,7 +198,7 @@
{
public:
void
- checkPolicy(const Data& data, const shared_ptr<ValidationState>& state,
+ checkPolicy(const Data&, const shared_ptr<ValidationState>& state,
const ValidationContinuation& continueValidation) override
{
continueValidation(nullptr, state);
@@ -264,28 +264,8 @@
// create another key for the same identity and sign it properly
Key parentKey = m_keyChain.createKey(subIdentity);
Key requestedKey = subIdentity.getKey(interest.getName());
-
- Name certificateName = requestedKey.getName();
- certificateName
- .append("looper")
- .appendVersion();
- v2::Certificate certificate;
- certificate.setName(certificateName);
-
- // set metainfo
- certificate.setContentType(tlv::ContentType_Key);
- certificate.setFreshnessPeriod(1_h);
-
- // set content
- certificate.setContent(requestedKey.getPublicKey().data(), requestedKey.getPublicKey().size());
-
- // set signature-info
- SignatureInfo info;
- info.setValidityPeriod(security::ValidityPeriod(time::system_clock::now() - 10_days,
- time::system_clock::now() + 10_days));
-
- m_keyChain.sign(certificate, signingByKey(parentKey).setSignatureInfo(info));
- face.receive(certificate);
+ auto cert = makeCert(requestedKey, "looper", parentKey);
+ face.receive(cert);
};
Data data("/Security/ValidatorFixture/Sub1/Sub2/Data");
@@ -307,13 +287,13 @@
BOOST_AUTO_TEST_CASE(LoopedCertChain)
{
- auto s1 = addIdentity("/loop");
+ auto s1 = m_keyChain.createIdentity("/loop");
auto k1 = m_keyChain.createKey(s1, RsaKeyParams(name::Component("key1")));
auto k2 = m_keyChain.createKey(s1, RsaKeyParams(name::Component("key2")));
auto k3 = m_keyChain.createKey(s1, RsaKeyParams(name::Component("key3")));
auto makeCert = [this] (Key& key, const Key& signer) {
- v2::Certificate request = key.getDefaultCertificate();
+ Certificate request = key.getDefaultCertificate();
request.setName(Name(key.getName()).append("looper").appendVersion());
SignatureInfo info;
diff --git a/tests/unit/security/validity-period.t.cpp b/tests/unit/security/validity-period.t.cpp
index 768e774..1dc7740 100644
--- a/tests/unit/security/validity-period.t.cpp
+++ b/tests/unit/security/validity-period.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2020 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,7 +22,7 @@
#include "ndn-cxx/security/validity-period.hpp"
#include "tests/boost-test.hpp"
-#include "tests/unit/unit-test-time-fixture.hpp"
+#include "tests/unit/clock-fixture.hpp"
#include <boost/lexical_cast.hpp>
@@ -35,14 +35,12 @@
BOOST_AUTO_TEST_SUITE(Security)
BOOST_AUTO_TEST_SUITE(TestValidityPeriod)
-BOOST_FIXTURE_TEST_CASE(ConstructorSetter, UnitTestTimeFixture)
+BOOST_FIXTURE_TEST_CASE(ConstructorSetter, ClockFixture)
{
- time::system_clock::TimePoint now = this->systemClock->getNow();
-
- time::system_clock::TimePoint notBefore = now - 1_day;
- time::system_clock::TimePoint notAfter = notBefore + 2_days;
-
- ValidityPeriod validity1 = ValidityPeriod(notBefore, notAfter);
+ auto now = m_systemClock->getNow();
+ auto notBefore = now - 1_day;
+ auto notAfter = notBefore + 2_days;
+ ValidityPeriod validity1(notBefore, notAfter);
auto period = validity1.getPeriod();
BOOST_CHECK_GE(period.first, notBefore); // fractional seconds will be removed
diff --git a/tests/unit/security/verification-helpers.t.cpp b/tests/unit/security/verification-helpers.t.cpp
index f1e7185..476bbe3 100644
--- a/tests/unit/security/verification-helpers.t.cpp
+++ b/tests/unit/security/verification-helpers.t.cpp
@@ -23,9 +23,8 @@
#include "ndn-cxx/security/transform/public-key.hpp"
// #include "ndn-cxx/util/string-helper.hpp"
-#include "tests/boost-test.hpp"
-#include "tests/identity-management-fixture.hpp"
-#include "tests/make-interest-data.hpp"
+#include "tests/key-chain-fixture.hpp"
+#include "tests/test-common.hpp"
#include <boost/mpl/vector.hpp>
@@ -39,12 +38,12 @@
BOOST_AUTO_TEST_SUITE(TestVerificationHelpers)
// // Use this test case to regenerate the dataset if the signature format changes
-// BOOST_FIXTURE_TEST_CASE(Generator, IdentityManagementFixture)
+// BOOST_FIXTURE_TEST_CASE(Generator, KeyChainFixture)
// {
-// Identity wrongIdentity = addIdentity("/Security/TestVerificationHelpers/Wrong");
+// Identity wrongIdentity = m_keyChain.createIdentity("/Security/TestVerificationHelpers/Wrong");
// std::map<std::string, SigningInfo> identities = {
-// {"Ecdsa", signingByIdentity(addIdentity("/Security/TestVerificationHelpers/EC", EcKeyParams()))},
-// {"Rsa", signingByIdentity(addIdentity("/Security/TestVerificationHelpers/RSA", RsaKeyParams()))},
+// {"Ecdsa", signingByIdentity(m_keyChain.createIdentity("/Security/TestVerificationHelpers/EC", EcKeyParams()))},
+// {"Rsa", signingByIdentity(m_keyChain.createIdentity("/Security/TestVerificationHelpers/RSA", RsaKeyParams()))},
// {"Sha256", signingWithSha256()}
// };
@@ -601,7 +600,7 @@
// - pib::Key version is tested as part of key-chain.t.cpp (Security/TestKeyChain)
}
-BOOST_FIXTURE_TEST_CASE(VerifyHmac, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_CASE(VerifyHmac, KeyChainFixture)
{
const Tpm& tpm = m_keyChain.getTpm();
Data data("/data");