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

Validate TC_MEC_MEC011_SRV_MSL_xxx

parent 53c05408
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@ int json_codec_mec011::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& ms
    const EdgePlatformApplicationEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription& ser = msg.serAvailabilityNotificationSubscription();
    ser.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::SerAvailabilityNotificationSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
    data = /*char2oct(CHARSTRING("{\"SerAvailabilityNotificationSubscription\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/;
  } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_serviceLivenessUpdate)) {
    const EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceLivenessUpdate& service_liveness_update = msg.serviceLivenessUpdate();
    service_liveness_update.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceLivenessUpdate_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
    data = char2oct(CHARSTRING("{\"serviceLivenessUpdate\": ")) + OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data()) + char2oct(CHARSTRING("}"));
  } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_trafficRule)) {
    const EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRule& traffic_rule = msg.trafficRule();
    traffic_rule.encode(EdgePlatformApplicationEnablementAPI__TypesAndValues::TrafficRule_descr_, encoding_buffer, TTCN_EncDec::CT_JSON);
@@ -165,6 +169,10 @@ int json_codec_mec011::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBo
    EdgePlatformApplicationEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription app_term;
    app_term.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::AppTerminationNotificationSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
    msg.appTerminationNotificationSubscription() = app_term;
  } else if ((it->second.find("\"state\"") != std::string::npos) && (it->second.find("\"interval\"") != std::string::npos)) {
      EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceLivenessInfo service_liveness_info;
      service_liveness_info.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::ServiceLivenessInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
      msg.serviceLivenessInfo() = service_liveness_info;
  } else if ((it->second.find("\"ntpServers\"") != std::string::npos) || (it->second.find("{\"timeStamp\"") == 0)) {
    EdgePlatformApplicationEnablementAPI__TypesAndValues::TimingCaps timing_caps;
    timing_caps.decode(EdgePlatformApplicationEnablementAPI__TypesAndValues::TimingCaps_descr_, decoding_buffer, TTCN_EncDec::CT_JSON);
+3 −7
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ LibMec_Pics.PICS_ROOT_API := "/sbxykqjr17/mep1/" # Need to sign i
LibMec_Pics.PICS_MEC_PLAT := true

# Application Instance ID
EdgePlatformApplicationEnablementAPI_Pixits.PX_APP_INSTANCE_ID := "6c6b308f-4849-413a-9b15-6cae37ee5fce" # Copied from ETSI MEC Sandbox GUI
EdgePlatformApplicationEnablementAPI_Pixits.PX_APP_INSTANCE_ID := "bd880c4d-5d75-43d4-8541-d852db57f1ab" # Copied from ETSI MEC Sandbox GUI

# Callbacks

@@ -127,7 +127,7 @@ system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec011)/TCP(debug=1
# Check that the IUT responds with an error when a request for an URI that cannot be mapped to a valid resource URI is sent by a MEC Application
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_MSL_001_NF
# Check that the IUT updates the liveness of a MEC service instance when requested by a MEC Application
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_MSL_002_OK
AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_MSL_002_OK
# Check that the IUT responds with an error when incorrect parameters were sent by a MEC Application
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_MSL_002_BR

@@ -149,7 +149,7 @@ system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec011)/TCP(debug=1
# Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_SRVSUB_002_BR
# Check that the IUT responds with the information on a specific subscription when queried by a MEC Application
AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_SRVSUB_003_OK
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_SRVSUB_003_OK
# Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_SRVSUB_003_NF
# Check that the IUT acknowledges the unsubscribe from service availability event notifications when commanded by a MEC Application
@@ -188,10 +188,6 @@ AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_SRVSUB_0
# Check that the IUT responds with an error when queried to delete an unknown MEC Application registration
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_REGAPPS_004_NF





# Check that the IUT responds with timing capabilities when queried by a MEC Application
#AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.TC_MEC_MEC011_SRV_TIME_001_OK
# Check that the IUT responds with current time when queried by a MEC Application
+3 −6
Original line number Diff line number Diff line
@@ -8,14 +8,12 @@ LibCommon_Time.PX_TAC := 30.0
LibCommon_Sync.PX_TSYNC_TIME_LIMIT := 30.0;
LibCommon_Sync.PX_TSHUT_DOWN_TIME_LIMIT := 30.0;

LibHttp_Pics.PICS_HEADER_HOST := "try-mec.etsi.org" #"192.168.1.39"
LibHttp_Pics.PICS_HEADER_HOST := "192.168.1.39"

LibHttp_Pics.PICS_HEADER_CONTENT_TYPE := "application/json"
LibHttp_Pics.PICS_USE_TOKEN_HEADER    := true
#LibHttp_Pics.PICS_TOKEN_HEADER        := "Basic WrongToken"

LibMec_Pics.PICS_ROOT_API                := "/sbx1y8q0x9/mep1" # Need to sign in on https://try-mec.etsi.org/, section 'Try-it from your MEC application'

# LibMec_Pixits


@@ -35,9 +33,8 @@ LogEventTypes:= Yes

[TESTPORT_PARAMETERS]
# In this section you can specify parameters that are passed to Test Ports.
#system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=192.168.1.39,port=30030,use_ssl=0)"
system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=try-mec.etsi.org,port=443,use_ssl=1)"
#system.httpPort_notif.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server_mode=1,local_port=443,use_ssl=1)"
system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=192.168.1.21,port=30030,use_ssl=0)"
#system.httpPort.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server=try-mec.etsi.org,port=443,use_ssl=1)"
system.httpPort_notif.params := "HTTP(codecs=json:json_codec)/TCP(debug=1,server_mode=1,local_port=80,use_ssl=0)"

[DEFINE]
+25 −18
Original line number Diff line number Diff line
@@ -2081,6 +2081,9 @@ module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {

  } // End of group app_dns

  /*
   * LivenessInfo (MSL)
   */
  group msl {

    /**
@@ -2091,6 +2094,7 @@ module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {
      var Headers v_headers;
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;
      var charstring v_uri;

      // Test control
      if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
@@ -2105,12 +2109,17 @@ module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {
      // Test adapter configuration

      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
      f_create_service_info_with_liveness(v_service_info, v_subscription_id);
      f_init_default_headers_list(-, -, v_headers);
      v_uri := regexp(
                      oct2char(unichar2oct(v_service_info.links.liveness.href, "UTF-8")),
                      "?+" & PX_LINK_LIV & "/(?*)",
                      0
                      );
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_ROOT_API & PX_LINK_LIV,
                                                      PICS_ROOT_API & PX_LINK_LIV & "/" & v_uri,
                                                      v_headers
                    )));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);
@@ -2201,6 +2210,7 @@ module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {
      var Headers v_headers;
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;
      var charstring v_uri;

      // Test control
      if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
@@ -2217,19 +2227,20 @@ module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {
      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
      f_init_default_headers_list(-, -, v_headers);
      v_uri := regexp(
                      oct2char(unichar2oct(v_service_info.links.liveness.href, "UTF-8")),
                      "?+" & PX_LINK_LIV & "/(?*)",
                      0
                      );
      httpPort.send(
                    m_http_request(
                                   m_http_request_patch(
                                                       PICS_ROOT_API & PX_LINK_LIV,
                                                       PICS_ROOT_API & PX_LINK_LIV & "/" & v_uri,
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_srv_liveness_info(
                                                                                                              m_service_liveness_info(
                                                                                                                                      ACTIVE,
                                                                                                                                      m_time_stamp(
                                                                                                                                                   f_get_current_timestamp_utc()
                                                                                                                                                   ),
                                                                                                                                      10
                                                                                m_body_json_srv_liveness_update(
                                                                                                                m_service_liveness_update(
                                                                                                                                          ACTIVE
                    ))))));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

@@ -2246,7 +2257,7 @@ module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {
                            )))))) {
          tc_ac.stop;
          
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a new ServiceLivenessInfo ***");
          log("*** " & testcasename() & ": PASS: IUT successfully responds with an updated ServiceLivenessInfo ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
@@ -2287,13 +2298,9 @@ module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {
                                                       PICS_ROOT_API & PX_LINK_LIV,
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_srv_liveness_info(
                                                                                                              m_service_liveness_info(
                                                                                                                                      INACTIVE,
                                                                                                                                      m_time_stamp(
                                                                                                                                                   f_get_current_timestamp_utc()
                                                                                                                                                   ),
                                                                                                                                      10
                                                                                m_body_json_srv_liveness_update(
                                                                                                                m_service_liveness_update(
                                                                                                                                          INACTIVE
                    ))))));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

+64 −0
Original line number Diff line number Diff line
@@ -86,6 +86,70 @@ module EdgePlatformApplicationEnablementAPI_Functions {
    } // End of 'alt' statement
  } // End of function f_create_service_info
  
  function f_create_service_info_with_liveness(
                                               out ServiceInfo p_service_info,
                                               out charstring p_subscription_id
                                               ) runs on HttpComponent {
    var Headers v_headers;
    var HttpMessage v_response;
    var universal charstring v_service_name := oct2unichar(char2oct("service_" & int2str(f_get_current_timestamp_utc())));

    f_init_default_headers_list(-, -, v_headers);
    httpPort.send(
                  m_http_request(
                                 m_http_request_post(
                                                     PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services",
                                                     v_headers,
                                                     m_http_message_body_json(
                                                                              m_body_json_service_info(
                                                                                                       m_service_info(
                                                                                                                      v_service_name,
                                                                                                                      -, -, -, -, -, -,
                                                                                                                      m_transport_info(
                                                                                                                                       "REST",
                                                                                                                                       "REST_HTTP",
                                                                                                                                       REST_HTTP,
                                                                                                                                       "HTTP",
                                                                                                                                       "2.0",
                                                                                                                                       m_end_point_uris({"/meMp1/service/MyEntryPoint"}),
                                                                                                                                       m_security_info
                                                                                                                                       ),
                                                                                                                      -,
                                                                                                                      PX_LIVENESS_INTERVAL
                  ))))));
    tc_ac.start;
    alt {
      [] httpPort.receive(
                          mw_http_response(
                                           mw_http_response_201_created(
                                                                        mw_http_message_body_json(
                                                                                                  mw_body_json_service_info(
                                                                                                                            mw_service_info(
                                                                                                                                            v_service_name,
                                                                                                                                            -, -, -,
                                                                                                                                            mw_service_info_link_liveness
                          )))))) -> value v_response {
        tc_ac.stop;
        
        // Extract HTTP Location header
        var charstring_list v_subscription_id;
        f_get_header(v_response.response.header, "Location", v_subscription_id);
        // Extract HTTP subssription id
        p_subscription_id := regexp(
                                    v_subscription_id[0],
                                    "?+" & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services" & "/(?*)",
                                    0
                                    );
        p_service_info := v_response.response.body.json_body.serviceInfo;
        log("f_create_service_info: INFO: IUT successfully responds to the service creation: ", p_service_info);
        log("f_create_service_info: INFO: Resource URI: ", p_subscription_id);
      }
      [] tc_ac.timeout {
        log("f_create_service_info: INCONC: Expected message not received");
      }
    } // End of 'alt' statement
  } // End of function f_create_service_info_with_liveness
  
  function f_delete_service_info(
                                 in charstring p_subscription_id
                                 ) runs on HttpComponent {
Loading