Commit 1f75fd25 authored by YannGarcia's avatar YannGarcia
Browse files

Update Codec for new types - MEC015

parent 8fb418af
Loading
Loading
Loading
Loading
+131 −124
Original line number Diff line number Diff line
@@ -64,6 +64,10 @@ int json_codec::encode (const LibItsHttp__JsonMessageBodyTypes::JsonBody& msg, O
    const AppEnablementAPI__TypesAndValues::TrafficRule& traffic_rule = msg.trafficRule();
    traffic_rule.encode(AppEnablementAPI__TypesAndValues::TrafficRule_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
    data = /*char2oct(CHARSTRING("{\"TrafficRule\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
  } else if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_bwInfo)) {
    const TrafficManagementAPI__TypesAndValues::BwInfo& bw_info = msg.bwInfo();
    bw_info.encode(TrafficManagementAPI__TypesAndValues::BwInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
    data = /*char2oct(CHARSTRING("{\"TrafficRule\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
  } else {
    loggers::get_instance().error("json_codec::encode: Not supported");
  }
@@ -367,16 +371,19 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
    msg.appInfo() = appInfo;
  } else if ((it->second.find("\"bwInfo\"") != std::string::npos) || (it->second.find("\"fixedBWPriority\"") != std::string::npos)) {
    // Need to change some enumerated string not supported by TTCN-3 language
    if (str.find("not defined in the present document") != std::string::npos) {
      str = regex_replace(str, regex("not defined in the present document"), "not_defined_in_the_present_document");
    }
    if (str.find("00") != std::string::npos) {
      str = regex_replace(str, regex("00"), "Downlink");
    } else if (str.find("01 = Uplink (towards the application/session)") != std::string::npos) {
      str = regex_replace(str, regex("01"), "Uplink");
    } else if (str.find("10 = Symmetrical") != std::string::npos) {
      str = regex_replace(str, regex("10"), "Symmetrical");
    while (true) {
      if (str.find("\"00\"") != std::string::npos) {
        str = regex_replace(str, regex("\"00\""), "\"Downlink\"");
      } else if (str.find("\"01\"") != std::string::npos) {
        str = regex_replace(str, regex("\"01\""), "\"Uplink\"");
      } else if (str.find("\"10\"") != std::string::npos) {
        str = regex_replace(str, regex("\"10\""), "\"Symmetrical\"");
      } else {
        loggers::get_instance().log("json_codec::decode: BwInfo in break");
        break;
      }
    } // End of 'while' loop
    loggers::get_instance().log("json_codec::decode: BwInfo after converting enum: %s", str.c_str());
    if (it->second[0] == '[') { // BwInfoList
      TTCN_Buffer decoding_buffer_(OCTETSTRING(str.length(), (const unsigned char*)str.c_str()));
      TrafficManagementAPI__TypesAndValues::BwInfoList bw_info_list;
+3 −3
Original line number Diff line number Diff line
@@ -238,10 +238,10 @@ system.httpPort_notif.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server
# Check that the IUT responds with an error when a request with an unknown resource URI is sent by a MEC Application
#AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_002_NF
# Check that the IUT responds with a registration and initialisation approval for the requested bandwidth requirements sent by a MEC Application
AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_003_OK_01
#AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_003_OK_01
#AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_003_OK_02
# Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
#AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_003_BR_01
AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_003_BR_01
#AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_003_BR_02
#AtsMec_TrafficManagementAPI_TestCases.TC_MEC_MEC015_SRV_TM_003_BR_03
# Check that the IUT responds with the configured bandwidth allocation when queried by a MEC Application
+3 −3
Original line number Diff line number Diff line
@@ -316,7 +316,7 @@ module AtsMec_MultiAccessSteeringInfoAPI_TestCases {
                                                                                                                                  {
                                                                                                                                    m_session_filter(
                                                                                                                                                     "10.10.10.10",
                                                                                                                                                     {"10"}
                                                                                                                                                     {"1010"}
                                                                                                                                                     )
                                                                                                                                    } // FlowFilter

@@ -400,7 +400,7 @@ module AtsMec_MultiAccessSteeringInfoAPI_TestCases {
                                                                                                                                  {
                                                                                                                                    m_session_filter(
                                                                                                                                                     "10.10.10.10",
                                                                                                                                                     {"10.10.10.10"} // Invalid port number
                                                                                                                                                     {"10.10"} // Invalid port number
                                                                                                                                                     )
                                                                                                                                    } // FlowFilter

@@ -793,7 +793,7 @@ module AtsMec_MultiAccessSteeringInfoAPI_TestCases {
                                                                                                                                 {
                                                                                                                                   m_session_filter(
                                                                                                                                                    "10.10.10.10",
                                                                                                                                                    {"10"}
                                                                                                                                                    {"1010"}
                                                                                                                                                    )
                                                                                                                                   } // FlowFilter
                                                                                                                                 )
+9 −7
Original line number Diff line number Diff line
@@ -286,6 +286,7 @@ module AtsMec_TrafficManagementAPI_TestCases {
        // Local variables
        var Headers v_headers;
        var HttpMessage v_response;
        var JSON.String v_app_instance_id := PX_APP_INSTANCE_ID & oct2unichar(char2oct("001"));
        
        // Test control
        if (not(PICS_MEC_PLAT) or not(PICS_BWMANAGEMENT_API_SUPPORTED)) {
@@ -309,7 +310,7 @@ module AtsMec_TrafficManagementAPI_TestCases {
                                                         m_http_message_body_json(
                                                                                  m_body_json_bw_info(
                                                                                                      m_bw_info(
                                                                                                                PX_APP_INSTANCE_ID,
                                                                                                                v_app_instance_id,
                                                                                                                APPLICATION_SPECIFIC_BW_ALLOCATION, // Request type
                                                                                                                "1024", // FixedAllocation
                                                                                                                Downlink // AllocationDirection
@@ -330,7 +331,7 @@ module AtsMec_TrafficManagementAPI_TestCases {
                                                                            mw_http_message_body_json(
                                                                                                      mw_body_json_bw_info(
                                                                                                                           mw_bw_info(
                                                                                                                                      PX_APP_INSTANCE_ID
                                                                                                                                      v_app_instance_id
                                                                                                                                      )))))) -> value v_response {
            tc_ac.stop;

@@ -363,6 +364,7 @@ module AtsMec_TrafficManagementAPI_TestCases {
        // Local variables
        var Headers v_headers;
        var HttpMessage v_response;
        var JSON.String v_app_instance_id := PX_APP_INSTANCE_ID & oct2unichar(char2oct("002"));
        
        // Test control
        if (not(PICS_MEC_PLAT) or not(PICS_BWMANAGEMENT_API_SUPPORTED)) {
@@ -386,11 +388,11 @@ module AtsMec_TrafficManagementAPI_TestCases {
                                                         m_http_message_body_json(
                                                                                  m_body_json_bw_info(
                                                                                                      m_bw_info(
                                                                                                                PX_APP_INSTANCE_ID,
                                                                                                                v_app_instance_id,
                                                                                                                SESSION_SPECIFIC_BW_ALLOCATION, // Request type
                                                                                                                "1024", // FixedAllocation
                                                                                                                Downlink, // AllocationDirection
                                                                                                                { m_session_filter("10.10.10.10", { "10" }) }
                                                                                                                { m_session_filter("10.10.10.10", { "1010" }) }
                                                                                                                )
                                                                                                      )
                                                                                  )
@@ -408,7 +410,7 @@ module AtsMec_TrafficManagementAPI_TestCases {
                                                                            mw_http_message_body_json(
                                                                                                      mw_body_json_bw_info(
                                                                                                                           mw_bw_info(
                                                                                                                                      PX_APP_INSTANCE_ID,
                                                                                                                                      v_app_instance_id,
                                                                                                                                      SESSION_SPECIFIC_BW_ALLOCATION, // Request type
                                                                                                                                      "1024", // FixedAllocation
                                                                                                                                      Downlink, // AllocationDirection
@@ -541,7 +543,7 @@ module AtsMec_TrafficManagementAPI_TestCases {
                                                                                                                APPLICATION_SPECIFIC_BW_ALLOCATION, // Request type
                                                                                                                "1024", // FixedAllocation
                                                                                                                Downlink, // AllocationDirection
                                                                                                                { m_session_filter("10.10.10.10", { "10" }) } // MEC015 Clause 7.2.2 Type: BwInfo Table 7.2.2-1: Elements of BwInfo, sessionFilter shall be omit
                                                                                                                { m_session_filter("10.10.10.10", { "1010" }) } // MEC015 Clause 7.2.2 Type: BwInfo Table 7.2.2-1: Elements of BwInfo, sessionFilter shall be omit
                                                                                                                )
                                                                                                      )
                                                                                  )
@@ -644,7 +646,7 @@ module AtsMec_TrafficManagementAPI_TestCases {
        
        // Postamble
        f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC015_SRV_TM_003_BR_02
    } // End of testcase TC_MEC_MEC015_SRV_TM_003_BR_03
    
    /**
     * @desc Check that the IUT responds with the configured bandwidth allocation when queried by a MEC Application
+189 −0
Original line number Diff line number Diff line
module TrafficManagementAPI_Functions {
  
  // JSON
  import from JSON all;
  
  // LibCommon
  import from LibCommon_BasicTypesAndValues all;
  import from LibCommon_Time all;
  import from LibCommon_VerdictControl all;
  import from LibCommon_Sync all;

  // LibHttp
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_Functions all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_JsonTemplates all;
  import from LibItsHttp_TestSystem all;

  // LibMec/TrafficManagementAPI
  import from TrafficManagementAPI_TypesAndValues all;
  import from TrafficManagementAPI_Templates all;
  import from TrafficManagementAPI_Pixits all;

  // LibMec
  import from LibMec_Templates all;
  import from LibMec_Functions all;
  import from LibMec_Pics all;
  import from LibMec_Pixits all;

  function f_create_bw_allocation_resource(
                                           in JSON.String p_app_instance_id,
                                           out charstring p_bw_allocation_id,
                                           out BwInfo p_bw_info
                                           ) runs on HttpComponent {
    var Headers v_headers;
    var HttpMessage v_response;

    p_bw_allocation_id := "";
    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PX_ME_BWM_URI,
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_bw_info(
                                                                                                  m_bw_info(
                                                                                                            p_app_instance_id,
                                                                                                            APPLICATION_SPECIFIC_BW_ALLOCATION, // Request type
                                                                                                            "1024", // FixedAllocation
                                                                                                            Downlink // AllocationDirection
                                                                                                            ))))));
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_ok(
                                                               mw_http_message_body_json(
                                                                                         mw_body_json_bw_info(
                                                                                                              mw_bw_info(
                                                                                                                         p_app_instance_id
                                                                                                                         )))))) -> value v_response {
        var charstring_list v_bw_allocation_id;
        
        tc_ac.stop;

        log("f_create_bw_allocation_resource: BwInfo recsource created: ", v_response);
        f_get_header(valueof(v_response.response.header), "Location", v_bw_allocation_id);
        if (lengthof(v_bw_allocation_id) != 0) {
          p_bw_allocation_id := v_bw_allocation_id[0];
          p_bw_info := v_response.response.body.json_body.bwInfo;
        }
      }
      [] tc_ac.timeout {
        log("f_create_bw_allocation_resource: Expected message not received");
      }
    } // End of 'alt' statement
  } // End of function f_create_bw_allocation_resource

  function f_delete_bw_allocation_resource(
                                           in JSON.String p_app_instance_id,
                                           in charstring p_bw_allocation_id
                                           ) runs on HttpComponent {
    var Headers v_headers;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_delete(
                                                       PX_ME_BWM_URI & "/" & p_bw_allocation_id,
                                                       v_headers
                                                       )));
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_204_no_content
                                           )) {
      }
      [] tc_ac.timeout {
        log("f_delete_bw_allocation_resource: Expected message not received");
      }
    } // End of 'alt' statement
  } // End of function f_delete_bw_allocation_resource

  function f_create_mts_session_info_resource(
                                              in JSON.String p_app_instance_id,
                                              out charstring p_mts_session_id,
                                              out MtsSessionInfo p_mts_session_info
                                              ) runs on HttpComponent {
    var Headers v_headers;
    var HttpMessage v_response;

    p_mts_session_id := "";
    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PX_ME_MTS_SESSIONS_URI,
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_mts_session_info(
                                                                                                           m_mts_session_info(
                                                                                                                              PX_APP_INSTANCE_ID,
                                                                                                                              APPLICATION_SPECIFIC_MTS_ALLOCATION, // Request type
                                                                                                                              m_qosd, // QoS
                                                                                                                              LowCost, // MtsMode
                                                                                                                              Downlink, // TrafficDirection
                                                                                                                              {
                                                                                                                                m_session_filter(
                                                                                                                                                 "10.10.10.10",
                                                                                                                                                 {"1010"}
                                                                                                                                                 )
                                                                                                                                } // FlowFilter
                                                                                                                              ))))));
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_ok(
                                                               mw_http_message_body_json(
                                                                                         mw_body_json_mts_session_info(
                                                                                                                       mw_mts_session_info(
                                                                                                                                           p_app_instance_id
                                                                                                                                           )))))) -> value v_response {
        var charstring_list v_mts_session_info_id;
        
        tc_ac.stop;

        log("f_create_mts_session_info_resource: BwInfo recsource created: ", v_response);
        f_get_header(valueof(v_response.response.header), "Location", v_mts_session_info_id);
        if (lengthof(v_mts_session_info_id) != 0) {
          p_mts_session_id := v_mts_session_info_id[0];
          p_mts_session_info := v_response.response.body.json_body.mtsSessionInfo;
        }
      }
      [] tc_ac.timeout {
        log("f_create_mts_session_info_resource: Expected message not received");
      }
    } // End of 'alt' statement
  } // End of function f_create_mts_session_info_resource

  function f_delete_mts_session_info_resource(
                                           in JSON.String p_app_instance_id,
                                           in charstring p_mts_session_id
                                           ) runs on HttpComponent {
    var Headers v_headers;

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_delete(
                                                       PX_ME_MTS_SESSIONS_URI & "/" & p_mts_session_id,
                                                       v_headers
                                                       )));
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_204_no_content
                                           )) {
      }
      [] tc_ac.timeout {
        log("f_delete_mts_session_info_resource: Expected message not received");
      }
    } // End of 'alt' statement
  } // End of function f_delete_mts_session_info_resource

} // End of module TrafficManagementAPI_Functions