}
void MyHandler::evRequest(anna::comm::ClientSocket& clientSocket, const anna::http::Request& request)
-throw(anna::RuntimeException) {
+noexcept(false) {
const anna::DataBlock& body = request.getBody();
anna::http::Method::Type::_v method = request.getMethod();
auto it = j.find("condition");
if (it != j.end() && it->is_object()) {
-/*
- auto j2 = it->get<nlohmann::json::object_t>();
-
- // [code]|[bitR]|[hopByHop]|[applicationId]|[sessionId]|[resultCode]|[msisdn]|[imsi]|[serviceContextId]
- auto it_code = j2.find("code");
- auto it_bitR = j2.find("bitR");
- auto it_hopByHop = j2.find("hopByHop");
- auto it_applicationId = j2.find("applicationId");
- auto it_sessionId = j2.find("sessionId");
- auto it_resultCode = j2.find("resultCode");
- auto it_msisdn = j2.find("msisdn");
- auto it_imsi = j2.find("imsi");
- auto it_serviceContextId = j2.find("serviceContextId");
-
- std::string p1 = (it_code != j2.end() && it_code->is_string()) ? *it_code : "";
- std::string p2 = (it_bitR != j2.end() && it_bitR->is_string()) ? *it_bitR : "";
- std::string p3 = (it_hopByHop != it->end() && it_hopByHop->is_string()) ? *it_hopByHop : "";
- std::string p4 = (it_applicationId != it->end() && it_applicationId->is_string()) ? *it_applicationId : "";
- std::string p5 = (it_sessionId != it->end() && it_sessionId->is_string()) ? *it_sessionId : "";
- std::string p6 = (it_resultCode != it->end() && it_resultCode->is_string()) ? *it_resultCode : "";
- std::string p7 = (it_msisdn != it->end() && it_msisdn->is_string()) ? *it_msisdn : "";
- std::string p8 = (it_imsi != it->end() && it_imsi->is_string()) ? *it_imsi : "";
- std::string p9 = (it_serviceContextId != it->end() && it_serviceContextId->is_string()) ? *it_serviceContextId : "";
-*/
-
// [code]|[bitR]|[hopByHop]|[applicationId]|[sessionId]|[resultCode]|[msisdn]|[imsi]|[serviceContextId]
auto it_code = it->find("code");
auto it_bitR = it->find("bitR");
}
else if (opType == "/test-reset") {
auto it = j.find("type");
- if (it != j.end() && it->is_string()) {
+ std::string type = (it != j.end() && it->is_string()) ? *it : "soft";
- auto itI = j.find("id");
- int id = (itI != j.end() && itI->is_number_integer()) ? itI->get<int>() : -2; // default is: apply to all the tests
+ auto itI = j.find("id");
+ int id = (itI != j.end() && itI->is_number_integer()) ? itI->get<int>() : -1; // default is: apply to all the tests
- if ((*it == "soft") || (*it == "hard")) {
- result = eop.test__reset(response, (*it == "soft"), id);
- }
- else
- response += "invalid 'type' string field (allowed: soft|hard)";
+ if ((type == "soft") || (type == "hard")) {
+ result = eop.test__reset(response, (type == "soft"), id);
}
else
- response += "missing 'type' string field";
+ response += "invalid 'type' string field (allowed: [soft]|hard)";
}
else if (opType == "/test-repeats") {
auto it = j.find("amount");
result = eop.test__finished(response);
}
else if (opType == "/test-clear") {
- result = eop.test__clear(response);
+ auto it = j.find("id");
+ int id = (it != j.end() && it->is_number_integer()) ? it->get<int>() : -1; // default is: all
+ result = eop.test__clear(response, id);
}
else if (opType == "/test-junit") {
auto it = j.find("targetFile");
- if (it != j.end() && it->is_string())
- result = eop.test__junit(response, *it);
- else
- response += "missing 'targetFile' string field";
+ std::string targetFile = (it != j.end() && it->is_string()) ? *it : "/tmp/junit.xml";
+ result = eop.test__junit(response, targetFile);
}
else if (opType == "/test-summary-counts") {
result = eop.test__summary_counts(response);
else
response += "invalid 'action' string field (allowed: enable|disable)";
}
- else if ((opType == "/test-report-hex")||(opType == "/test-dump_stdout")) {
+ else if ((opType == "/test-report-hex")||(opType == "/test-dump-stdout")) {
auto itA = j.find("action");
std::string action = (itA != j.end() && itA->is_string()) ? *itA : "enable"; // default is: enable
response += "invalid 'action' string field (allowed: enable|disable)";
}
+ // Dynamic procedure
+ else if ((opType == "/dynamic")) {
+ auto it = j.find("arguments");
+ if (it != j.end() && it->is_object()) {
+ result = eop.test__dynamic(response, *it);
+ }
+ else
+ response += "missing 'arguments' object field";
+ }
+
return result;
}