Commit eae602ba authored by YannGarcia's avatar YannGarcia
Browse files

Validate MEC-011 against MEC Sandbox

parent dbc1246a
Loading
Loading
Loading
Loading
+30 −6
Changes for ccsrc/Protocols/Json/json_codec.cc: 30 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -219,6 +219,18 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
  } else if (it->second.find("\"serName\"") != std::string::npos) { // Be careful to the order
                                                                    // TODO To be refined, find("\"accessPointList\"") is not optimal
    if (it->second[0] == '[') {
      std::size_t it_start;
      while ((it_start = str.find("null")) != std::string::npos) {
        loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
        loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
        std::size_t it_stop = it_start + 4;
        loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
        loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
        str = str.substr(0, it_start) + "{}" + str.substr(it_stop);
        loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
      } // End of 'while' statement
      decoding_buffer.clear();
      decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
      AppEnablementAPI__TypesAndValues::ServiceInfoList service_info_list;
      service_info_list.decode(AppEnablementAPI__TypesAndValues::ServiceInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
      msg.serviceInfoList() = service_info_list;
@@ -229,6 +241,18 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
    }
  } else if (it->second.find("\"security\"") != std::string::npos) { // Be careful to the order
                                                                     // TODO To be refined, find("\"accessPointList\"") is not optimal
    std::size_t it_start;
    while ((it_start = str.find("null")) != std::string::npos) {
      loggers::get_instance().log("json_codec::decode: id_start=%d", it_start);
      loggers::get_instance().log("json_codec::decode: Before, str=%s", str.c_str());
      std::size_t it_stop = it_start + 4;
      loggers::get_instance().log("json_codec::decode: id_stop=%d", it_stop);
      loggers::get_instance().log("json_codec::decode: segment=%s", str.substr(it_start, it_stop - it_start).c_str());
      str = str.substr(0, it_start) + "{}" + str.substr(it_stop);
      loggers::get_instance().log("json_codec::decode: After, str=%s", str.c_str());
    } // End of 'while' statement
    decoding_buffer.clear();
    decoding_buffer.put_os(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
    AppEnablementAPI__TypesAndValues::TransportInfoList transport_info_list;
    transport_info_list.decode(AppEnablementAPI__TypesAndValues::TransportInfoList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.transportInfoList() = transport_info_list;
@@ -252,19 +276,19 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
      dns_rule.decode(AppEnablementAPI__TypesAndValues::DnsRule_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
      msg.dnsRule() = dns_rule;
    }
  } else if (it->second.find("\"AppTerminationNotificationSubscription\"") != std::string::npos) {
    AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription app_term;
    app_term.decode(AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.appTerminationNotificationSubscription() = app_term;
  } else if ((it->second.find("\"_links\"") != std::string::npos) && (it->second.find("\"subscriptions\"") != std::string::npos)) {
    AppEnablementAPI__TypesAndValues::SubscriptionLinkList sub_link_list;
    sub_link_list.decode(AppEnablementAPI__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.subscriptionLinkList__app__ens() = sub_link_list;
  } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"filteringCriteria\"") != std::string::npos)) {
  } else if (it->second.find("\"AppTerminationNotificationSubscription\"") != std::string::npos) {
    AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription app_term;
    app_term.decode(AppEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.appTerminationNotificationSubscription() = app_term;
  } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SerAvailabilityNotificationSubscription\"") != std::string::npos)) {
    AppEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription ser_av;
    ser_av.decode(AppEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.serAvailabilityNotificationSubscription() = ser_av;
  } else if (it->second.find("\"ntpServers\"") != std::string::npos) {
  } else if ((it->second.find("\"ntpServers\"") != std::string::npos) || (it->second.find("{\"timeStamp\"") == 0)) {
    AppEnablementAPI__TypesAndValues::TimingCaps timing_caps;
    timing_caps.decode(AppEnablementAPI__TypesAndValues::TimingCaps_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.timingCaps() = timing_caps;
−155

File deleted.

+133 −66

File changed.

Preview size limit exceeded, changes collapsed.

−239

File deleted.

−243

File deleted.

Preview size limit exceeded, changes collapsed.

Loading