CR fix 3
Change-Id: If6802a52f48870a1fe3c42d57d7797a5f5248b26
diff --git a/src/detail/probe-encoder.cpp b/src/detail/probe-encoder.cpp
index 2a5fa08..f040d2e 100644
--- a/src/detail/probe-encoder.cpp
+++ b/src/detail/probe-encoder.cpp
@@ -24,25 +24,25 @@
namespace ndncert {
Block
-probeEncoder::encodeApplicationParameters(std::vector<std::tuple<std::string, std::string>>&& parameters)
+probeEncoder::encodeApplicationParameters(std::multimap<std::string, std::string>&& parameters)
{
Block content(ndn::tlv::ApplicationParameters);
- for (size_t i = 0; i < parameters.size(); ++i) {
- content.push_back(makeStringBlock(tlv::ParameterKey, std::get<0>(parameters[i])));
- content.push_back(makeStringBlock(tlv::ParameterValue, std::get<1>(parameters[i])));
+ for (const auto& items : parameters) {
+ content.push_back(makeStringBlock(tlv::ParameterKey, items.first));
+ content.push_back(makeStringBlock(tlv::ParameterValue, items.second));
}
content.encode();
return content;
}
-std::vector<std::tuple<std::string, std::string>>
+std::multimap<std::string, std::string>
probeEncoder::decodeApplicationParameters(const Block& block)
{
- std::vector<std::tuple<std::string, std::string>> result;
+ std::multimap<std::string, std::string> result;
block.parse();
for (size_t i = 0; i < block.elements().size() - 1; i++) {
if (block.elements()[i].type() == tlv::ParameterKey && block.elements()[i + 1].type() == tlv::ParameterValue) {
- result.emplace_back(readString(block.elements().at(i)), readString(block.elements().at(i + 1)));
+ result.emplace(readString(block.elements().at(i)), readString(block.elements().at(i + 1)));
i ++;
}
}
diff --git a/src/detail/probe-encoder.hpp b/src/detail/probe-encoder.hpp
index 03d216e..3985f93 100644
--- a/src/detail/probe-encoder.hpp
+++ b/src/detail/probe-encoder.hpp
@@ -29,7 +29,7 @@
// For Client use
Block
- encodeApplicationParameters(std::vector<std::tuple<std::string, std::string>>&& parameters);
+ encodeApplicationParameters(std::multimap<std::string, std::string>&& parameters);
void
decodeDataContent(const Block& block, std::vector<std::pair<Name, int>>& availableNames,
@@ -41,7 +41,7 @@
optional<size_t> maxSuffixLength = nullopt,
optional<std::vector<std::shared_ptr<security::Certificate>>> redirectionItems = nullopt);
- std::vector<std::tuple<std::string, std::string>>
+ std::multimap<std::string, std::string>
decodeApplicationParameters(const Block& block);
} // namespace ProbeEncoder
} // namespace ndncert
diff --git a/src/identity-challenge/challenge-credential.cpp b/src/identity-challenge/challenge-credential.cpp
index 7e72805..a9ebe1c 100644
--- a/src/identity-challenge/challenge-credential.cpp
+++ b/src/identity-challenge/challenge-credential.cpp
@@ -121,13 +121,13 @@
}
// For Client
-std::vector<std::tuple<std::string, std::string>>
+std::multimap<std::string, std::string>
ChallengeCredential::getRequestedParameterList(Status status, const std::string& challengeStatus)
{
- std::vector<std::tuple<std::string, std::string>> result;
+ std::multimap<std::string, std::string> result;
if (status == Status::BEFORE_CHALLENGE) {
- result.push_back(std::make_tuple(PARAMETER_KEY_CREDENTIAL_CERT, "Please provide the certificate issued by a trusted CA."));
- result.push_back(std::make_tuple(PARAMETER_KEY_PROOF_OF_PRIVATE_KEY, "Please sign a Data packet with request ID as the content."));
+ result.emplace(PARAMETER_KEY_CREDENTIAL_CERT, "Please provide the certificate issued by a trusted CA.");
+ result.emplace(PARAMETER_KEY_PROOF_OF_PRIVATE_KEY, "Please sign a Data packet with request ID as the content.");
return result;
}
NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
@@ -135,7 +135,7 @@
Block
ChallengeCredential::genChallengeRequestTLV(Status status, const std::string& challengeStatus,
- std::vector<std::tuple<std::string, std::string>>&& params)
+ std::multimap<std::string, std::string>&& params)
{
Block request(tlv::EncryptedPayload);
if (status == Status::BEFORE_CHALLENGE) {
@@ -170,7 +170,7 @@
}
void
-ChallengeCredential::fulfillParameters(std::vector<std::tuple<std::string, std::string>>& params,
+ChallengeCredential::fulfillParameters(std::multimap<std::string, std::string>& params,
KeyChain& keyChain, const Name& issuedCertName, const RequestId& requestId)
{
auto& pib = keyChain.getPib();
diff --git a/src/identity-challenge/challenge-credential.hpp b/src/identity-challenge/challenge-credential.hpp
index 72db981..7b48483 100644
--- a/src/identity-challenge/challenge-credential.hpp
+++ b/src/identity-challenge/challenge-credential.hpp
@@ -56,15 +56,15 @@
handleChallengeRequest(const Block& params, ca::RequestState& request) override;
// For Client
- std::vector<std::tuple<std::string, std::string>>
+ std::multimap<std::string, std::string>
getRequestedParameterList(Status status, const std::string& challengeStatus) override;
Block
genChallengeRequestTLV(Status status, const std::string& challengeStatus,
- std::vector<std::tuple<std::string, std::string>>&& params) override;
+ std::multimap<std::string, std::string>&& params) override;
static void
- fulfillParameters(std::vector<std::tuple<std::string, std::string>>& params,
+ fulfillParameters(std::multimap<std::string, std::string>& params,
KeyChain& keyChain, const Name& issuedCertName, const RequestId& requestId);
// challenge parameters
diff --git a/src/identity-challenge/challenge-email.cpp b/src/identity-challenge/challenge-email.cpp
index 332ef96..8b08d82 100644
--- a/src/identity-challenge/challenge-email.cpp
+++ b/src/identity-challenge/challenge-email.cpp
@@ -103,18 +103,18 @@
}
// For Client
-std::vector<std::tuple<std::string, std::string>>
+std::multimap<std::string, std::string>
ChallengeEmail::getRequestedParameterList(Status status, const std::string& challengeStatus)
{
- std::vector<std::tuple<std::string, std::string>> result;
+ std::multimap<std::string, std::string> result;
if (status == Status::BEFORE_CHALLENGE && challengeStatus == "") {
- result.push_back(std::make_tuple(PARAMETER_KEY_EMAIL, "Please input your email address"));
+ result.emplace(PARAMETER_KEY_EMAIL, "Please input your email address");
}
else if (status == Status::CHALLENGE && challengeStatus == NEED_CODE) {
- result.push_back(std::make_tuple(PARAMETER_KEY_CODE, "Please input your verification code"));
+ result.emplace(PARAMETER_KEY_CODE, "Please input your verification code");
}
else if (status == Status::CHALLENGE && challengeStatus == WRONG_CODE) {
- result.push_back(std::make_tuple(PARAMETER_KEY_CODE, "Incorrect code, please try again"));
+ result.emplace(PARAMETER_KEY_CODE, "Incorrect code, please try again");
}
else {
NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
@@ -124,24 +124,24 @@
Block
ChallengeEmail::genChallengeRequestTLV(Status status, const std::string& challengeStatus,
- std::vector<std::tuple<std::string, std::string>>&& params)
+ std::multimap<std::string, std::string>&& params)
{
Block request(tlv::EncryptedPayload);
if (status == Status::BEFORE_CHALLENGE) {
- if (params.size() != 1 || std::get<0>(params[0]) != PARAMETER_KEY_EMAIL) {
+ if (params.size() != 1 || params.find(PARAMETER_KEY_EMAIL) == params.end()) {
NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
request.push_back(makeStringBlock(tlv::SelectedChallenge, CHALLENGE_TYPE));
request.push_back(makeStringBlock(tlv::ParameterKey, PARAMETER_KEY_EMAIL));
- request.push_back(makeStringBlock(tlv::ParameterValue, std::get<1>(params[0])));
+ request.push_back(makeStringBlock(tlv::ParameterValue, params.find(PARAMETER_KEY_EMAIL)->second));
}
else if (status == Status::CHALLENGE && (challengeStatus == NEED_CODE || challengeStatus == WRONG_CODE)) {
- if (params.size() != 1 || std::get<0>(params[0]) != PARAMETER_KEY_CODE) {
+ if (params.size() != 1 || params.find(PARAMETER_KEY_CODE) == params.end()) {
NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
request.push_back(makeStringBlock(tlv::SelectedChallenge, CHALLENGE_TYPE));
request.push_back(makeStringBlock(tlv::ParameterKey, PARAMETER_KEY_CODE));
- request.push_back(makeStringBlock(tlv::ParameterValue, std::get<1>(params[0])));
+ request.push_back(makeStringBlock(tlv::ParameterValue, params.find(PARAMETER_KEY_CODE)->second));
}
else {
NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
diff --git a/src/identity-challenge/challenge-email.hpp b/src/identity-challenge/challenge-email.hpp
index 9dbcedd..c005b7e 100644
--- a/src/identity-challenge/challenge-email.hpp
+++ b/src/identity-challenge/challenge-email.hpp
@@ -60,12 +60,12 @@
handleChallengeRequest(const Block& params, ca::RequestState& request) override;
// For Client
- std::vector<std::tuple<std::string, std::string>>
+ std::multimap<std::string, std::string>
getRequestedParameterList(Status status, const std::string& challengeStatus) override;
Block
genChallengeRequestTLV(Status status, const std::string& challengeStatus,
- std::vector<std::tuple<std::string, std::string>>&& params) override;
+ std::multimap<std::string, std::string>&& params) override;
// challenge status
static const std::string NEED_CODE;
diff --git a/src/identity-challenge/challenge-module.hpp b/src/identity-challenge/challenge-module.hpp
index 1e2ca81..02e5027 100644
--- a/src/identity-challenge/challenge-module.hpp
+++ b/src/identity-challenge/challenge-module.hpp
@@ -54,12 +54,12 @@
handleChallengeRequest(const Block& params, ca::RequestState& request) = 0;
// For Client
- virtual std::vector<std::tuple<std::string, std::string>>
+ virtual std::multimap<std::string, std::string>
getRequestedParameterList(Status status, const std::string& challengeStatus) = 0;
virtual Block
genChallengeRequestTLV(Status status, const std::string& challengeStatus,
- std::vector<std::tuple<std::string, std::string>>&& params) = 0;
+ std::multimap<std::string, std::string>&& params) = 0;
// helpers
static std::string
diff --git a/src/identity-challenge/challenge-pin.cpp b/src/identity-challenge/challenge-pin.cpp
index 34b987d..1ae6753 100644
--- a/src/identity-challenge/challenge-pin.cpp
+++ b/src/identity-challenge/challenge-pin.cpp
@@ -84,18 +84,18 @@
}
// For Client
-std::vector<std::tuple<std::string, std::string>>
+std::multimap<std::string, std::string>
ChallengePin::getRequestedParameterList(Status status, const std::string& challengeStatus)
{
- std::vector<std::tuple<std::string, std::string>> result;
+ std::multimap<std::string, std::string> result;
if (status == Status::BEFORE_CHALLENGE) {
// do nothing
}
else if (status == Status::CHALLENGE && challengeStatus == NEED_CODE) {
- result.push_back(std::make_tuple(PARAMETER_KEY_CODE, "Please input your PIN code"));
+ result.emplace(PARAMETER_KEY_CODE, "Please input your PIN code");
}
else if (status == Status::CHALLENGE && challengeStatus == WRONG_CODE) {
- result.push_back(std::make_tuple(PARAMETER_KEY_CODE, "Incorrect PIN code, please try again"));
+ result.emplace(PARAMETER_KEY_CODE, "Incorrect PIN code, please try again");
}
else {
NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
@@ -105,19 +105,19 @@
Block
ChallengePin::genChallengeRequestTLV(Status status, const std::string& challengeStatus,
- std::vector<std::tuple<std::string, std::string>>&& params)
+ std::multimap<std::string, std::string>&& params)
{
Block request(tlv::EncryptedPayload);
if (status == Status::BEFORE_CHALLENGE) {
request.push_back(makeStringBlock(tlv::SelectedChallenge, CHALLENGE_TYPE));
}
else if (status == Status::CHALLENGE && (challengeStatus == NEED_CODE || challengeStatus == WRONG_CODE)) {
- if (params.size() != 1 || std::get<0>(params[0]) != PARAMETER_KEY_CODE) {
+ if (params.size() != 1 || params.find(PARAMETER_KEY_CODE) == params.end()) {
NDN_THROW(std::runtime_error("Wrong parameter provided."));
}
request.push_back(makeStringBlock(tlv::SelectedChallenge, CHALLENGE_TYPE));
request.push_back(makeStringBlock(tlv::ParameterKey, PARAMETER_KEY_CODE));
- request.push_back(makeStringBlock(tlv::ParameterValue, std::get<1>(params[0])));
+ request.push_back(makeStringBlock(tlv::ParameterValue, params.find(PARAMETER_KEY_CODE)->second));
}
else {
NDN_THROW(std::runtime_error("Unexpected status or challenge status."));
diff --git a/src/identity-challenge/challenge-pin.hpp b/src/identity-challenge/challenge-pin.hpp
index 10b23d4..757870d 100644
--- a/src/identity-challenge/challenge-pin.hpp
+++ b/src/identity-challenge/challenge-pin.hpp
@@ -55,12 +55,12 @@
handleChallengeRequest(const Block& params, ca::RequestState& request) override;
// For Client
- std::vector<std::tuple<std::string, std::string>>
+ std::multimap<std::string, std::string>
getRequestedParameterList(Status status, const std::string& challengeStatus) override;
Block
genChallengeRequestTLV(Status status, const std::string& challengeStatus,
- std::vector<std::tuple<std::string, std::string>>&& params) override;
+ std::multimap<std::string, std::string>&& params) override;
// challenge status
static const std::string NEED_CODE;
diff --git a/src/name-assignment/assignment-func.cpp b/src/name-assignment/assignment-func.cpp
index 22eb35e..d65eefd 100644
--- a/src/name-assignment/assignment-func.cpp
+++ b/src/name-assignment/assignment-func.cpp
@@ -24,8 +24,7 @@
namespace ndn {
namespace ndncert {
-NameAssignmentFunc::NameAssignmentFunc(const std::string& factoryType, const std::string& format)
- : FACTORY_TYPE(factoryType)
+NameAssignmentFunc::NameAssignmentFunc(const std::string& format)
{
size_t index = 0, startIndex = 0;
while ((index = format.find("/", startIndex)) != std::string::npos) {
diff --git a/src/name-assignment/assignment-func.hpp b/src/name-assignment/assignment-func.hpp
index e122ed2..9ed8e22 100644
--- a/src/name-assignment/assignment-func.hpp
+++ b/src/name-assignment/assignment-func.hpp
@@ -22,6 +22,7 @@
#define NDNCERT_ASSIGNMENT_FUNC_HPP
#include "detail/ca-request-state.hpp"
+#include <map>
namespace ndn {
namespace ndncert {
@@ -29,7 +30,7 @@
class NameAssignmentFunc : noncopyable
{
protected:
- explicit NameAssignmentFunc(const std::string& factoryType, const std::string& format = "");
+ explicit NameAssignmentFunc(const std::string& format = "");
public:
virtual ~NameAssignmentFunc() = default;
@@ -45,9 +46,7 @@
* @return a vector containing the possible namespaces derived from the parameters.
*/
virtual std::vector<PartialName>
- assignName(const std::vector<std::tuple<std::string, std::string>>& params) = 0;
-
- const std::string FACTORY_TYPE;
+ assignName(const std::multimap<std::string, std::string> ¶ms) = 0;
public:
template <class AssignmentType>
@@ -62,7 +61,7 @@
static unique_ptr<NameAssignmentFunc>
createNameAssignmentFunc(const std::string& challengeType, const std::string& format = "");
-NDNCERT_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+NDNCERT_PUBLIC_WITH_TESTS_ELSE_PROTECTED:
std::vector<std::string> m_nameFormat;
private:
diff --git a/src/name-assignment/assignment-hash.cpp b/src/name-assignment/assignment-hash.cpp
index 8f0e641..0dec488 100644
--- a/src/name-assignment/assignment-hash.cpp
+++ b/src/name-assignment/assignment-hash.cpp
@@ -27,20 +27,19 @@
NDNCERT_REGISTER_FUNCFACTORY(AssignmentHash, "hash");
AssignmentHash::AssignmentHash(const std::string& format)
- : NameAssignmentFunc("hash", format)
+ : NameAssignmentFunc(format)
{}
std::vector<PartialName>
-AssignmentHash::assignName(const std::vector<std::tuple<std::string, std::string>>& params)
+AssignmentHash::assignName(const std::multimap<std::string, std::string> ¶ms)
{
std::vector<PartialName> resultList;
Name result;
for (const auto& item : m_nameFormat) {
- auto it = std::find_if(params.begin(), params.end(),
- [&](const std::tuple<std::string, std::string>& e) { return std::get<0>(e) == item; });
+ auto it = params.find(item);
if (it != params.end()) {
util::Sha256 digest;
- digest << std::get<1>(*it);
+ digest << it->second;
result.append(digest.toString());
}
else {
diff --git a/src/name-assignment/assignment-hash.hpp b/src/name-assignment/assignment-hash.hpp
index 77e5e91..6acb30c 100644
--- a/src/name-assignment/assignment-hash.hpp
+++ b/src/name-assignment/assignment-hash.hpp
@@ -35,7 +35,7 @@
AssignmentHash(const std::string& format = "");
std::vector<PartialName>
- assignName(const std::vector<std::tuple<std::string, std::string>>& params) override;
+ assignName(const std::multimap<std::string, std::string> ¶ms) override;
};
diff --git a/src/name-assignment/assignment-param.cpp b/src/name-assignment/assignment-param.cpp
index 4ebe637..b99d685 100644
--- a/src/name-assignment/assignment-param.cpp
+++ b/src/name-assignment/assignment-param.cpp
@@ -26,19 +26,19 @@
NDNCERT_REGISTER_FUNCFACTORY(AssignmentParam, "param");
AssignmentParam::AssignmentParam(const std::string& format)
- : NameAssignmentFunc("param", format)
+ : NameAssignmentFunc(format)
{}
std::vector<PartialName>
-AssignmentParam::assignName(const std::vector<std::tuple<std::string, std::string>>& params)
+AssignmentParam::assignName(const std::multimap<std::string, std::string> ¶ms)
{
std::vector<PartialName> resultList;
Name result;
for (const auto& item : m_nameFormat) {
auto it = std::find_if(params.begin(), params.end(),
[&](const std::tuple<std::string, std::string>& e) { return std::get<0>(e) == item; });
- if (it != params.end() && !std::get<1>(*it).empty()) {
- result.append(std::get<1>(*it));
+ if (it != params.end() && !it->second.empty()) {
+ result.append(it->second);
}
else {
return resultList;
diff --git a/src/name-assignment/assignment-param.hpp b/src/name-assignment/assignment-param.hpp
index 8a31dc6..cdf2cc5 100644
--- a/src/name-assignment/assignment-param.hpp
+++ b/src/name-assignment/assignment-param.hpp
@@ -35,7 +35,7 @@
AssignmentParam(const std::string& format = "");
std::vector<PartialName>
- assignName(const std::vector<std::tuple<std::string, std::string>>& params) override;
+ assignName(const std::multimap<std::string, std::string> ¶ms) override;
};
diff --git a/src/name-assignment/assignment-random.cpp b/src/name-assignment/assignment-random.cpp
index 59f6477..eaed861 100644
--- a/src/name-assignment/assignment-random.cpp
+++ b/src/name-assignment/assignment-random.cpp
@@ -27,11 +27,11 @@
NDNCERT_REGISTER_FUNCFACTORY(AssignmentRandom, "random");
AssignmentRandom::AssignmentRandom(const std::string& format)
- : NameAssignmentFunc("random", format)
+ : NameAssignmentFunc(format)
{}
std::vector<PartialName>
-AssignmentRandom::assignName(const std::vector<std::tuple<std::string, std::string>>& params)
+AssignmentRandom::assignName(const std::multimap<std::string, std::string> ¶ms)
{
std::vector<PartialName> resultList;
resultList.emplace_back(to_string(random::generateSecureWord64()));
diff --git a/src/name-assignment/assignment-random.hpp b/src/name-assignment/assignment-random.hpp
index cf6509f..978a0b7 100644
--- a/src/name-assignment/assignment-random.hpp
+++ b/src/name-assignment/assignment-random.hpp
@@ -35,7 +35,7 @@
AssignmentRandom(const std::string& format = "");
std::vector<PartialName>
- assignName(const std::vector<std::tuple<std::string, std::string>>& params) override;
+ assignName(const std::multimap<std::string, std::string> ¶ms) override;
};
} // namespace ndncert
diff --git a/src/requester.cpp b/src/requester.cpp
index 7ace36c..5372db3 100644
--- a/src/requester.cpp
+++ b/src/requester.cpp
@@ -88,7 +88,7 @@
}
shared_ptr<Interest>
-Requester::genProbeInterest(const CaProfile& ca, std::vector<std::tuple<std::string, std::string>>&& probeInfo)
+Requester::genProbeInterest(const CaProfile& ca, std::multimap<std::string, std::string>&& probeInfo)
{
Name interestName = ca.m_caPrefix;
interestName.append("CA").append("PROBE");
@@ -212,7 +212,7 @@
return challenges;
}
-std::vector<std::tuple<std::string, std::string>>
+std::multimap<std::string, std::string>
Requester::selectOrContinueChallenge(RequestState& state, const std::string& challengeSelected)
{
auto challenge = ChallengeModule::createChallengeModule(challengeSelected);
@@ -225,7 +225,7 @@
shared_ptr<Interest>
Requester::genChallengeInterest(RequestState& state,
- std::vector<std::tuple<std::string, std::string>>&& parameters)
+ std::multimap<std::string, std::string>&& parameters)
{
if (state.m_challengeType == "") {
NDN_THROW(std::runtime_error("The challenge has not been selected."));
diff --git a/src/requester.hpp b/src/requester.hpp
index 825efd9..92cf00b 100644
--- a/src/requester.hpp
+++ b/src/requester.hpp
@@ -84,7 +84,7 @@
* @return A shared pointer of to the encoded interest, ready to be sent.
*/
static shared_ptr<Interest>
- genProbeInterest(const CaProfile& ca, std::vector<std::tuple<std::string, std::string>>&& probeInfo);
+ genProbeInterest(const CaProfile& ca, std::multimap<std::string, std::string>&& probeInfo);
/**
* @brief Decodes the replied data for PROBE process from the CA.
@@ -147,7 +147,7 @@
* @return The requirement list for the current stage of the challenge, in name, prompt mapping.
* @throw std::runtime_error if the challenge is not supported.
*/
- static std::vector<std::tuple<std::string, std::string>>
+ static std::multimap<std::string, std::string>
selectOrContinueChallenge(RequestState& state, const std::string& challengeSelected);
/**
@@ -160,7 +160,7 @@
*/
static shared_ptr<Interest>
genChallengeInterest(RequestState& state,
- std::vector<std::tuple<std::string, std::string>>&& parameters);
+ std::multimap<std::string, std::string>&& parameters);
/**
* @brief Decodes the responded data from the CHALLENGE interest.
diff --git a/tests/unit-tests/bench.t.cpp b/tests/unit-tests/bench.t.cpp
index 9fba0e8..0927e9c 100644
--- a/tests/unit-tests/bench.t.cpp
+++ b/tests/unit-tests/bench.t.cpp
@@ -144,7 +144,7 @@
auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
auto request = ca.getCertificateRequest(*challengeInterest2);
auto secret = request->m_challengeState->m_secrets.get(ChallengePin::PARAMETER_KEY_CODE, "");
- std::get<1>(paramList[0]) = secret;
+ paramList.begin()->second = secret;
challengeInterest3 = requester::Requester::genChallengeInterest(state, std::move(paramList));
// std::cout << "CHALLENGE Interest Size: " << challengeInterest3->wireEncode().size() << std::endl;
}
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 15c7532..4c295db 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -423,7 +423,7 @@
auto paramList = requester::Requester::selectOrContinueChallenge(state, "pin");
auto request = ca.getCertificateRequest(*challengeInterest2);
auto secret = request->m_challengeState->m_secrets.get(ChallengePin::PARAMETER_KEY_CODE, "");
- std::get<1>(paramList[0]) = secret;
+ paramList.begin()->second = secret;
challengeInterest3 = requester::Requester::genChallengeInterest(state, std::move(paramList));
}
else if (Name("/ndn/CA/CHALLENGE").isPrefixOf(response.getName()) && count == 2) {
diff --git a/tests/unit-tests/configuration.t.cpp b/tests/unit-tests/configuration.t.cpp
index 3ba4567..317d01b 100644
--- a/tests/unit-tests/configuration.t.cpp
+++ b/tests/unit-tests/configuration.t.cpp
@@ -55,15 +55,12 @@
BOOST_CHECK_EQUAL(config.m_redirection->at(0)->getName(),
"/ndn/site1/KEY/%11%BC%22%F4c%15%FF%17/self/%FD%00%00%01Y%C8%14%D9%A5");
BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs.size(), 3);
- BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[0]->FACTORY_TYPE, "param");
- BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[1]->FACTORY_TYPE, "param");
- BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[2]->FACTORY_TYPE, "random");
BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[0]->m_nameFormat[0], "group");
BOOST_CHECK_EQUAL(config.m_nameAssignmentFuncs[0]->m_nameFormat[1], "email");
- std::vector<std::tuple<std::string, std::string>> params;
- params.emplace_back("email", "1@1.edu");
- params.emplace_back("group", "irl");
- params.emplace_back("name", "ndncert");
+ std::multimap<std::string, std::string> params;
+ params.emplace("email", "1@1.edu");
+ params.emplace("group", "irl");
+ params.emplace("name", "ndncert");
std::vector<Name> names;
for (auto& assignment : config.m_nameAssignmentFuncs) {
auto results = assignment->assignName(params);
diff --git a/tests/unit-tests/name-assignment.t.cpp b/tests/unit-tests/name-assignment.t.cpp
index 154779a..425e513 100644
--- a/tests/unit-tests/name-assignment.t.cpp
+++ b/tests/unit-tests/name-assignment.t.cpp
@@ -31,39 +31,39 @@
BOOST_AUTO_TEST_CASE(NameAssignmentRandom)
{
AssignmentRandom assignment;
- BOOST_CHECK_EQUAL(assignment.assignName(std::vector<std::tuple<std::string, std::string>>()).size(), 1);
- BOOST_CHECK_EQUAL(assignment.assignName(std::vector<std::tuple<std::string, std::string>>()).begin()->size(), 1);
+ BOOST_CHECK_EQUAL(assignment.assignName(std::multimap<std::string, std::string>()).size(), 1);
+ BOOST_CHECK_EQUAL(assignment.assignName(std::multimap<std::string, std::string>()).begin()->size(), 1);
}
BOOST_AUTO_TEST_CASE(NameAssignmentParam)
{
AssignmentParam assignment("/abc/xyz");
- std::vector<std::tuple<std::string, std::string>> params;
- params.emplace_back("abc", "123");
+ std::multimap<std::string, std::string> params;
+ params.emplace("abc", "123");
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 0);
- params.emplace_back("xyz", "789");
+ params.emplace("xyz", "789");
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 1);
BOOST_CHECK_EQUAL(*assignment.assignName(params).begin(), Name("/123/789"));
- params.emplace_back("fake", "456");
+ params.emplace("fake", "456");
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 1);
BOOST_CHECK_EQUAL(*assignment.assignName(params).begin(), Name("/123/789"));
- params[1] = std::tuple<std::string, std::string>("xyz", "");
+ params.find("xyz")->second = "";
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 0);
}
BOOST_AUTO_TEST_CASE(NameAssignmentHash)
{
AssignmentHash assignment("/abc/xyz");
- std::vector<std::tuple<std::string, std::string>> params;
- params.emplace_back("abc", "123");
+ std::multimap<std::string, std::string> params;
+ params.emplace("abc", "123");
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 0);
- params.emplace_back("xyz", "789");
+ params.emplace("xyz", "789");
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 1);
BOOST_CHECK_EQUAL(assignment.assignName(params).begin()->size(), 2);
- params.emplace_back("fake", "456");
+ params.emplace("fake", "456");
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 1);
BOOST_CHECK_EQUAL(assignment.assignName(params).begin()->size(), 2);
- params[1] = std::tuple<std::string, std::string>("xyz", "");
+ params.find("xyz")->second = "";
BOOST_CHECK_EQUAL(assignment.assignName(params).size(), 1);
BOOST_CHECK_EQUAL(assignment.assignName(params).begin()->size(), 2);
}
diff --git a/tests/unit-tests/protocol-encoders.t.cpp b/tests/unit-tests/protocol-encoders.t.cpp
index 532049b..47e65f5 100644
--- a/tests/unit-tests/protocol-encoders.t.cpp
+++ b/tests/unit-tests/protocol-encoders.t.cpp
@@ -64,16 +64,14 @@
BOOST_AUTO_TEST_CASE(ProbeEncodingAppParam)
{
- std::vector<std::tuple<std::string, std::string>> parameters;
- parameters.emplace_back("key1", "value1");
- parameters.emplace_back("key2", "value2");
+ std::multimap<std::string, std::string> parameters;
+ parameters.emplace("key1", "value1");
+ parameters.emplace("key2", "value2");
auto appParam = probeEncoder::encodeApplicationParameters(std::move(parameters));
auto param1 = probeEncoder::decodeApplicationParameters(appParam);
- BOOST_CHECK_EQUAL(parameters.size(), param1.size());
- BOOST_CHECK_EQUAL(std::get<0>(parameters[0]), std::get<0>(param1[0]));
- BOOST_CHECK_EQUAL(std::get<1>(parameters[0]), std::get<1>(param1[0]));
- BOOST_CHECK_EQUAL(std::get<0>(parameters[1]), std::get<0>(param1[1]));
- BOOST_CHECK_EQUAL(std::get<1>(parameters[1]), std::get<1>(param1[1]));
+ BOOST_CHECK_EQUAL(param1.size(), 2);
+ BOOST_CHECK_EQUAL(param1.find("key1")->second, "value1");
+ BOOST_CHECK_EQUAL(param1.find("key2")->second, "value2");
}
BOOST_AUTO_TEST_CASE(ProbeEncodingData)
diff --git a/tests/unit-tests/requester.t.cpp b/tests/unit-tests/requester.t.cpp
index e51658d..c9a1d1d 100644
--- a/tests/unit-tests/requester.t.cpp
+++ b/tests/unit-tests/requester.t.cpp
@@ -47,10 +47,10 @@
ca_profile.m_caPrefix = Name("/site");
ca_profile.m_cert = std::make_shared<security::Certificate>(cert);
- std::vector<std::tuple<std::string, std::string>> probeParams;
- probeParams.push_back(std::make_tuple("email", "zhiyi@cs.ucla.edu"));
- probeParams.push_back(std::make_tuple("uid", "987654321"));
- probeParams.push_back(std::make_tuple("name", "Zhiyi Zhang"));
+ std::multimap<std::string, std::string> probeParams;
+ probeParams.emplace("email", "zhiyi@cs.ucla.edu");
+ probeParams.emplace("uid", "987654321");
+ probeParams.emplace("name", "Zhiyi Zhang");
auto firstInterest = Requester::genProbeInterest(ca_profile, std::move(probeParams));
BOOST_CHECK(firstInterest->getName().at(-1).isParametersSha256Digest());
diff --git a/tools/ndncert-client.cpp b/tools/ndncert-client.cpp
index 3a9a2b6..844a192 100644
--- a/tools/ndncert-client.cpp
+++ b/tools/ndncert-client.cpp
@@ -46,7 +46,7 @@
shared_ptr<RequestState> requesterState = nullptr;
static void
-captureParams(std::vector<std::tuple<std::string, std::string>>& requirement)
+captureParams(std::multimap<std::string, std::string>& requirement)
{
std::list<std::string> results;
for (auto& item : requirement) {
@@ -61,12 +61,12 @@
}
}
-static std::vector<std::tuple<std::string, std::string>>
+static std::multimap<std::string, std::string>
captureParams(const std::list<std::string>& requirement)
{
- std::vector<std::tuple<std::string, std::string>> results;
+ std::multimap<std::string, std::string> results;
for (const auto& r : requirement) {
- results.emplace_back(r, "Please input: " + r);
+ results.emplace(r, "Please input: " + r);
}
captureParams(results);
return results;
@@ -300,7 +300,7 @@
size_t count = 0;
std::cerr << "***************************************\n"
<< "Step " << nStep++ << ": CA SELECTION" << std::endl;
- for (auto item : profileStorage.m_caItems) {
+ for (auto item : profileStorage.getCaItems()) {
std::cerr << "> Index: " << count++ << std::endl
<< ">> CA prefix:" << item.m_caPrefix << std::endl
<< ">> Introduction: " << item.m_caInfo << std::endl;
@@ -341,7 +341,7 @@
std::cerr << "Your input is not an existing index. Exit" << std::endl;
return;
}
- auto itemIterator = profileStorage.m_caItems.cbegin();
+ auto itemIterator = profileStorage.getCaItems().cbegin();
std::advance(itemIterator, caIndex);
auto targetCaItem = *itemIterator;
runProbe(targetCaItem);
@@ -407,7 +407,7 @@
static void
runChallenge(const std::string& challengeType)
{
- std::vector<std::tuple<std::string, std::string>> requirement;
+ std::multimap<std::string, std::string> requirement;
try {
requirement = Requester::selectOrContinueChallenge(*requesterState, challengeType);
}