Commit d91c2529 authored by Yann Garcia's avatar Yann Garcia
Browse files

Finalyze UEidentityAPI support

parent a85ee750
Loading
Loading
Loading
Loading
+22 −10
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
#include "LibItsHttp_TypesAndValues.hh"
#include "LibItsHttp_MessageBodyTypes.hh"
#include "LibItsHttp_XmlMessageBodyTypes.hh"
#include "LibItsHttp_JsonMessageBodyTypes.hh"

int http_codec::encode (const LibItsHttp__TypesAndValues::HttpMessage& msg, OCTETSTRING& data)
{
@@ -413,16 +414,6 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
        if (it != _codecs.cend()) {
          loggers::get_instance().log("http_codec::encode_body: Call '%s'", it->first.c_str());
          //_codecs["http_its"]->encode((Record_Type&)binary_body.ieee1609dot2__data(), p_encoding_buffer); // TODO Use params
          
          
#if defined(GEMALTO_FIX) // Temporary fix to be removed
          // GEMALTO Encode in hex string
          CHARSTRING buf = oct2str(p_encoding_buffer);
          p_encoding_buffer = OCTETSTRING(buf.lengthof(), (const unsigned char*)(static_cast<const char*>(buf)));
          loggers::get_instance().log_msg("http_codec::encode_body: Convert binary to string: ", p_encoding_buffer);
#endif
          
          
          processed = true;
        }
      } // TODO Add new HTTP message codec here
