Reduce namespace nesting (ndn::ndncert -> ndncert)
Change-Id: I5b69a2c3673cccdf07ea0ba3a0e7181894328f47
diff --git a/tests/database-fixture.hpp b/tests/database-fixture.hpp
index 598e304..53f813e 100644
--- a/tests/database-fixture.hpp
+++ b/tests/database-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -24,9 +24,9 @@
#include "identity-management-fixture.hpp"
#include "unit-test-time-fixture.hpp"
+
#include <boost/filesystem.hpp>
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -58,6 +58,5 @@
} // namespace tests
} // namespace ndncert
-} // namespace ndn
#endif // NDNCERT_TESTS_DATABASE_FIXTURE_HPP
diff --git a/tests/global-configuration.cpp b/tests/global-configuration.cpp
index 61d0cbd..0c92646 100644
--- a/tests/global-configuration.cpp
+++ b/tests/global-configuration.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -18,12 +18,14 @@
* See AUTHORS.md for complete list of ndncert authors and contributors.
*/
+#include "detail/ndncert-common.hpp"
+
#include "boost-test.hpp"
+
#include <boost/filesystem.hpp>
#include <fstream>
#include <stdlib.h>
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -36,19 +38,22 @@
if (envHome)
m_home = envHome;
- boost::filesystem::path dir{TMP_TESTS_PATH};
- dir /= "test-home";
- ::setenv("HOME", dir.c_str(), 1);
+ auto testHome = boost::filesystem::path(TMP_TESTS_PATH) / "test-home";
+ if (::setenv("HOME", testHome.c_str(), 1) != 0)
+ NDN_THROW(std::runtime_error("setenv() failed"));
- boost::filesystem::create_directories(dir);
- std::ofstream clientConf((dir / ".ndn" / "client.conf").c_str());
+ boost::filesystem::create_directories(testHome);
+
+ std::ofstream clientConf((testHome / ".ndn" / "client.conf").c_str());
clientConf << "pib=pib-sqlite3" << std::endl
<< "tpm=tpm-file" << std::endl;
}
- ~GlobalConfiguration()
+ ~GlobalConfiguration() noexcept
{
- if (!m_home.empty())
+ if (m_home.empty())
+ ::unsetenv("HOME");
+ else
::setenv("HOME", m_home.data(), 1);
}
@@ -66,4 +71,3 @@
} // namespace tests
} // namespace ndncert
-} // namespace ndn
\ No newline at end of file
diff --git a/tests/identity-management-fixture.cpp b/tests/identity-management-fixture.cpp
index 8ca0545..c4a4590 100644
--- a/tests/identity-management-fixture.cpp
+++ b/tests/identity-management-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -20,15 +20,16 @@
*/
#include "identity-management-fixture.hpp"
+
#include <ndn-cxx/security/additional-description.hpp>
#include <ndn-cxx/util/io.hpp>
+
#include <boost/filesystem.hpp>
-namespace ndn {
namespace ndncert {
namespace tests {
-namespace v2 = security::v2;
+using namespace ndn::security;
IdentityManagementBaseFixture::~IdentityManagementBaseFixture()
{
@@ -43,10 +44,10 @@
{
m_certFiles.insert(filename);
try {
- io::save(obj, filename);
+ ndn::io::save(obj, filename);
return true;
}
- catch (const io::Error&) {
+ catch (const ndn::io::Error&) {
return false;
}
}
@@ -56,8 +57,8 @@
{
}
-security::Identity
-IdentityManagementFixture::addIdentity(const Name& identityName, const KeyParams& params)
+Identity
+IdentityManagementFixture::addIdentity(const Name& identityName, const ndn::KeyParams& params)
{
auto identity = m_keyChain.createIdentity(identityName, params);
m_identities.insert(identityName);
@@ -65,32 +66,31 @@
}
bool
-IdentityManagementFixture::saveCertificate(const security::Identity& identity, const std::string& filename)
+IdentityManagementFixture::saveCertificate(const Identity& identity, const std::string& filename)
{
try {
auto cert = identity.getDefaultKey().getDefaultCertificate();
return saveCertToFile(cert, filename);
}
- catch (const security::Pib::Error&) {
+ catch (const Pib::Error&) {
return false;
}
}
-security::Identity
+Identity
IdentityManagementFixture::addSubCertificate(const Name& subIdentityName,
- const security::Identity& issuer, const KeyParams& params)
+ const Identity& issuer, const ndn::KeyParams& params)
{
auto subIdentity = addIdentity(subIdentityName, params);
- v2::Certificate request = subIdentity.getDefaultKey().getDefaultCertificate();
-
+ Certificate request = subIdentity.getDefaultKey().getDefaultCertificate();
request.setName(request.getKeyName().append("parent").appendVersion());
SignatureInfo info;
auto now = time::system_clock::now();
- info.setValidityPeriod(security::ValidityPeriod(now, now + 7300_days));
+ info.setValidityPeriod(ValidityPeriod(now, now + 7300_days));
- v2::AdditionalDescription description;
+ AdditionalDescription description;
description.set("type", "sub-certificate");
info.addCustomTlv(description.wireEncode());
@@ -100,14 +100,14 @@
return subIdentity;
}
-v2::Certificate
-IdentityManagementFixture::addCertificate(const security::Key& key, const std::string& issuer)
+Certificate
+IdentityManagementFixture::addCertificate(const Key& key, const std::string& issuer)
{
Name certificateName = key.getName();
certificateName
.append(issuer)
.appendVersion();
- v2::Certificate certificate;
+ Certificate certificate;
certificate.setName(certificateName);
// set metainfo
@@ -120,7 +120,7 @@
// set signature-info
SignatureInfo info;
auto now = time::system_clock::now();
- info.setValidityPeriod(security::ValidityPeriod(now, now + 10_days));
+ info.setValidityPeriod(ValidityPeriod(now, now + 10_days));
m_keyChain.sign(certificate, signingByKey(key).setSignatureInfo(info));
return certificate;
@@ -128,4 +128,3 @@
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/identity-management-fixture.hpp b/tests/identity-management-fixture.hpp
index 9b10dbf..7856bf9 100644
--- a/tests/identity-management-fixture.hpp
+++ b/tests/identity-management-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,11 +22,11 @@
#ifndef NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
#define NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
+#include "detail/ndncert-common.hpp"
+
#include <ndn-cxx/security/key-chain.hpp>
#include <ndn-cxx/security/signing-helpers.hpp>
-#include <vector>
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -51,6 +51,10 @@
*/
class IdentityManagementFixture : public IdentityManagementBaseFixture
{
+protected:
+ using Identity = ndn::security::Identity;
+ using Key = ndn::security::Key;
+
public:
IdentityManagementFixture();
@@ -58,9 +62,9 @@
* @brief Add identity @p identityName
* @return name of the created self-signed certificate
*/
- security::Identity
+ Identity
addIdentity(const Name& identityName,
- const KeyParams& params = security::KeyChain::getDefaultKeyParams());
+ const ndn::KeyParams& params = ndn::KeyChain::getDefaultKeyParams());
/**
* @brief Save identity certificate to a file
@@ -69,7 +73,7 @@
* @return whether successful
*/
bool
- saveCertificate(const security::Identity& identity, const std::string& filename);
+ saveCertificate(const Identity& identity, const std::string& filename);
/**
* @brief Issue a certificate for \p subIdentityName signed by \p issuer
@@ -80,22 +84,21 @@
*
* @return the sub identity
*/
- security::Identity
- addSubCertificate(const Name& subIdentityName, const security::Identity& issuer,
- const KeyParams& params = security::KeyChain::getDefaultKeyParams());
+ Identity
+ addSubCertificate(const Name& subIdentityName, const Identity& issuer,
+ const ndn::KeyParams& params = ndn::KeyChain::getDefaultKeyParams());
/**
* @brief Add a self-signed certificate to @p key with issuer ID @p issuer
*/
- security::Certificate
- addCertificate(const security::Key& key, const std::string& issuer);
+ Certificate
+ addCertificate(const Key& key, const std::string& issuer);
protected:
- KeyChain m_keyChain;
+ ndn::KeyChain m_keyChain;
};
} // namespace tests
} // namespace ndncert
-} // namespace ndn
#endif // NDN_TESTS_IDENTITY_MANAGEMENT_FIXTURE_HPP
diff --git a/tests/unit-test-time-fixture.hpp b/tests/unit-test-time-fixture.hpp
index cebce38..c497940 100644
--- a/tests/unit-test-time-fixture.hpp
+++ b/tests/unit-test-time-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2021 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -22,10 +22,12 @@
#ifndef NDN_TESTS_UNIT_UNIT_TEST_TIME_FIXTURE_HPP
#define NDN_TESTS_UNIT_UNIT_TEST_TIME_FIXTURE_HPP
+#include "detail/ndncert-common.hpp"
+
#include <ndn-cxx/util/time-unit-test-clock.hpp>
+
#include <boost/asio/io_service.hpp>
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -35,8 +37,8 @@
{
public:
UnitTestTimeFixture()
- : steadyClock(make_shared<time::UnitTestSteadyClock>())
- , systemClock(make_shared<time::UnitTestSystemClock>())
+ : steadyClock(std::make_shared<time::UnitTestSteadyClock>())
+ , systemClock(std::make_shared<time::UnitTestSystemClock>())
{
time::setCustomClocks(steadyClock, systemClock);
}
@@ -95,13 +97,12 @@
}
public:
- shared_ptr<time::UnitTestSteadyClock> steadyClock;
- shared_ptr<time::UnitTestSystemClock> systemClock;
+ std::shared_ptr<time::UnitTestSteadyClock> steadyClock;
+ std::shared_ptr<time::UnitTestSystemClock> systemClock;
boost::asio::io_service io;
};
} // namespace tests
} // namespace ndncert
-} // namespace ndn
#endif // NDN_TESTS_UNIT_UNIT_TEST_TIME_FIXTURE_HPP
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 7e321e3..5dbdb3b 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -24,31 +24,28 @@
#include "requester-request.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(TestForBenchmark, IdentityManagementTimeFixture)
+BOOST_FIXTURE_TEST_SUITE(Benchmark, IdentityManagementTimeFixture)
BOOST_AUTO_TEST_CASE(PacketSize0)
{
- name::setConventionEncoding(name::Convention::TYPED);
-
auto identity = addIdentity(Name("/ndn"));
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ ndn::util::DummyClientFace face(io, m_keyChain, {true, true});
ca::CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
auto profileData = ca.getCaProfileData();
- Interest interest = MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
+ Interest interest = ndn::MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
// std::cout << "CA Config discovery Interest Size: " << interest.wireEncode().size() << std::endl;
- shared_ptr<Interest> infoInterest = nullptr;
+ std::shared_ptr<Interest> infoInterest;
face.setInterestFilter(
- InterestFilter("/ndn/CA/INFO"),
+ ndn::InterestFilter("/ndn/CA/INFO"),
[&](const auto&, const Interest& interest) {
// std::cout << interest.getName() << std::endl;
if (interest.getName() == profileData.getName()) {
@@ -72,7 +69,7 @@
else {
count++;
// std::cout << "CA Config Data Size: " << response.wireEncode().size() << std::endl;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(ndn::security::verifySignature(response, cert));
auto contentBlock = response.getContent();
contentBlock.parse();
auto caItem = infotlv::decodeDataContent(contentBlock);
@@ -97,25 +94,25 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ ndn::util::DummyClientFace face(io, m_keyChain, {true, true});
ca::CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
// generate NEW Interest
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto newInterest = state.genNewInterest(Name("/ndn/alice"),
- time::system_clock::now(),
- time::system_clock::now() + time::days(1));
+ time::system_clock::now(),
+ time::system_clock::now() + time::days(1));
// std::cout << "New Interest Size: " << newInterest->wireEncode().size() << std::endl;
// generate CHALLENGE Interest
- shared_ptr<Interest> challengeInterest = nullptr;
- shared_ptr<Interest> challengeInterest2 = nullptr;
- shared_ptr<Interest> challengeInterest3 = nullptr;
+ std::shared_ptr<Interest> challengeInterest;
+ std::shared_ptr<Interest> challengeInterest2;
+ std::shared_ptr<Interest> challengeInterest3;
int count = 0;
face.onSendData.connect([&](const Data& response) {
@@ -127,7 +124,7 @@
}
else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 0) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(ndn::security::verifySignature(response, cert));
state.onChallengeResponse(response);
BOOST_CHECK(state.m_status == Status::CHALLENGE);
@@ -137,7 +134,7 @@
}
else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 1) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(ndn::security::verifySignature(response, cert));
state.onChallengeResponse(response);
BOOST_CHECK(state.m_status == Status::CHALLENGE);
@@ -153,7 +150,7 @@
else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 2) {
// std::cout << "CHALLENGE Data Size: " << response.wireEncode().size() << std::endl;
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(ndn::security::verifySignature(response, cert));
state.onChallengeResponse(response);
BOOST_CHECK(state.m_status == Status::SUCCESS);
}
@@ -170,8 +167,7 @@
BOOST_CHECK_EQUAL(count, 3);
}
-BOOST_AUTO_TEST_SUITE_END() // TestCaConfig
+BOOST_AUTO_TEST_SUITE_END() // Benchmark
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/ca-memory.t.cpp b/tests/unit-tests/ca-memory.t.cpp
index 290e4ca..fd6f9a5 100644
--- a/tests/unit-tests/ca-memory.t.cpp
+++ b/tests/unit-tests/ca-memory.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -22,7 +22,6 @@
#include "detail/ca-sqlite.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -93,8 +92,7 @@
BOOST_CHECK_EQUAL(allRequests.size(), 1);
}
-BOOST_AUTO_TEST_SUITE_END() // TestCaModule
+BOOST_AUTO_TEST_SUITE_END() // TestCaMemory
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 385f7ef..d4a733d 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -26,17 +26,18 @@
#include "requester-request.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
using namespace ca;
+using ndn::util::DummyClientFace;
+using ndn::security::verifySignature;
BOOST_FIXTURE_TEST_SUITE(TestCaModule, DatabaseFixture)
BOOST_AUTO_TEST_CASE(Initialization)
{
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
BOOST_CHECK_EQUAL(ca.getCaConf().caProfile.caPrefix, "/ndn");
@@ -47,22 +48,20 @@
BOOST_AUTO_TEST_CASE(HandleProfileFetching)
{
- name::setConventionEncoding(name::Convention::TYPED);
-
auto identity = addIdentity(Name("/ndn"));
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
auto profileData = ca.getCaProfileData();
- Interest interest = MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
- shared_ptr<Interest> infoInterest = nullptr;
+ Interest interest = ndn::MetadataObject::makeDiscoveryInterest(Name("/ndn/CA/INFO"));
+ std::shared_ptr<Interest> infoInterest = nullptr;
face.setInterestFilter(
- InterestFilter("/ndn/CA/INFO"),
+ ndn::InterestFilter("/ndn/CA/INFO"),
[&](const auto&, const Interest& interest) {
if (interest.getName() == profileData.getName()) {
face.put(profileData);
@@ -77,12 +76,12 @@
count++;
auto block = response.getContent();
block.parse();
- infoInterest =std::make_shared<Interest>(Name(block.get(ndn::tlv::Name)).appendSegment(0));
+ infoInterest = std::make_shared<Interest>(Name(block.get(ndn::tlv::Name)).appendSegment(0));
infoInterest->setCanBePrefix(false);
}
else {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
auto contentBlock = response.getContent();
contentBlock.parse();
auto caItem = infotlv::decodeDataContent(contentBlock);
@@ -107,16 +106,16 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
Interest interest("/ndn/CA/PROBE");
interest.setCanBePrefix(false);
- Block paramTLV = makeEmptyBlock(ndn::tlv::ApplicationParameters);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, "name"));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "zhiyi"));
+ Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
paramTLV.encode();
interest.setApplicationParameters(paramTLV);
@@ -124,7 +123,7 @@
int count = 0;
face.onSendData.connect([&](const Data& response) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
Block contentBlock = response.getContent();
contentBlock.parse();
Block probeResponse = contentBlock.get(tlv::ProbeResponse);
@@ -145,16 +144,16 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
Interest interest("/ndn/CA/PROBE");
interest.setCanBePrefix(false);
- Block paramTLV = makeEmptyBlock(ndn::tlv::ApplicationParameters);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, "name"));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "zhiyi"));
+ Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
paramTLV.encode();
interest.setApplicationParameters(paramTLV);
@@ -162,7 +161,7 @@
int count = 0;
face.onSendData.connect([&](const Data& response) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
auto contentBlock = response.getContent();
contentBlock.parse();
auto probeResponseBlock = contentBlock.get(tlv::ProbeResponse);
@@ -183,16 +182,16 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-5", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
Interest interest("/ndn/CA/PROBE");
interest.setCanBePrefix(false);
- Block paramTLV = makeEmptyBlock(ndn::tlv::ApplicationParameters);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, "name"));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "zhiyi"));
+ Block paramTLV = ndn::makeEmptyBlock(ndn::tlv::ApplicationParameters);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, "name"));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi"));
paramTLV.encode();
interest.setApplicationParameters(paramTLV);
@@ -200,7 +199,7 @@
int count = 0;
face.onSendData.connect([&](const Data& response) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
Block contentBlock = response.getContent();
contentBlock.parse();
@@ -212,8 +211,8 @@
}
}
BOOST_CHECK_EQUAL(redirectionItems.size(), 2);
- BOOST_CHECK_EQUAL(security::extractIdentityFromCertName(redirectionItems[0].getPrefix(-1)), "/ndn/site1");
- BOOST_CHECK_EQUAL(security::extractIdentityFromCertName(redirectionItems[1].getPrefix(-1)), "/ndn/site1");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[0].getPrefix(-1)), "/ndn/site1");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirectionItems[1].getPrefix(-1)), "/ndn/site1");
});
face.receive(interest);
advanceClocks(time::milliseconds(20), 60);
@@ -226,13 +225,13 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto interest = state.genNewInterest(Name("/ndn/zhiyi"),
time::system_clock::now(),
@@ -241,7 +240,7 @@
int count = 0;
face.onSendData.connect([&](const Data& response) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
auto contentBlock = response.getContent();
contentBlock.parse();
@@ -277,13 +276,13 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1");
advanceClocks(time::milliseconds(20), 60);
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto current_tp = time::system_clock::now();
auto interest1 = state.genNewInterest(Name("/ndn/zhiyi"), current_tp, current_tp - time::hours(1));
@@ -308,22 +307,23 @@
auto key = identity.getDefaultKey();
//build expired cert
- security::Certificate cert;
+ Certificate cert;
cert.setName(Name(key.getName()).append("self-sign").appendVersion());
cert.setContentType(ndn::tlv::ContentType_Key);
cert.setContent(key.getPublicKey().data(), key.getPublicKey().size());
SignatureInfo signatureInfo;
- signatureInfo.setValidityPeriod(security::ValidityPeriod(time::system_clock::now() - time::days(1), time::system_clock::now() - time::seconds(1)));
+ signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now() - time::days(1),
+ time::system_clock::now() - time::seconds(1)));
m_keyChain.sign(cert, signingByKey(key.getName()).setSignatureInfo(signatureInfo));
m_keyChain.setDefaultCertificate(key, cert);
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto interest = state.genNewInterest(Name("/ndn/zhiyi"),
time::system_clock::now(),
@@ -349,13 +349,13 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto interest1 = state.genNewInterest(Name("/ndn/a"), time::system_clock::now(),
@@ -374,8 +374,7 @@
}
else {
// should successfully get responses
- BOOST_CHECK_EXCEPTION(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode)), std::runtime_error,
- [](const auto& e) { return true; });
+ BOOST_CHECK_THROW(readNonNegativeInteger(contentTlv.get(tlv::ErrorCode)), std::runtime_error);
}
});
face.receive(*interest1);
@@ -390,13 +389,13 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1");
advanceClocks(time::milliseconds(20), 60);
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto current_tp = time::system_clock::now();
@@ -420,23 +419,23 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ DummyClientFace face(io, m_keyChain, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
// generate NEW Interest
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto newInterest = state.genNewInterest(Name("/ndn/zhiyi"), time::system_clock::now(),
time::system_clock::now() + time::days(1));
// generate CHALLENGE Interest
- shared_ptr<Interest> challengeInterest = nullptr;
- shared_ptr<Interest> challengeInterest2 = nullptr;
- shared_ptr<Interest> challengeInterest3 = nullptr;
+ std::shared_ptr<Interest> challengeInterest;
+ std::shared_ptr<Interest> challengeInterest2;
+ std::shared_ptr<Interest> challengeInterest3;
int count = 0;
face.onSendData.connect([&](const Data& response) {
@@ -447,7 +446,7 @@
}
else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 0) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
state.onChallengeResponse(response);
BOOST_CHECK(state.m_status == Status::CHALLENGE);
@@ -457,7 +456,7 @@
}
else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 1) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
state.onChallengeResponse(response);
BOOST_CHECK(state.m_status == Status::CHALLENGE);
@@ -471,7 +470,7 @@
}
else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 2) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
state.onChallengeResponse(response);
BOOST_CHECK(state.m_status == Status::SUCCESS);
}
@@ -494,21 +493,21 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, {true, true});
+ DummyClientFace face(io, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
//generate a certificate
auto clientIdentity = m_keyChain.createIdentity("/ndn/qwerty");
auto clientKey = clientIdentity.getDefaultKey();
- security::Certificate clientCert;
+ Certificate clientCert;
clientCert.setName(Name(clientKey.getName()).append("cert-request").appendVersion());
clientCert.setContentType(ndn::tlv::ContentType_Key);
clientCert.setFreshnessPeriod(time::hours(24));
clientCert.setContent(clientKey.getPublicKey().data(), clientKey.getPublicKey().size());
SignatureInfo signatureInfo;
- signatureInfo.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(),
- time::system_clock::now() + time::hours(10)));
+ signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
+ time::system_clock::now() + time::hours(10)));
m_keyChain.sign(clientCert, signingByKey(clientKey.getName()).setSignatureInfo(signatureInfo));
RequestId requestId = {{101}};
RequestState certRequest;
@@ -521,7 +520,7 @@
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::REVOKE);
auto interest = state.genRevokeInterest(issuedCert);
@@ -529,7 +528,7 @@
int count = 0;
face.onSendData.connect([&](const Data& response) {
count++;
- BOOST_CHECK(security::verifySignature(response, cert));
+ BOOST_CHECK(verifySignature(response, cert));
auto contentBlock = response.getContent();
contentBlock.parse();
@@ -565,26 +564,26 @@
auto key = identity.getDefaultKey();
auto cert = key.getDefaultCertificate();
- util::DummyClientFace face(io, {true, true});
+ DummyClientFace face(io, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-1", "ca-storage-memory");
advanceClocks(time::milliseconds(20), 60);
// generate a certificate
auto clientIdentity = m_keyChain.createIdentity("/ndn/qwerty");
auto clientKey = clientIdentity.getDefaultKey();
- security::Certificate clientCert;
- clientCert.setName(Name(clientKey.getName()).append("NDNCERT").append(std::to_string(1473283247810732701)));
+ Certificate clientCert;
+ clientCert.setName(Name(clientKey.getName()).append("NDNCERT").append("1473283247810732701"));
clientCert.setContentType(ndn::tlv::ContentType_Key);
clientCert.setFreshnessPeriod(time::hours(24));
clientCert.setContent(clientKey.getPublicKey().data(), clientKey.getPublicKey().size());
SignatureInfo signatureInfo;
- signatureInfo.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(),
- time::system_clock::now() + time::hours(10)));
+ signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
+ time::system_clock::now() + time::hours(10)));
m_keyChain.sign(clientCert, signingByKey(clientKey.getName()).setSignatureInfo(signatureInfo));
CaProfile item;
item.caPrefix = Name("/ndn");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
requester::Request state(m_keyChain, item, RequestType::NEW);
auto interest = state.genRevokeInterest(clientCert);
@@ -602,8 +601,7 @@
BOOST_CHECK_EQUAL(receiveData, true);
}
-BOOST_AUTO_TEST_SUITE_END() // TestCaModule
+BOOST_AUTO_TEST_SUITE_END() // TestCaModule
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/ca-sqlite.t.cpp b/tests/unit-tests/ca-sqlite.t.cpp
index 78077db..c592d47 100644
--- a/tests/unit-tests/ca-sqlite.t.cpp
+++ b/tests/unit-tests/ca-sqlite.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -21,7 +21,6 @@
#include "detail/ca-sqlite.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -130,8 +129,7 @@
BOOST_CHECK_THROW(storage.addRequest(request1), std::runtime_error);
}
-BOOST_AUTO_TEST_SUITE_END() // TestCaModule
+BOOST_AUTO_TEST_SUITE_END() // TestCaSqlite
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/challenge-email.t.cpp b/tests/unit-tests/challenge-email.t.cpp
index 8ee9be9..92fb45b 100644
--- a/tests/unit-tests/challenge-email.t.cpp
+++ b/tests/unit-tests/challenge-email.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -21,7 +21,6 @@
#include "challenge/challenge-email.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -52,9 +51,9 @@
request.requestType = RequestType::NEW;
request.cert = cert;
- Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_EMAIL));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "zhiyi@cs.ucla.edu"));
+ Block paramTLV = ndn::makeEmptyBlock(tlv::EncryptedPayload);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_EMAIL));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi@cs.ucla.edu"));
ChallengeEmail challenge("./tests/unit-tests/test-send-email.sh");
challenge.handleChallengeRequest(paramTLV, request);
@@ -106,9 +105,9 @@
request.requestType = RequestType::NEW;
request.cert = cert;
- Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_EMAIL));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "zhiyi@cs"));
+ Block paramTLV = ndn::makeEmptyBlock(tlv::EncryptedPayload);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_EMAIL));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "zhiyi@cs"));
ChallengeEmail challenge;
challenge.handleChallengeRequest(paramTLV, request);
@@ -136,9 +135,9 @@
request.challengeState = ca::ChallengeState(ChallengeEmail::NEED_CODE, time::system_clock::now(),
3, time::seconds(3600), std::move(secret));
- Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_CODE));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "4567"));
+ Block paramTLV = ndn::makeEmptyBlock(tlv::EncryptedPayload);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_CODE));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "4567"));
ChallengeEmail challenge;
challenge.handleChallengeRequest(paramTLV, request);
@@ -165,9 +164,9 @@
request.challengeState = ca::ChallengeState(ChallengeEmail::NEED_CODE, time::system_clock::now(),
3, time::seconds(3600), std::move(secret));
- Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_CODE));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "7890"));
+ Block paramTLV = ndn::makeEmptyBlock(tlv::EncryptedPayload);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, ChallengeEmail::PARAMETER_KEY_CODE));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "7890"));
ChallengeEmail challenge;
challenge.handleChallengeRequest(paramTLV, request);
@@ -177,8 +176,7 @@
BOOST_CHECK_EQUAL(request.challengeState->secrets.empty(), false);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestChallengeEmail
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/challenge-pin.t.cpp b/tests/unit-tests/challenge-pin.t.cpp
index 61167d0..b835089 100644
--- a/tests/unit-tests/challenge-pin.t.cpp
+++ b/tests/unit-tests/challenge-pin.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -21,7 +21,6 @@
#include "challenge/challenge-pin.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -46,7 +45,7 @@
request.cert = cert;
ChallengePin challenge;
- challenge.handleChallengeRequest(makeEmptyBlock(tlv::EncryptedPayload), request);
+ challenge.handleChallengeRequest(ndn::makeEmptyBlock(tlv::EncryptedPayload), request);
BOOST_CHECK(request.status == Status::CHALLENGE);
BOOST_CHECK_EQUAL(request.challengeState->challengeStatus, ChallengePin::NEED_CODE);
@@ -71,9 +70,9 @@
request.challengeState = ca::ChallengeState(ChallengePin::NEED_CODE, time::system_clock::now(),
3, time::seconds(3600), std::move(secret));
- Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengePin::PARAMETER_KEY_CODE));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "12345"));
+ Block paramTLV = ndn::makeEmptyBlock(tlv::EncryptedPayload);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, ChallengePin::PARAMETER_KEY_CODE));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "12345"));
ChallengePin challenge;
challenge.handleChallengeRequest(paramTLV, request);
@@ -100,9 +99,9 @@
request.challengeState = ca::ChallengeState(ChallengePin::NEED_CODE, time::system_clock::now(),
3, time::seconds(3600), std::move(secret));
- Block paramTLV = makeEmptyBlock(tlv::EncryptedPayload);
- paramTLV.push_back(makeStringBlock(tlv::ParameterKey, ChallengePin::PARAMETER_KEY_CODE));
- paramTLV.push_back(makeStringBlock(tlv::ParameterValue, "45678"));
+ Block paramTLV = ndn::makeEmptyBlock(tlv::EncryptedPayload);
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterKey, ChallengePin::PARAMETER_KEY_CODE));
+ paramTLV.push_back(ndn::makeStringBlock(tlv::ParameterValue, "45678"));
ChallengePin challenge;
challenge.handleChallengeRequest(paramTLV, request);
@@ -112,8 +111,7 @@
BOOST_CHECK_EQUAL(request.challengeState->secrets.empty(), false);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestChallengePin
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/challenge-possession.t.cpp b/tests/unit-tests/challenge-possession.t.cpp
index 84d05d5..2c76c3d 100644
--- a/tests/unit-tests/challenge-possession.t.cpp
+++ b/tests/unit-tests/challenge-possession.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -19,14 +19,13 @@
*/
#include "challenge/challenge-possession.hpp"
-#include "test-common.hpp"
#include "detail/challenge-encoder.hpp"
+#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
-BOOST_FIXTURE_TEST_SUITE(TestChallengeCredential, IdentityManagementFixture)
+BOOST_FIXTURE_TEST_SUITE(TestChallengePossession, IdentityManagementFixture)
BOOST_AUTO_TEST_CASE(LoadConfig)
{
@@ -65,12 +64,12 @@
auto identityB = addIdentity(Name("/trust/cert"));
auto keyB = identityB.getDefaultKey();
auto credentialName = Name(keyB.getName()).append("Credential").appendVersion();
- security::Certificate credential;
+ Certificate credential;
credential.setName(credentialName);
credential.setContent(keyB.getPublicKey().data(), keyB.getPublicKey().size());
SignatureInfo signatureInfo;
- signatureInfo.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(), time::system_clock::now() +
- time::minutes(1)));
+ signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
+ time::system_clock::now() + time::minutes(1)));
m_keyChain.sign(credential, signingByCertificate(trustAnchor).setSignatureInfo(signatureInfo));
m_keyChain.addCertificate(keyB, credential);
@@ -83,7 +82,7 @@
BOOST_CHECK_EQUAL(state.challengeState->challengeStatus, "need-proof");
// reply from server
- auto nonceBuf = fromHex(state.challengeState->secrets.get("nonce", ""));
+ auto nonceBuf = ndn::fromHex(state.challengeState->secrets.get("nonce", ""));
std::array<uint8_t, 16> nonce{};
memcpy(nonce.data(), nonceBuf->data(), 16);
auto params2 = challenge.getRequestedParameterList(state.status, state.challengeState->challengeStatus);
@@ -118,12 +117,12 @@
auto identityB = addIdentity(Name("/trust/cert"));
auto keyB = identityB.getDefaultKey();
auto credentialName = Name(keyB.getName()).append("Credential").appendVersion();
- security::Certificate credential;
+ Certificate credential;
credential.setName(credentialName);
credential.setContent(keyB.getPublicKey().data(), keyB.getPublicKey().size());
SignatureInfo signatureInfo;
- signatureInfo.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(), time::system_clock::now() +
- time::minutes(1)));
+ signatureInfo.setValidityPeriod(ndn::security::ValidityPeriod(time::system_clock::now(),
+ time::system_clock::now() + time::minutes(1)));
m_keyChain.sign(credential, signingByCertificate(trustAnchor).setSignatureInfo(signatureInfo));
m_keyChain.addCertificate(keyB, credential);
@@ -144,8 +143,7 @@
BOOST_CHECK_EQUAL(statusToString(state.status), statusToString(Status::FAILURE));
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestChallengePossession
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index 20748d9..f7a8bc5 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -23,13 +23,12 @@
#include "detail/info-encoder.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
BOOST_FIXTURE_TEST_SUITE(TestConfig, IdentityManagementFixture)
-BOOST_AUTO_TEST_CASE(CAConfigFile)
+BOOST_AUTO_TEST_CASE(CaConfigFile)
{
ca::CaConfig config;
config.load("tests/unit-tests/config-files/config-ca-1");
@@ -73,7 +72,7 @@
BOOST_CHECK_EQUAL(names[2].size(), 1);
}
-BOOST_AUTO_TEST_CASE(CAConfigFileWithErrors)
+BOOST_AUTO_TEST_CASE(CaConfigFileWithErrors)
{
ca::CaConfig config;
// nonexistent file
@@ -143,8 +142,7 @@
BOOST_CHECK_EQUAL(lastItem.caPrefix, "/ndn/edu/ucla/zhiyi");
}
-BOOST_AUTO_TEST_SUITE_END() // TestCaConfig
+BOOST_AUTO_TEST_SUITE_END() // TestConfig
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/crypto-helpers.t.cpp b/tests/unit-tests/crypto-helpers.t.cpp
index 9025da0..008a2f6 100644
--- a/tests/unit-tests/crypto-helpers.t.cpp
+++ b/tests/unit-tests/crypto-helpers.t.cpp
@@ -21,7 +21,6 @@
#include "detail/crypto-helpers.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -281,7 +280,7 @@
(uint8_t*)associatedData.c_str(), associatedData.size(), encryptionIv);
block.parse();
auto ivBlock = block.get(tlv::InitializationVector);
- Buffer ivBuf(ivBlock.value(), ivBlock.value_size());
+ ndn::Buffer ivBuf(ivBlock.value(), ivBlock.value_size());
BOOST_CHECK_EQUAL(ivBuf.size(), 12);
BOOST_CHECK_EQUAL(loadBigU32(&encryptionIv[8]), 6);
BOOST_CHECK_EQUAL(loadBigU32(&ivBuf[8]), 0);
@@ -290,7 +289,7 @@
(uint8_t*)associatedData.c_str(), associatedData.size(), encryptionIv);
block.parse();
ivBlock = block.get(tlv::InitializationVector);
- Buffer ivBuf2(ivBlock.value(), ivBlock.value_size());
+ ndn::Buffer ivBuf2(ivBlock.value(), ivBlock.value_size());
BOOST_CHECK_EQUAL(std::memcmp(ivBuf2.data(), encryptionIv.data(), 8), 0);
}
@@ -338,8 +337,7 @@
std::runtime_error);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestCryptoHelpers
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/name-assignment.t.cpp b/tests/unit-tests/name-assignment.t.cpp
index 425e513..94b7fef 100644
--- a/tests/unit-tests/name-assignment.t.cpp
+++ b/tests/unit-tests/name-assignment.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -23,11 +23,11 @@
#include "name-assignment/assignment-hash.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
BOOST_AUTO_TEST_SUITE(TestNameAssignment)
+
BOOST_AUTO_TEST_CASE(NameAssignmentRandom)
{
AssignmentRandom assignment;
@@ -68,10 +68,7 @@
BOOST_CHECK_EQUAL(assignment.assignName(params).begin()->size(), 2);
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestNameAssignment
} // namespace tests
} // namespace ndncert
-} // namespace ndn
-
-
diff --git a/tests/unit-tests/protocol-encoders.t.cpp b/tests/unit-tests/protocol-encoders.t.cpp
index 61128e3..bc1daa0 100644
--- a/tests/unit-tests/protocol-encoders.t.cpp
+++ b/tests/unit-tests/protocol-encoders.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2017-2020, Regents of the University of California.
+/*
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -25,9 +25,7 @@
#include "detail/probe-encoder.hpp"
#include "detail/ca-configuration.hpp"
#include "test-common.hpp"
-#include "identity-management-fixture.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -108,7 +106,7 @@
std::vector<uint8_t> pub = ECDHState().getSelfPubKey();
auto b = requesttlv::encodeApplicationParameters(RequestType::REVOKE, pub, *certRequest);
std::vector<uint8_t> returnedPub;
- std::shared_ptr<security::Certificate> returnedCert;
+ std::shared_ptr<Certificate> returnedCert;
requesttlv::decodeApplicationParameters(b, RequestType::REVOKE, returnedPub, returnedCert);
BOOST_CHECK_EQUAL(returnedPub.size(), pub.size());
@@ -143,7 +141,7 @@
0xe0, 0xff, 0x56, 0x83, 0xf2, 0x43, 0xb2, 0x13};
requester::ProfileStorage caCache;
caCache.load("tests/unit-tests/config-files/config-client-1");
- security::Certificate certRequest = *caCache.getKnownProfiles().front().cert;
+ auto certRequest = *caCache.getKnownProfiles().front().cert;
RequestId id = {{102}};
ca::RequestState state;
state.caPrefix = Name("/ndn/ucla");
@@ -170,8 +168,7 @@
BOOST_CHECK_EQUAL(context.m_issuedCertName, "/ndn/ucla/a/b/c");
}
-BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END() // TestProtocolEncoding
} // namespace tests
} // namespace ndncert
-} // namespace ndn
diff --git a/tests/unit-tests/requester.t.cpp b/tests/unit-tests/requester.t.cpp
index 1f07a3f..d2833c4 100644
--- a/tests/unit-tests/requester.t.cpp
+++ b/tests/unit-tests/requester.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2017-2020, Regents of the University of California.
+ * Copyright (c) 2017-2021, Regents of the University of California.
*
* This file is part of ndncert, a certificate management system based on NDN.
*
@@ -25,7 +25,6 @@
#include "ca-module.hpp"
#include "test-common.hpp"
-namespace ndn {
namespace ndncert {
namespace tests {
@@ -33,7 +32,6 @@
BOOST_FIXTURE_TEST_SUITE(TestRequester, IdentityManagementTimeFixture)
-/* PROBE */
BOOST_AUTO_TEST_CASE(GenProbeInterest)
{
auto identity = addIdentity(Name("/site"));
@@ -45,7 +43,7 @@
ca_profile.probeParameterKeys.push_back("uid");
ca_profile.probeParameterKeys.push_back("name");
ca_profile.caPrefix = Name("/site");
- ca_profile.cert = std::make_shared<security::Certificate>(cert);
+ ca_profile.cert = std::make_shared<Certificate>(cert);
std::multimap<std::string, std::string> probeParams;
probeParams.emplace("email", "zhiyi@cs.ucla.edu");
@@ -69,20 +67,20 @@
ca_profile.probeParameterKeys.push_back("uid");
ca_profile.probeParameterKeys.push_back("name");
ca_profile.caPrefix = Name("/site");
- ca_profile.cert = std::make_shared<security::Certificate>(cert);
+ ca_profile.cert = std::make_shared<Certificate>(cert);
std::vector<Name> availableNames;
availableNames.push_back(Name("/site1"));
availableNames.push_back(Name("/site2"));
- util::DummyClientFace face(io, m_keyChain, {true, true});
+ ndn::util::DummyClientFace face(io, m_keyChain, {true, true});
ca::CaModule ca(face, m_keyChain, "tests/unit-tests/config-files/config-ca-5", "ca-storage-memory");
Data reply;
reply.setName(Name("/site/CA/PROBE"));
reply.setFreshnessPeriod(time::seconds(100));
reply.setContent(probetlv::encodeDataContent(availableNames, 3, ca.m_config.redirection));
- m_keyChain.sign(reply, signingByIdentity(identity));
+ m_keyChain.sign(reply, ndn::signingByIdentity(identity));
std::vector<std::pair<Name, int>> names;
std::vector<Name> redirects;
@@ -96,8 +94,8 @@
BOOST_CHECK_EQUAL(names[1].second, 3);
BOOST_CHECK_EQUAL(redirects.size(), 2);
- BOOST_CHECK_EQUAL(security::extractIdentityFromCertName(redirects[0].getPrefix(-1)), "/ndn/site1");
- BOOST_CHECK_EQUAL(security::extractIdentityFromCertName(redirects[1].getPrefix(-1)), "/ndn/site1");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirects[0].getPrefix(-1)), "/ndn/site1");
+ BOOST_CHECK_EQUAL(ndn::security::extractIdentityFromCertName(redirects[1].getPrefix(-1)), "/ndn/site1");
}
BOOST_AUTO_TEST_CASE(ErrorHandling)
@@ -108,14 +106,14 @@
CaProfile item;
item.caPrefix = Name("/site");
- item.cert = std::make_shared<security::Certificate>(cert);
+ item.cert = std::make_shared<Certificate>(cert);
Request state(m_keyChain, item, RequestType::NEW);
Data errorPacket;
errorPacket.setName(Name("/site/pretend/this/is/error/packet"));
errorPacket.setFreshnessPeriod(time::seconds(100));
errorPacket.setContent(errortlv::encodeDataContent(ErrorCode::INVALID_PARAMETER, "This is a test."));
- m_keyChain.sign(errorPacket, signingByIdentity(identity));
+ m_keyChain.sign(errorPacket, ndn::signingByIdentity(identity));
std::vector<std::pair<Name, int>> ids;
std::vector<Name> cas;
@@ -128,4 +126,3 @@
} // namespace tests
} // namespace ndncert
-} // namespace ndn