AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.ttcn 217 KB
Newer Older
YannGarcia's avatar
YannGarcia committed
/**
 *    @author   ETSI / STF569
 *    @version  $URL:$
 *              $ID:$
 *    @desc     This module provides the MEC test cases.
 *    @copyright   ETSI Copyright Notification
 *                 No part may be reproduced except as authorized by written permission.
 *                 The copyright and the foregoing restriction extend to reproduction in all media.
 *                 All rights reserved.
Yann Garcia's avatar
Yann Garcia committed
 *    @see      ETSI GS MEC 003, Draft ETSI GS MEC 011 V3.2.1
YannGarcia's avatar
YannGarcia committed
 */
module AtsMec_EdgePlatformApplicationEnablementAPI_TestCases {
YannGarcia's avatar
YannGarcia committed
  // Libcommon
YannGarcia's avatar
YannGarcia committed
  import from LibCommon_BasicTypesAndValues all;
YannGarcia's avatar
YannGarcia committed
  import from LibCommon_Sync all;
YannGarcia's avatar
YannGarcia committed
  // LibHttp
  import from LibHttp_TypesAndValues all;
  import from LibHttp_Functions all;
  import from LibHttp_Templates all;
  import from LibHttp_JsonTemplates all;
  import from LibHttp_TestSystem all;
  // LibMec/EdgePlatformApplicationEnablementAPI
  import from EdgePlatformApplicationEnablementAPI_TypesAndValues all;
  import from EdgePlatformApplicationEnablementAPI_Templates all;
  import from EdgePlatformApplicationEnablementAPI_Functions all;
  import from EdgePlatformApplicationEnablementAPI_Pics all;
  import from EdgePlatformApplicationEnablementAPI_Pixits all;
YannGarcia's avatar
YannGarcia committed

Yann Garcia's avatar
Yann Garcia committed
  // LibMec/ApplicationPackageLifecycleAndOperationGrantingAPI
  import from ApplicationPackageLifecycleAndOperationGrantingAPI_Templates all;

YannGarcia's avatar
YannGarcia committed
  // LibMec
  import from LibMec_TypesAndValues all;
  import from LibMec_Templates all;
YannGarcia's avatar
YannGarcia committed
  import from LibMec_Functions all;
  import from LibMec_Pics all;
  import from LibMec_Pixits all;
Yann Garcia's avatar
Yann Garcia committed
  const charstring c_etag_http_header := "etag";
Yann Garcia's avatar
Yann Garcia committed
  /*
   * Application Service Availability Query (APPSAQ)
   */
YannGarcia's avatar
YannGarcia committed
  group app_saq {

    /**
     * @desc Check that the IUT responds with a list of available MEC services for a given application instance when queried by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_001_OK() runs on HttpComponent system HttpTestAdapter {
YannGarcia's avatar
YannGarcia committed
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
Yann Garcia's avatar
Yann Garcia committed
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;
YannGarcia's avatar
YannGarcia committed
      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

YannGarcia's avatar
YannGarcia committed
      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
YannGarcia's avatar
YannGarcia committed
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services",
YannGarcia's avatar
YannGarcia committed
                                                      v_headers
YannGarcia's avatar
YannGarcia committed
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);
YannGarcia's avatar
YannGarcia committed
      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_ok(
YannGarcia's avatar
YannGarcia committed
                                                                 mw_http_message_body_json(
Yann Garcia's avatar
Yann Garcia committed
                                                                                           mw_body_json_service_info_list(
                                                                                                                          {
                                                                                                                            *, 
                                                                                                                            mw_service_info(
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                                            ),
                                                                                                                            *
                                                                                                                          }
                            ))))) {
YannGarcia's avatar
YannGarcia committed
          tc_ac.stop;
          log("*** " & testcasename() & ": PASS: IUT successfully responds with to the service creation ***");
YannGarcia's avatar
YannGarcia committed
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
YannGarcia's avatar
YannGarcia committed
      // Postamble
      f_delete_service_info(v_subscription_id);
YannGarcia's avatar
YannGarcia committed
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_001_OK
YannGarcia's avatar
YannGarcia committed
    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
YannGarcia's avatar
YannGarcia committed
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_001_BR() runs on HttpComponent system HttpTestAdapter {
YannGarcia's avatar
YannGarcia committed
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
      var HttpMessage v_response;
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;
YannGarcia's avatar
YannGarcia committed
      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
YannGarcia's avatar
YannGarcia committed
        setverdict(inconc);
        stop;
      }
YannGarcia's avatar
YannGarcia committed
      // Test component configuration
      f_cf_01_http_up();
YannGarcia's avatar
YannGarcia committed
      // Test adapter configuration
YannGarcia's avatar
YannGarcia committed
      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
YannGarcia's avatar
YannGarcia committed
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services?instance_id=" & oct2char(unichar2oct(v_service_info.serInstanceId)),
YannGarcia's avatar
YannGarcia committed
                                                      v_headers
YannGarcia's avatar
YannGarcia committed
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);
YannGarcia's avatar
YannGarcia committed
      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_400_bad_request
YannGarcia's avatar
YannGarcia committed
          tc_ac.stop;
          log("*** " & testcasename() & ": PASS: IUT successfully responds with the correct error code ***");
YannGarcia's avatar
YannGarcia committed
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
YannGarcia's avatar
YannGarcia committed
      // Postamble
      f_delete_service_info(v_subscription_id);
YannGarcia's avatar
YannGarcia committed
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_001_BR
    /**
     * @desc Check that the IUT responds with an error when a request with an unknown service is sent by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_001_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var Headers v_headers;

      // Test control
      if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_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_get(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services?ser_instance_id=" & oct2char(unichar2oct(PX_NON_EXISTENT_SERVICE_NAME)),
                                                      v_headers
                    )));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_404_not_found
                            )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with the correct error code ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_001_NF

YannGarcia's avatar
YannGarcia committed
    /**
Yann Garcia's avatar
Yann Garcia committed
     * @desc Check that the IUT notifies the authorised relevant (subscribed) application instances when a new service for a given application instance is registered
YannGarcia's avatar
YannGarcia committed
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_002_OK() runs on HttpComponent system HttpTestAdapter {
YannGarcia's avatar
YannGarcia committed
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
YannGarcia's avatar
YannGarcia committed
      var HttpMessage v_response;
Yann Garcia's avatar
Yann Garcia committed
      var universal charstring v_service_name;
      var charstring v_subscription_id;
YannGarcia's avatar
YannGarcia committed
      // Test control
YannGarcia's avatar
YannGarcia committed
      if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not (PICS_NOTIFICATIONS) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PIC_NOTIFICATIONS and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
YannGarcia's avatar
YannGarcia committed
        setverdict(inconc);
        stop;
      }
YannGarcia's avatar
YannGarcia committed
      // Test component configuration
      f_cf_01_http_up();
YannGarcia's avatar
YannGarcia committed
      // Test adapter configuration
YannGarcia's avatar
YannGarcia committed
      // Preamble
      f_init_default_headers_list(-, -, v_headers);
Yann Garcia's avatar
Yann Garcia committed
      v_service_name := oct2unichar(char2oct("service_" & int2str(f_get_current_timestamp_utc())));
YannGarcia's avatar
YannGarcia committed
      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(
YannGarcia's avatar
YannGarcia committed
                                                                                                         m_service_info(
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                        v_service_name,
                                                                                                                        m_transport_info(
                                                                                                                                         "transportId1",
                                                                                                                                         "TC_MEC_MEC011_SRV_APPSAQ_002_OK",
                                                                                                                                         REST_HTTP,
                                                                                                                                         "HTTP",
                                                                                                                                         "2.0",
                                                                                                                                         m_end_point_uris({PX_APP_ENDPOINT_URI}),
                                                                                                                                         m_security_info
Yann Garcia's avatar
Yann Garcia committed
                    )))))));
YannGarcia's avatar
YannGarcia committed
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);
YannGarcia's avatar
YannGarcia committed
      // Test Body
      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(
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                                              v_service_name //serName
YannGarcia's avatar
YannGarcia committed
          tc_ac.stop;
          
          // Check HTTP Location header
          if (f_check_headers(v_response.response.header) == false) {
            log("*** " & testcasename() & ": FAIL: IUT failed in creating service  ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
          } else {
            var charstring_list v_header_location;
            f_get_header(v_response.response.header, "Location", v_header_location);
            v_subscription_id := regexp(
                                        v_header_location[0],
                                        "?+" & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services" & "/(?*)",
                                        0
                                        );

            // TODO how to test this as the notification is for another MEC Application?
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a ServiceInfo and set notification ***");
YannGarcia's avatar
YannGarcia committed
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          }
YannGarcia's avatar
YannGarcia committed
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
YannGarcia's avatar
YannGarcia committed
      // Postamble
      f_delete_service_info(v_subscription_id);
YannGarcia's avatar
YannGarcia committed
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_002_OK
YannGarcia's avatar
YannGarcia committed
    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
YannGarcia's avatar
YannGarcia committed
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_002_BR() runs on HttpComponent system HttpTestAdapter {
YannGarcia's avatar
YannGarcia committed
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
Yann Garcia's avatar
Yann Garcia committed
      var universal charstring v_service_name;
YannGarcia's avatar
YannGarcia committed
      // Test control
      if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
YannGarcia's avatar
YannGarcia committed
        setverdict(inconc);
        stop;
      }
YannGarcia's avatar
YannGarcia committed
      // Test component configuration
      f_cf_01_http_up();
YannGarcia's avatar
YannGarcia committed
      // Test adapter configuration
YannGarcia's avatar
YannGarcia committed
      // Preamble
      f_init_default_headers_list(-, -, v_headers);
Yann Garcia's avatar
Yann Garcia committed
      v_service_name := oct2unichar(char2oct("service_" & int2str(f_get_current_timestamp_utc())));
YannGarcia's avatar
YannGarcia committed
      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",
YannGarcia's avatar
YannGarcia committed
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_service_info(
YannGarcia's avatar
YannGarcia committed
                                                                                                         m_service_info(
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                        v_service_name,
                                                                                                                        -,
                                                                                                                        m_service_info_link("m_service_info_link") // Shall not be present in the request
                    ))))));
YannGarcia's avatar
YannGarcia committed
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);
YannGarcia's avatar
YannGarcia committed
      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_400_bad_request
          log("*** " & testcasename() & ": PASS: IUT successfully responds with the correct error code ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_002_BR

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_002_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_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_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/services",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_service_info(
YannGarcia's avatar
YannGarcia committed
                                                                                                         m_service_info(
                                                                                                                        PX_SERVICE_NAME,
                                                                                                                        -, -, -,
                                                                                                                        m_service_info_link("m_service_info_link")
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_404_not_found
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with the correct error code ***");
YannGarcia's avatar
YannGarcia committed
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_002_NF

    /**
     * @desc Check that the IUT responds with the information on a specific service for a given application instance when queried by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_003_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
      var HttpMessage v_response;
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

YannGarcia's avatar
YannGarcia committed
      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
YannGarcia's avatar
YannGarcia committed
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(v_service_info.serInstanceId, "UTF-8")),
YannGarcia's avatar
YannGarcia committed
                                                      v_headers
YannGarcia's avatar
YannGarcia committed
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);
YannGarcia's avatar
YannGarcia committed
      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_ok(
YannGarcia's avatar
YannGarcia committed
                                                                 mw_http_message_body_json(
                                                                                           mw_body_json_service_info(
                                                                                                                    mw_service_info(
                                                                                                                                    v_service_info.serName, 
                                                                                                                                    -, -, -, -,
                                                                                                                                    v_service_info.serInstanceId
                            )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ServiceInfo ***");
YannGarcia's avatar
YannGarcia committed
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_delete_service_info(v_subscription_id);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_003_OK
Yann Garcia's avatar
Yann Garcia committed
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application#
    testcase TC_MEC_MEC011_SRV_APPSAQ_003_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_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_get(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(PX_NON_EXISTENT_SERVICE_ID, "UTF-8")),
                                                      v_headers
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_404_not_found()
          log("*** " & testcasename() & ": PASS: IUT successfully responds with the correct error code ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_003_NF

    /**
     * @desc Check that the IUT updates a service information for a given application instance when commanded by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_004_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
Yann Garcia's avatar
Yann Garcia committed
      var charstring_list v_etag;
Yann Garcia's avatar
Yann Garcia committed
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & v_subscription_id,
Yann Garcia's avatar
Yann Garcia committed
                                                      v_headers,
                                                      m_http_message_body_json(
                                                                               m_body_json_service_info(
                                                                                                        m_service_info(
                                                                                                                       v_service_info.serName,
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                       PX_NEW_SERVICE_INFO_VERSION,
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                       v_service_info.transportInfo
      f_selfOrClientSyncAndVerdict(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_service_info(
YannGarcia's avatar
YannGarcia committed
                                                                                                                     mw_service_info(
                                                                                                                                     v_service_info.serName,
                                                                                                                                     PX_NEW_SERVICE_INFO_VERSION,
                                                                                                                                     -, -, -, -, -,
                                                                                                                                     v_service_info.transportInfo
                            )))))) {
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a modified ServiceInfo ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_delete_service_info(v_subscription_id);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_004_OK

    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_004_BR() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
Yann Garcia's avatar
Yann Garcia committed
      var charstring_list v_etag;
Yann Garcia's avatar
Yann Garcia committed
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;

      // Test control
      if (not(PICS_MEC_PLAT) or not (PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & v_subscription_id,
                                                      v_headers,
                                                      m_http_message_body_json(
                                                                               m_body_json_service_info(
                                                                                                        m_service_info(
                                                                                                                       v_service_info.serName,
                                                                                                                       PX_NEW_SERVICE_INFO_VERSION,
                                                                                                                       -, -,
                                                                                                                       m_service_info_link("m_service_info_link")
                    ))))));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_400_bad_request
          log("*** " & testcasename() & ": PASS: IUT successfully responds with the correct error code ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_delete_service_info(v_subscription_id);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_004_BR

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_004_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

      // Preamble
      // TODO If-Match header needs to have a PROPER_ETAG
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
                                                       PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(PX_NON_EXISTENT_SERVICE_ID, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_service_info(
YannGarcia's avatar
YannGarcia committed
                                                                                                         m_service_info(
                                                                                                                        PX_SERVICE_NAME,
                                                                                                                        PX_NEW_SERVICE_INFO_VERSION,
                                                                                                                        -, -,
                                                                                                                        m_service_info_link("m_service_info_link")
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_404_not_found
          log("*** " & testcasename() & ": PASS: IUT successfully responds with the correct error code ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_004_NF

    /**
     * @desc Check that the IUT responds with an error when a request sent by a MEC Application doesn't comply with a required condition
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_004_PF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
Yann Garcia's avatar
Yann Garcia committed
      var charstring_list v_etag;
Yann Garcia's avatar
Yann Garcia committed
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
Yann Garcia's avatar
Yann Garcia committed
      if (f_check_headers(v_headers, c_etag_http_header) == false) {
        log("*** " & testcasename() & ": INCONC: 'ETag' HTTP header not set ***");
        f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
      }
      f_get_header(v_headers, c_etag_http_header, v_etag);
      // If-Match header needs to have an INVALID_ETAG
      f_init_default_headers_list(-, -, v_headers);
Yann Garcia's avatar
Yann Garcia committed
      f_set_headers_list({ "If-Match" }, { int2str(f_get_current_timestamp_utc()) }, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
                                                      PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(v_service_info.serName, "UTF-8")),
Yann Garcia's avatar
Yann Garcia committed
                                                      v_headers,
                                                      m_http_message_body_json(
                                                                               m_body_json_service_info(
                                                                                                        m_service_info(
                                                                                                                       v_service_info.serName,
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                       PX_NEW_SERVICE_INFO_VERSION,
                                                                                                                       -, -,
                                                                                                                       m_service_info_link("m_service_info_link"),
                                                                                                                       -, -,
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                       v_service_info.transportInfo
                                                                                                                       )
                                                                                                        )
                                                                               )
                                                      )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_412_precondition_failed
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 412 Precondition Failed ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_delete_service_info(v_subscription_id);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_004_PF
    /**
     * @desc Check that the IUT executes the deletion of a service for a given application instance when requested by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_005_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var Headers v_headers;
      var ServiceInfo v_service_info;
      var charstring v_subscription_id;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

      // Preamble
      f_create_service_info(v_service_info, v_subscription_id);
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_delete(
                                                         PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & v_subscription_id,
                                                         v_headers
                    )));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_204_no_content
                            )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds successfully to the service delation ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_005_OK

    /**
     * @desc Check that the IUT responds with an error when a request for deletion of a unknown service is sent by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSAQ_005_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var Headers v_headers;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_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_delete(
                                                         PICS_ROOT_API & PX_ME_APP_REG_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & PX_NON_EXISTENT_SERVICE_NAME,
                                                         v_headers
                    )));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_404_not_found
                            )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds successfully with the correct error code ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_005_NF

YannGarcia's avatar
YannGarcia committed
  } // End of group app_saq

   /*
    * Application Subscriptions (APPSUB)
    */
YannGarcia's avatar
YannGarcia committed
  group app_sub {

    /**
     * @desc Check that the IUT responds with a list of subscriptions for notifications on services availability when queried by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_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_get(
                                                      PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions",
                                                      v_headers
                                                      )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_ok(
YannGarcia's avatar
YannGarcia committed
                                                                 mw_http_message_body_json(
                                                                                           mw_body_json_subscription_link_list(
                                                                                                                               mw_subscription_link_list
                                                                                                                               ))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a Mp1SubscriptionLinkList ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSUB_001_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_001_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;

      // Test control
      if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_APP_ENABLEMENT_API_SUPPORTED)) {
        log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_APP_ENABLEMENT_API_SUPPORTED required for executing the TC ***");
        setverdict(inconc);
        stop;
      }

      // Test component configuration
      f_cf_01_http_up();

      // Test adapter configuration

      // Preamble