@@ -463,6 +454,27 @@ int http_codec::encode_body(const LibItsHttp__MessageBodyTypes::HttpMessageBody&
        p_encoding_buffer = OCTETSTRING(0, nullptr);
      }
    }
  } else if (p_message_body.ischosen(LibItsHttp__MessageBodyTypes::HttpMessageBody::ALT_json__body)) {
    const LibItsHttp__JsonMessageBodyTypes::JsonBody& json_body = p_message_body.json__body();
    if (json_body.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_raw)) {
      p_encoding_buffer = unichar2oct(json_body.raw());
    } else {
      std::map<std::string, std::unique_ptr<codec<Record_Type, Record_Type> > >::const_iterator it;
      bool processed = false;
      loggers::get_instance().log("http_codec::encode_body: Content-Type:'%s'", p_content_type.c_str());
      if (p_content_type.find("json") != std::string::npos) {
        it = _codecs.find("json"); // TODO Use params
        if (it != _codecs.cend()) {
          loggers::get_instance().log("http_codec::encode_body: Call 'json_codec'");
          _codecs["json"]->encode((Record_Type&)json_body, p_encoding_buffer); // TODO Use params
          processed = true;
        }
      } // TODO Add new HTTP message codec here
      if (!processed) {
        loggers::get_instance().warning("http_codec::encode_body: Unsupported HTTP codec, use raw field as default");
        p_encoding_buffer = OCTETSTRING(0, nullptr);
      }
    }
  } else {
    loggers::get_instance().warning("http_codec::encode_body: Failed to encode HTTP message body");
    return -1;
+12 −2
Original line number Diff line number Diff line
@@ -16,7 +16,13 @@ int json_codec::encode (const LibItsHttp__JsonMessageBodyTypes::JsonBody& msg, O
  TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
  TTCN_Buffer encoding_buffer;

  loggers::get_instance().error("json_codec::encode: Not supported: ");
  if (msg.ischosen(LibItsHttp__JsonMessageBodyTypes::JsonBody::ALT_ueIdentityTagInfo)) {
    const UEidentityAPI__TypesAndValues::UeIdentityTagInfo& ue_identity_tag_info = msg.ueIdentityTagInfo();
    ue_identity_tag_info.encode(UEidentityAPI__TypesAndValues::UeIdentityTagInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
    data = OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data());
  } else {
    loggers::get_instance().error("json_codec::encode: Not supported");
  }
  
  loggers::get_instance().log("<<< json_codec::encode");
  return 0;
@@ -56,6 +62,10 @@ int json_codec::decode (const OCTETSTRING& p_data, LibItsHttp__JsonMessageBodyTy
    UEidentityAPI__TypesAndValues::UeIdentityTagInfo ue_identity_tag_info;
    ue_identity_tag_info.decode(UEidentityAPI__TypesAndValues::UeIdentityTagInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.ueIdentityTagInfo() = ue_identity_tag_info;
  } else if (it->second.find("\"problemDetails\"") != std::string::npos) {
    UEidentityAPI__TypesAndValues::ProblemDetails problem_details;
    problem_details.decode(UEidentityAPI__TypesAndValues::ProblemDetails_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.problemDetails() = problem_details;
  } else {
    loggers::get_instance().warning("json_codec::decode: Unsupported variant");
    return -1;
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ module AtsMec_TestControl {
      }
      if (PICS_UE_IDENTITY_API_SUPPORTED) {
        execute(TC_MEC_PLAT_MP1_UETAG_BV_001());
        execute(TC_MEC_PLAT_MP1_UETAG_BV_002());
        execute(TC_MEC_PLAT_MP1_UETAG_BV_003());
      }
    }
  }
+184 −45
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@ module AtsMec_UEidentityAPI_TestCases {
                                                                 mw_http_message_body_json(
                                                                                           mw_body_json_ue_identity_tag_info(
                                                                                                                             mw_ue_identity_tag_info(
                                                                                                                                                       ?
                                                                                                                                                     { *, mw_ue_identity_tag_item(PX_UE_IDENTITY_TAG, REGISTERED), * }

                                                                                                                                                                                                                                                                                                          )))))) -> value v_response {
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
@@ -93,6 +94,144 @@ module AtsMec_UEidentityAPI_TestCases {
      f_cf_01_http_down();
    } // End of testcase TC_MEC_PLAT_MP1_UETAG_BV_001
    
    /**
     * @desc Check that the IUT registers a tag (representing a UE) or a list of tags when commanded by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/UeIdentity/PlatUeIdentity.tplan2
     */
    testcase TC_MEC_PLAT_MP1_UETAG_BV_002() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines v_headers;
      var HttpMessage v_response;
      
      // Test control
      if (not(PICS_ME_APP_IUT) or not(PICS_UE_IDENTITY_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_ME_APP_IUT and PICS_LOCATION_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }
      
      // Test component configuration
      f_cf_01_http_up();
      
      // Test adapter configuration
      
      // Preamble
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                       PICS_ME_APP_Q_UE_IDENTITY_ID_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/ue_identity_tag_info",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_ue_identity_tag_info(
                                                                                                                 m_ue_identity_tag_info(
                                                                                                                                        {
                                                                                                                                          m_ue_identity_tag_item(
                                                                                                                                                                 PX_UE_IDENTITY_TAG,
                                                                                                                                                                 REGISTERED
                                                                                                                                                                 )
                                                                                                                                          }
                                                                                                                                        )
                                                                                                                 )
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
      
      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_ok(
                                                                 mw_http_message_body_json(
                                                                                           mw_body_json_ue_identity_tag_info(
                                                                                                                             mw_ue_identity_tag_info(
                                                                                                                                                     { *, mw_ue_identity_tag_item(PX_UE_IDENTITY_TAG, REGISTERED), * }
                                                                                                                                                     )))))) -> value v_response {
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
      
      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_PLAT_MP1_UETAG_BV_002
    
    /**
     * @desc Check that the IUT deregisters a tag (representing a UE) or a list of tags when commanded by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/MEC-tests/blob/master/Test%20Purposes/Plat/Mp1/UeIdentity/PlatUeIdentity.tplan2
     */
    testcase TC_MEC_PLAT_MP1_UETAG_BV_003() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines v_headers;
      var HttpMessage v_response;
      
      // Test control
      if (not(PICS_ME_APP_IUT) or not(PICS_UE_IDENTITY_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_ME_APP_IUT and PICS_LOCATION_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }
      
      // Test component configuration
      f_cf_01_http_up();
      
      // Test adapter configuration
      
      // Preamble
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                       PICS_ME_APP_Q_UE_IDENTITY_ID_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/ue_identity_tag_info",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_ue_identity_tag_info(
                                                                                                                 m_ue_identity_tag_info(
                                                                                                                                        {
                                                                                                                                          m_ue_identity_tag_item(
                                                                                                                                                                 PX_UE_IDENTITY_TAG,
                                                                                                                                                                 UNREGISTERED
                                                                                                                                                                 )
                                                                                                                                          }
                                                                                                                                        )
                                                                                                                 )
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdictTestBody(c_prDone, e_success);
      
      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_ok(
                                                                 mw_http_message_body_json(
                                                                                           mw_body_json_ue_identity_tag_info(
                                                                                                                             mw_ue_identity_tag_info(
                                                                                                                                                     { *, mw_ue_identity_tag_item(PX_UE_IDENTITY_TAG, UNREGISTERED), * }
                                                                                                                                                     )))))) -> value v_response {
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
      
      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_PLAT_MP1_UETAG_BV_003
    
  } // End of group me_app_role 
  
} // End of module AtsMec_TestCases 
+47 −38
Original line number Diff line number Diff line
@@ -82,6 +82,15 @@ module LibMec_Functions {
        log("*** " & testcasename() & ": FAIL: Unexpected XML response ***");
        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
      }
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_ok(
                                                               mw_http_message_body_json
                                                               ))) {
        tc_ac.stop;
        log("*** " & testcasename() & ": FAIL: Unexpected JSON response ***");
        f_selfOrClientSyncAndVerdictTestBody(c_tbDone, e_error);
      }
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_ok(
Loading