fixed some build errors
diff --git a/tests/unit-tests/ca-module.t.cpp b/tests/unit-tests/ca-module.t.cpp
index 81a5916..13abf4b 100644
--- a/tests/unit-tests/ca-module.t.cpp
+++ b/tests/unit-tests/ca-module.t.cpp
@@ -40,7 +40,7 @@
{
util::DummyClientFace face(io, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
- BOOST_CHECK_EQUAL(ca.getCaConf().m_caName, "/ndn");
+ BOOST_CHECK_EQUAL(ca.getCaConf().m_caPrefix, "/ndn");
auto identity = addIdentity(Name("/ndn/site2"));
auto key = identity.getDefaultKey();
@@ -61,23 +61,27 @@
util::DummyClientFace face(io, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
- ca.setProbeHandler([&] (const JsonSection& probeInfo) {
+ ca.setProbeHandler([&] (const Block& probeInfo) {
return "example";
});
advanceClocks(time::milliseconds(20), 60);
Interest interest("/ndn/CA/PROBE");
interest.setCanBePrefix(false);
- JsonSection paramJson;
- paramJson.add(JSON_CLIENT_PROBE_INFO, "zhiyi");
- interest.setApplicationParameters(ClientModule::paramFromJson(paramJson));
+
+ Block paramTLV = makeEmptyBlock(tlv::ApplicationParameters);
+ paramTLV.push_back(makeStringBlock(tlv_parameter_key, JSON_CLIENT_PROBE_INFO));
+ paramTLV.push_back(makeStringBlock(tlv_parameter_value, "zhiyi"));
+ paramTLV.encode();
+ interest.setApplicationParameters(paramTLV);
int count = 0;
face.onSendData.connect([&] (const Data& response) {
count++;
BOOST_CHECK(security::verifySignature(response, cert));
- auto contentJson = ClientModule::getJsonFromData(response);
- BOOST_CHECK_EQUAL(contentJson.get<std::string>(JSON_CA_NAME), "/ndn/example");
+ Block contentBlock = response.getContent();
+ contentBlock.parse();
+ BOOST_CHECK_EQUAL(readString(contentBlock.get(tlv_ca_prefix)), "/ndn/example");
});
face.receive(interest);
@@ -93,7 +97,7 @@
util::DummyClientFace face(io, {true, true});
CaModule ca(face, m_keyChain, "tests/unit-tests/ca.conf.test", "ca-storage-memory");
- ca.setProbeHandler([&] (const JsonSection& probeInfo) {
+ ca.setProbeHandler([&] (const Block& probeInfo) {
return "example";
});
advanceClocks(time::milliseconds(20), 60);
@@ -287,7 +291,7 @@
auto contentJson = ClientModule::getJsonFromData(response);
client.onNewResponse(response);
auto paramJson = pinChallenge.getRequirementForChallenge(client.m_status, client.m_challengeStatus);
- challengeInterest = client.generateChallengeInterest(pinChallenge.genChallengeRequestJson(client.m_status,
+ challengeInterest = client.generateChallengeInterest(pinChallenge.genChallengeRequestTLV(client.m_status,
client.m_challengeStatus,
paramJson));
}
@@ -300,7 +304,7 @@
BOOST_CHECK_EQUAL(client.m_challengeStatus, ChallengePin::NEED_CODE);
auto paramJson = pinChallenge.getRequirementForChallenge(client.m_status, client.m_challengeStatus);
- challengeInterest2 = client.generateChallengeInterest(pinChallenge.genChallengeRequestJson(client.m_status,
+ challengeInterest2 = client.generateChallengeInterest(pinChallenge.genChallengeRequestTLV(client.m_status,
client.m_challengeStatus,
paramJson));
}
@@ -319,7 +323,7 @@
if (i.first == ChallengePin::JSON_PIN_CODE)
i.second.put("", secret);
}
- challengeInterest3 = client.generateChallengeInterest(pinChallenge.genChallengeRequestJson(client.m_status,
+ challengeInterest3 = client.generateChallengeInterest(pinChallenge.genChallengeRequestTLV(client.m_status,
client.m_challengeStatus,
paramJson));
}
diff --git a/tests/unit-tests/challenge-credential.t.cpp b/tests/unit-tests/challenge-credential.t.cpp
index 2455e73..9072fa0 100644
--- a/tests/unit-tests/challenge-credential.t.cpp
+++ b/tests/unit-tests/challenge-credential.t.cpp
@@ -78,19 +78,22 @@
ss.str("");
ss.clear();
- JsonSection params;
io::save<security::v2::Certificate>(selfSigned, ss);
std::string selfSignedStr = ss.str();
- params.add(ChallengeCredential::JSON_CREDENTIAL_SELF, selfSignedStr);
ss.str("");
ss.clear();
io::save<security::v2::Certificate>(certB, ss);
std::string credentialStr = ss.str();
- params.add(ChallengeCredential::JSON_CREDENTIAL_CERT, credentialStr);
ss.str("");
ss.clear();
+ Block params = makeEmptyBlock(tlv_encrypted_payload);
+ params.push_back(makeStringBlock(tlv_parameter_key, ChallengeCredential::JSON_CREDENTIAL_SELF));
+ params.push_back(makeStringBlock(tlv_parameter_value, selfSignedStr));
+ params.push_back(makeStringBlock(tlv_parameter_key, ChallengeCredential::JSON_CREDENTIAL_CERT));
+ params.push_back(makeStringBlock(tlv_parameter_value, credentialStr));
+
challenge.handleChallengeRequest(params, request);
BOOST_CHECK_EQUAL(request.m_status, STATUS_PENDING);
BOOST_CHECK_EQUAL(request.m_challengeStatus, CHALLENGE_STATUS_SUCCESS);
diff --git a/tests/unit-tests/challenge-email.t.cpp b/tests/unit-tests/challenge-email.t.cpp
index 398df97..834411d 100644
--- a/tests/unit-tests/challenge-email.t.cpp
+++ b/tests/unit-tests/challenge-email.t.cpp
@@ -48,11 +48,12 @@
auto cert = key.getDefaultCertificate();
CertificateRequest request(Name("/ndn/site1"), "123", STATUS_BEFORE_CHALLENGE, cert);
- JsonSection emailJson;
- emailJson.put(ChallengeEmail::JSON_EMAIL, "zhiyi@cs.ucla.edu");
+ Block paramTLV = makeEmptyBlock(tlv_encrypted_payload);
+ paramTLV.push_back(makeStringBlock(tlv_parameter_key, ChallengeEmail::JSON_EMAIL));
+ paramTLV.push_back(makeStringBlock(tlv_parameter_value, "zhiyi@cs.ucla.edu"));
ChallengeEmail challenge("./tests/unit-tests/test-send-email.sh");
- challenge.handleChallengeRequest(emailJson, request);
+ challenge.handleChallengeRequest(paramTLV, request);
BOOST_CHECK_EQUAL(request.m_status, STATUS_CHALLENGE);
BOOST_CHECK_EQUAL(request.m_challengeStatus, ChallengeEmail::NEED_CODE);
@@ -97,11 +98,12 @@
auto cert = key.getDefaultCertificate();
CertificateRequest request(Name("/ndn/site1"), "123", STATUS_BEFORE_CHALLENGE, cert);
- JsonSection emailJson;
- emailJson.put(ChallengeEmail::JSON_EMAIL, "zhiyi@cs");
+ Block paramTLV = makeEmptyBlock(tlv_encrypted_payload);
+ paramTLV.push_back(makeStringBlock(tlv_parameter_key, ChallengeEmail::JSON_EMAIL));
+ paramTLV.push_back(makeStringBlock(tlv_parameter_value, "zhiyi@cs"));
ChallengeEmail challenge;
- challenge.handleChallengeRequest(emailJson, request);
+ challenge.handleChallengeRequest(paramTLV, request);
BOOST_CHECK_EQUAL(request.m_challengeStatus, ChallengeEmail::FAILURE_INVALID_EMAIL);
BOOST_CHECK_EQUAL(request.m_status, STATUS_FAILURE);
@@ -117,11 +119,12 @@
CertificateRequest request(Name("/ndn/site1"), "123", STATUS_CHALLENGE, ChallengeEmail::NEED_CODE,
"Email", time::toIsoString(time::system_clock::now()), 3600, 3, json, cert);
- JsonSection requestJson;
- requestJson.put(ChallengeEmail::JSON_CODE, "4567");
+ Block paramTLV = makeEmptyBlock(tlv_encrypted_payload);
+ paramTLV.push_back(makeStringBlock(tlv_parameter_key, ChallengeEmail::JSON_CODE));
+ paramTLV.push_back(makeStringBlock(tlv_parameter_value, "4567"));
ChallengeEmail challenge;
- challenge.handleChallengeRequest(requestJson, request);
+ challenge.handleChallengeRequest(paramTLV, request);
BOOST_CHECK_EQUAL(request.m_challengeStatus, CHALLENGE_STATUS_SUCCESS);
BOOST_CHECK_EQUAL(request.m_status, STATUS_PENDING);
@@ -138,11 +141,12 @@
CertificateRequest request(Name("/ndn/site1"), "123", STATUS_CHALLENGE, ChallengeEmail::NEED_CODE,
"email", time::toIsoString(time::system_clock::now()), 3600, 3, json, cert);
- JsonSection requestJson;
- requestJson.put(ChallengeEmail::JSON_CODE, "7890");
+ Block paramTLV = makeEmptyBlock(tlv_encrypted_payload);
+ paramTLV.push_back(makeStringBlock(tlv_parameter_key, ChallengeEmail::JSON_CODE));
+ paramTLV.push_back(makeStringBlock(tlv_parameter_value, "7890"));
ChallengeEmail challenge;
- challenge.handleChallengeRequest(requestJson, request);
+ challenge.handleChallengeRequest(paramTLV, request);
BOOST_CHECK_EQUAL(request.m_challengeStatus, ChallengeEmail::WRONG_CODE);
BOOST_CHECK_EQUAL(request.m_status, STATUS_CHALLENGE);
diff --git a/tests/unit-tests/challenge-pin.t.cpp b/tests/unit-tests/challenge-pin.t.cpp
index adac6b9..81ee1e1 100644
--- a/tests/unit-tests/challenge-pin.t.cpp
+++ b/tests/unit-tests/challenge-pin.t.cpp
@@ -42,7 +42,7 @@
CertificateRequest request(Name("/ndn/site1"), "123", STATUS_BEFORE_CHALLENGE, cert);
ChallengePin challenge;
- challenge.handleChallengeRequest(JsonSection(), request);
+ challenge.handleChallengeRequest(makeEmptyBlock(tlv_encrypted_payload), request);
BOOST_CHECK_EQUAL(request.m_status, STATUS_CHALLENGE);
BOOST_CHECK_EQUAL(request.m_challengeStatus, ChallengePin::NEED_CODE);
@@ -59,11 +59,12 @@
CertificateRequest request(Name("/ndn/site1"), "123", STATUS_CHALLENGE, ChallengePin::NEED_CODE, "pin",
time::toIsoString(time::system_clock::now()), 3600, 3, secret, cert);
- JsonSection paramJson;
- paramJson.put(ChallengePin::JSON_PIN_CODE, "12345");
+ Block paramTLV = makeEmptyBlock(tlv_encrypted_payload);
+ paramTLV.push_back(makeStringBlock(tlv_parameter_key, ChallengePin::JSON_PIN_CODE));
+ paramTLV.push_back(makeStringBlock(tlv_parameter_value, "12345"));
ChallengePin challenge;
- challenge.handleChallengeRequest(paramJson, request);
+ challenge.handleChallengeRequest(paramTLV, request);
BOOST_CHECK_EQUAL(request.m_status, STATUS_PENDING);
BOOST_CHECK_EQUAL(request.m_challengeStatus, CHALLENGE_STATUS_SUCCESS);
@@ -80,11 +81,12 @@
CertificateRequest request(Name("/ndn/site1"), "123", STATUS_CHALLENGE, ChallengePin::NEED_CODE, "pin",
time::toIsoString(time::system_clock::now()), 3600, 3, secret, cert);
- JsonSection paramJson;
- paramJson.put(ChallengePin::JSON_PIN_CODE, "45678");
+ Block paramTLV = makeEmptyBlock(tlv_encrypted_payload);
+ paramTLV.push_back(makeStringBlock(tlv_parameter_key, ChallengePin::JSON_PIN_CODE));
+ paramTLV.push_back(makeStringBlock(tlv_parameter_value, "45678"));
ChallengePin challenge;
- challenge.handleChallengeRequest(paramJson, request);
+ challenge.handleChallengeRequest(paramTLV, request);
BOOST_CHECK_EQUAL(request.m_status, STATUS_CHALLENGE);
BOOST_CHECK_EQUAL(request.m_challengeStatus, ChallengePin::WRONG_CODE);