Update JSON format: add status field in NEW's response
Change-Id: I7a58a92567c5d503bfca4f5efc3d66d09c20aa28
diff --git a/src/json-helper.cpp b/src/json-helper.cpp
index a7cc897..78969fc 100644
--- a/src/json-helper.cpp
+++ b/src/json-helper.cpp
@@ -25,22 +25,24 @@
namespace ndncert {
const JsonSection
-genResponseProbeJson(const Name& identifier, const Name& CaInformation)
+genResponseProbeJson(const Name& identifier, const Name& caInformation)
{
JsonSection root;
root.put(JSON_IDNENTIFIER, identifier.toUri());
- root.put(JSON_CA_INFO, CaInformation.toUri());
+ root.put(JSON_CA_INFO, caInformation.toUri());
return root;
}
const JsonSection
-genResponseNewJson(const std::string& requestId, const std::list<std::string>& challenges)
+genResponseNewJson(const std::string& requestId, const std::string& status,
+ const std::list<std::string>& challenges)
{
JsonSection root;
JsonSection challengesSection;
root.put(JSON_REQUEST_ID, requestId);
+ root.put(JSON_STATUS, status);
for (const auto& entry : challenges) {
JsonSection challenge;
diff --git a/src/json-helper.hpp b/src/json-helper.hpp
index c34c631..791fc12 100644
--- a/src/json-helper.hpp
+++ b/src/json-helper.hpp
@@ -40,19 +40,20 @@
*
* Target JSON format:
* {
- * "identifier": "",
- * "ca-info": ""
+ * "identifier": "@p identifier",
+ * "ca-info": "@p caInformation"
* }
*/
const JsonSection
-genResponseProbeJson(const Name& identifier, const Name& CaInformation);
+genResponseProbeJson(const Name& identifier, const Name& caInformation);
/**
* @brief Generate JSON file to response NEW interest
*
* Target JSON format:
* {
- * "request-id": "",
+ * "request-id": "@p requestId",
+ * "status": "@p status",
* "challenges": [
* {
* "challenge-type": ""
@@ -65,7 +66,8 @@
* }
*/
const JsonSection
-genResponseNewJson(const std::string& requestId, const std::list<std::string>& challenges);
+genResponseNewJson(const std::string& requestId, const std::string& status,
+ const std::list<std::string>& challenges);
/**
* @brief Generate JSON file to response _SELECT, _VALIDATE, and _STATUS interest
@@ -98,8 +100,8 @@
*
* Target JSON format:
* {
- * "status": "",
- * "error-info": ""
+ * "status": "error",
+ * "error-info": "@p errorInfo"
* }
*/
const JsonSection
diff --git a/tests/unit-tests/json-helper.t.cpp b/tests/unit-tests/json-helper.t.cpp
index 61a74e5..266d3ee 100644
--- a/tests/unit-tests/json-helper.t.cpp
+++ b/tests/unit-tests/json-helper.t.cpp
@@ -40,9 +40,10 @@
std::list<std::string> challenges;
challenges.push_back("PIN");
challenges.push_back("EMAIL");
- auto result = genResponseNewJson("598234759", challenges);
+ auto result = genResponseNewJson("598234759", "wait-selection", challenges);
BOOST_CHECK_EQUAL(result.get<std::string>(JSON_REQUEST_ID), "598234759");
+ BOOST_CHECK_EQUAL(result.get<std::string>(JSON_STATUS), "wait-selection");
auto child = result.get_child(JSON_CHALLENGES);
auto it = child.begin();
BOOST_CHECK_EQUAL(it->second.get<std::string>(JSON_CHALLENGE_TYPE), "PIN");