Skip to content
AtsMec_AppEnablementAPI_TestCases.ttcn 170 KiB
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.
 *    @see      ETSI GS MEC 003, Draft ETSI GS MEC 011 V2.2.1
YannGarcia's avatar
YannGarcia committed
 */
module AtsMec_AppEnablementAPI_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 LibItsHttp_TypesAndValues all;
  import from LibItsHttp_Functions all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_JsonTemplates all;
  import from LibItsHttp_TestSystem all;
YannGarcia's avatar
YannGarcia committed
  // LibMec/AppEnablementAPI
Yann Garcia's avatar
Yann Garcia committed
  import from AppEnablementAPI_TypesAndValues all;
YannGarcia's avatar
YannGarcia committed
  import from AppEnablementAPI_Templates all;
  import from AppEnablementAPI_Functions all;
YannGarcia's avatar
YannGarcia committed
  import from AppEnablementAPI_Pics all;
  import from AppEnablementAPI_Pixits all;
YannGarcia's avatar
YannGarcia committed

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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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;
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_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services",
YannGarcia's avatar
YannGarcia committed
                                                      v_headers
                                                      )
                                   )
                    );
      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_list
                                                                                           )))) {
YannGarcia's avatar
YannGarcia committed
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ServiceInfoList ***");
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_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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
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;
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);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services?instance_id=" & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID)),
YannGarcia's avatar
YannGarcia committed
                                                      v_headers
                                                      )
                                   )
                    );
      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 a ProblemDetails set to 400 Bad Request ***");
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_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_001_BR
YannGarcia's avatar
YannGarcia committed
    /**
     * @desc Check that the IUT notifies the authorised relevant (subscribed) application instances when a new service for a given application instance is registered.
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
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;
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_MEC_SVC_MGMT_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_service_info_link("m_service_info_link"),
                                                                                                                        -,
                                                                                                                        -,
                                                                                                                        m_transport_info(
                                                                                                                                         "transportId1",
                                                                                                                                         "TC_MEC_MEC011_SRV_APPSAQ_002_OK",
                                                                                                                                         REST_HTTP,
                                                                                                                                         "HTTP",
                                                                                                                                         "2.0",
                                                                                                                                         m_end_point_uris({"/meMp1/service/MyEntryPoint"}),
                                                                                                                                         m_security_info
                                                                                                                                         )
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
                                                                                                                                              )))))) -> value v_response {
YannGarcia's avatar
YannGarcia committed
          tc_ac.stop;
          
          if (f_check_headers(valueof(v_response.response.header)) == true) {
/* TODO how to test this as the notification is for another MEC Application?
               and
               // MEC 011, clause 6.4.2
               the IUT entity sends a notification_message containing
                  body containing
                     notificationType set to "SerAvailabilityNotification",
                     services containing
                        serName set to SERVICE_NAME
                     _links containing
                        subscription set to MP1_SUBSCRIPTION_A
                     ;
                     ;
                  ;
               ;
               to the MEC_APP_Subscriber entity
*/
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a ServiceInfo and set notification ***");
YannGarcia's avatar
YannGarcia committed
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } else {
            log("*** " & testcasename() & ": FAIL: Header 'Location' was not present in the response headers ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
          }
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_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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
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_MEC_SVC_MGMT_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,
                                                                                                                        -,
                                                                                                                        RAW,
                                                                                                                        m_service_info_link("m_service_info_link")
YannGarcia's avatar
YannGarcia 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(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_400_bad_request
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
          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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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_MEC_SVC_MGMT_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 a ProblemDetails set to 404 Not Found ***");
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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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;

      // 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_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(PX_SERVICE_ID, "UTF-8")),
YannGarcia's avatar
YannGarcia committed
                                                      v_headers
                                                      )
                                   )
                    );
      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(
                                                                                                                                    -, -, -, -, -,
YannGarcia's avatar
YannGarcia committed
                                                                                                                                    PX_SERVICE_ID
                                                                                                                                    )))))) {
          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_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_003_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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_MEC_SVC_MGMT_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()
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 404 Not Found ***");
          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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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;

      // 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_headers);
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); // TODO Check headers
      // If-Match header needs to have a PROPER_ETAG
      f_init_default_headers_list(-, -, v_headers);
Yann Garcia's avatar
Yann Garcia committed
      f_set_headers_list({ "If-Match" }, v_etag, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
                                                      PICS_ROOT_API & PX_MEC_SVC_MGMT_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(
                                             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,
YannGarcia's avatar
YannGarcia committed
                                                                                                                                     PX_NEW_SERVICE_INFO_VERSION
                                                                                                                                     )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a 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_service_info);
      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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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;

      // 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_headers);
      if (f_check_headers(v_headers, c_etag_http_header) == false) {
        log("*** " & testcasename() & ": INCONC: 'ETag' HTTP header not set ***");
Yann Garcia's avatar
Yann Garcia committed
        f_selfOrClientSyncAndVerdict(c_prDone, e_timeout);
      }
      f_get_header(v_headers, c_etag_http_header, v_etag); // TODO Check headers
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); // TODO Check headers
      // If-Match header needs to have a PROPER_ETAG
      f_init_default_headers_list(-, -, v_headers);
Yann Garcia's avatar
Yann Garcia committed
      f_set_headers_list({ "If-Match" }, v_etag, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/services/" & oct2char(unichar2oct(v_service_info.serName, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_service_info(
YannGarcia's avatar
YannGarcia committed
                                                                                                         m_service_info(
                                                                                                                        v_service_info.serName & char(0, 0, 1, 111),
                                                                                                                        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
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
          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_service_info);
      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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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_MEC_SVC_MGMT_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
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 404 Not Found ***");
          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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppServices.tplan2
     */
    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;

      // 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_headers);
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_MEC_SVC_MGMT_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_service_info);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSAQ_004_PF
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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    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
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_NON_EXISTENT_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(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_404_not_found
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 404 Not Found ***");
          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_NF

    /**
     * @desc Check that the IUT acknowledges the subscription by a MEC Application to notifications on service availability events.
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_002_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
YannGarcia's avatar
YannGarcia committed
      var HttpMessage v_response;

      // 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);
      //TODO Create a subsciption (see TC_MEC_MEC011_SRV_APPSUB_001_OK);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                      PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions",
                                                       v_headers,
                                                       m_http_message_body_json(
Yann Garcia's avatar
Yann Garcia committed
                                                                                m_body_json_app_termination_notif_subscription(
                                                                                                                               m_app_termination_notif_subscription(
YannGarcia's avatar
YannGarcia committed
                                                                                                                                                                    PX_APP_TERM_NOTIF_CALLBACK_URI,
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                                                                    -/*m_self(
YannGarcia's avatar
YannGarcia committed
                                                                                                                                                                           { href := PX_HREF }
Yann Garcia's avatar
Yann Garcia committed
                                                                                                                                                                           )*/,
                                                                                                                                                                    "ID1"/*PX_APP_INSTANCE_ID*/
                                                                                                                                                                    )
                                                                                                                               )
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_201_created(
Yann Garcia's avatar
Yann Garcia committed
                                                                          mw_http_message_body_json(
                                                                                                    mw_body_json_app_termination_notif_subscription(
                                                                                                                                                    mw_app_termination_notif_subscription(
                                                                                                                                                                                          PX_APP_TERM_NOTIF_CALLBACK_URI
                                                                                                                                                                                          )))))) -> value v_response {
YannGarcia's avatar
YannGarcia committed
          if (f_check_headers(valueof(v_response.response.header)) == true) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a AppTerminationNotificationSubscription ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } else {
            log("*** " & testcasename() & ": FAIL: Header 'Location' was not present in the response headers ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
          }
        }
        [] 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_002_OK

    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_002_BR() 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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_app_termination_notif_subscription(
YannGarcia's avatar
YannGarcia committed
                                                                                                                               m_app_termination_notif_subscription_invalid(
                                                                                                                                                                            PX_APP_TERM_NOTIF_CALLBACK_URI,
                                                                                                                                                                            m_self(
                                                                                                                                                                                   { href := PX_HREF }
                                                                                                                                                                                   ),
                                                                                                                                                                            PX_APP_INSTANCE_ID
                                                                                                                                                                            )
                                                                                                                               )
                                                                                )
                                                       )
                                   )
                    );
      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
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
          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_002_BR

    /**
     * @desc Check that the IUT responds with the information on a specific subscription when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_003_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/" & oct2char(unichar2oct(PX_SUBSCRIPTION_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_ok(
                                                                 mw_http_message_body_json(
YannGarcia's avatar
YannGarcia committed
                                                                                           mw_body_json_app_termination_notif_subscription(
                                                                                                                                           mw_app_termination_notif_subscription
                                                                                                                                           ))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a AppTerminationNotificationSubscription ***");
          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_003_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions/" & oct2char(unichar2oct(PX_NON_EXISTENT_SUBSCRIPTION_ID, "UTF-8")),
                                                      v_headers
                                                      )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_003_NF

    /**
     * @desc Check that the IUT acknowledges the unsubscribe from service availability event notifications when commanded by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_004_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_delete(
                                                         PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions/" & oct2char(unichar2oct(PX_SUBSCRIPTION_ID, "UTF-8")),
YannGarcia's avatar
YannGarcia committed
                                                         v_headers
                                                         )
                                   )
                    );
      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_204_no_content
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with no content ***");
          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_004_OK

    /**
     * @desc 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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/APPSAQ/PlatAppSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_APPSUB_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
      f_init_default_headers_list(-, -, v_headers);

      httpPort.send(
                    m_http_request(
                                   m_http_request_delete(
                                                         PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions/" & oct2char(unichar2oct(PX_SUBSCRIPTION_ID, "UTF-8")),
YannGarcia's avatar
YannGarcia committed
                                                         v_headers
                                                         )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_004_NF
YannGarcia's avatar
YannGarcia committed
  } // End of group app_sub
  group conf_task {
    /**
     * @desc Check that the IUT responds that it has completed the application level termination
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/CONFTASK/ConfirmTasks.tplan2
     */
    testcase TC_MEC_MEC011_SRV_CONFTASK_001_OK() 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_post(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/applications/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/confirm_termination",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_app_termination_confirmation(
                                                                                                                         { operationAction := TERMINATING }
                                                                                                                         )
                                                                                )
                                                       )
                                   )
                    );
      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 with a AppTerminationConf ***");
          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_CONFTASK_001_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an operationAction is sent to an unknown application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/CONFTASK/ConfirmTasks.tplan2
     */
    testcase TC_MEC_MEC011_SRV_CONFTASK_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_post(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/applications/" & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/confirm_termination",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_app_termination_confirmation(
                                                                                                                         { operationAction := TERMINATING }
                                                                                                                         )
                                                                                )
                                                       )
                                   )
                    );
      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_CONFTASK_001_NF
    
    /**
     * @desc Check that the IUT responds that the MEC application is up and running
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/CONFTASK/ConfirmTasks.tplan2
     */
    testcase TC_MEC_MEC011_SRV_CONFTASK_002_OK() 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_post(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/applications/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/confirm_ready",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_app_ready_confirmation(
                                                                                                                   { indication := "READY" }
                                                                                                                   )
                                                                                )
                                                       )
                                   )
                    );
      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 with a AppReadyConf ***");
          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_CONFTASK_002_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an indication is sent to an unknown application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/CONFTASK/ConfirmTasks.tplan2
     */
    testcase TC_MEC_MEC011_SRV_CONFTASK_002_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_post(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/applications/" & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/confirm_ready",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_app_ready_confirmation(
                                                                                                                   { indication := "READY" }
                                                                                                                   )
                                                                                )
                                                       )
                                   )
                    );
      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_CONFTASK_002_NF

  } // End of group conf_task

  /*
   * DNS rules (DNS)
   */
YannGarcia's avatar
YannGarcia committed
  group app_dns {

    /**
     * @desc Check that the IUT responds with a list of active DNS rules when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/DNS/PlatDnsRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_DNS_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")) & "/dns_rules",
                                                      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(
YannGarcia's avatar
YannGarcia committed
                                                                                           mw_body_json_dns_rule_list
YannGarcia's avatar
YannGarcia committed
                                                                                           )))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a DnsRuleList ***");
          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_DNS_001_OK

    /**
     * @desc Check that the IUT responds with the information on a specific DNS rule when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/DNS/PlatDnsRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_DNS_002_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")) & "/dns_rules/" & oct2char(unichar2oct(PX_DNS_RULE_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_ok(
YannGarcia's avatar
YannGarcia committed
                                                                 mw_http_message_body_json(
Yann Garcia's avatar
Yann Garcia committed
                                                                                           mw_body_json_dns_rule(
                                                                                                                 mw_dns_rule(
                                                                                                                             PX_DNS_RULE_ID
                                                                                                                             )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a DnsRule ***");
          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_DNS_002_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/DNS/PlatDnsRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_DNS_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_get(
                                                      PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/dns_rules/" & oct2char(unichar2oct(PX_NON_EXISTENT_DNS_RULE_ID, "UTF-8")),
                                                      v_headers
                                                      )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_DNS_002_NF

    /**
     * @desc Check that the IUT updates a specific DNS rule when commanded by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/DNS/PlatDnsRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_DNS_003_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
      // 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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/dns_rules/" & oct2char(unichar2oct(PX_DNS_RULE_ID, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_dns_rule(
YannGarcia's avatar
YannGarcia committed
                                                                                                     m_dns_rule(
YannGarcia's avatar
YannGarcia committed
                                                                                                                PX_DNS_RULE_ID
                                                                                )
                                                       )
                                   )
                    );
      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_dns_rule(
                                                                                                                 mw_dns_rule(
YannGarcia's avatar
YannGarcia committed
                                                                                                                             PX_DNS_RULE_ID
                                                                                                                             )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a DnsRule ***");
          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_DNS_003_OK

    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/DNS/PlatDnsRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_DNS_003_BR() 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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/dns_rules/" & oct2char(unichar2oct(PX_DNS_RULE_ID, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_dns_rule(
YannGarcia's avatar
YannGarcia committed
                                                                                                     m_dns_rule(
                                                                                                                PX_DNS_RULE_ID,
                                                                                                                -, -, -, -,
                                                                                                                PX_DNS_INVALID_STATE
                                                                                                                )
                                                                                                     )
                                                                                )
                                                       )
                                   )
                    );
      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
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
          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_DNS_003_BR

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/DNS/PlatDnsRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_DNS_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
      // 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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/dns_rules/" & oct2char(unichar2oct(PX_NON_EXISTENT_DNS_RULE_ID, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_dns_rule(
YannGarcia's avatar
YannGarcia committed
                                                                                                     m_dns_rule(
                                                                                                                PX_DNS_RULE_ID,
                                                                                                                -, -,
                                                                                                                PX_INVALID_IP_ADDRESS
                                                                                                                )
                                                                                                     )
                                                                                )
                                                       )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_DNS_003_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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/DNS/PlatDnsRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_DNS_003_PF() 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);
Yann Garcia's avatar
Yann Garcia committed
      // If-Match header needs to have an INVALID_ETAG
      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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/dns_rules/" & oct2char(unichar2oct(PX_DNS_RULE_ID, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_dns_rule(
YannGarcia's avatar
YannGarcia committed
                                                                                                     m_dns_rule(
                                                                                                                PX_DNS_RULE_ID,
                                                                                                                -, -, 
                                                                                                                PX_IP_ADDRESS 
                                                                                                                )
                                                                                                     )
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             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_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_DNS_003_PF
YannGarcia's avatar
YannGarcia committed
  } // End of group app_dns
  group liv {

    /**
     * @desc Check that the IUT responds with the liveness of a MEC service instance when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/Liveness.tplan2
     */
    testcase TC_MEC_MEC011_SRV_MSL_001_OK() 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_LINK_LIV,
                                                      v_headers
                                                      )
                                   )
                    );
      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_srv_liveness_info(
                                                                                                                          mw_service_liveness_info(
                                                                                                                                                   ACTIVE
                                                                                                                                                   )))))) {
          tc_ac.stop;
          
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ServiceLivenessInfo ***");
          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_MSL_001_OK

    /**
     * @desc 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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/Liveness.tplan2
     */
    testcase TC_MEC_MEC011_SRV_MSL_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_LINK_LIV,
                                                      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_APPSUB_002_OK

    /**
     * @desc Check that the IUT updates the liveness of a MEC service instance when requested by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/Liveness.tplan2
     */
    testcase TC_MEC_MEC011_SRV_MSL_002_OK() 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_patch(
                                                       PICS_ROOT_API & "/" & PX_LINK_LIV,
                                                       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
                                                                                                                                      )
                                                                                                              )
                                                                                )
                                                       )
                                   )
                    );
      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_srv_liveness_info(
                                                                                                                          mw_service_liveness_info(
                                                                                                                                                   ACTIVE
                                                                                                                                                   )))))) {
          tc_ac.stop;
          
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a new ServiceLivenessInfo ***");
          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_MSL_002_OK

    /**
     * @desc Check that the IUT responds with an error when incorrect parameters were sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/Liveness.tplan2
     */
    testcase TC_MEC_MEC011_SRV_MSL_002_BR() 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_patch(
                                                       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
                                                                                                                                      )
                                                                                                              )
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_400_bad_request
                                             )) {
          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_MSL_002_BR

  } // End of group liv

  /*
   * Service Availability Query (SAQ)
   */
  group saq {

    /**
     * @desc Check that the IUT responds with a list of available MEC services when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SAQ/PlatServices.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SAQ_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_MEC_SVC_MGMT_SVC_URI,
                                                      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_service_info_list
                                                                                           )))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ServiceInfoList ***");
          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_SAQ_001_OK

    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SAQ/PlatServices.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SAQ_001_BR() 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_MEC_SVC_MGMT_SVC_URI & "?instance_id=" &  oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_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_400_bad_request()
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
          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_SAQ_001_BR

    /**
     * @desc Check that the IUT responds with the information on a specific service when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SAQ/PlatServices.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SAQ_002_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_MEC_SVC_MGMT_SVC_URI & "/" & oct2char(unichar2oct(PX_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_ok(
YannGarcia's avatar
YannGarcia committed
                                                                 mw_http_message_body_json(
                                                                                           mw_body_json_service_info(
                                                                                                                     mw_service_info(
                                                                                                                                     PX_SERVICE_ID
                                                                                                                                     )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a 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_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_SAQ_002_OK

    /**
     * @desc 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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SAQ/PlatServices.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SAQ_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_get(
                                                      PICS_ROOT_API & PX_MEC_SVC_MGMT_SVC_URI & "/" & 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(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_404_not_found
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 404 Not Found ***");
          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_SAQ_002_NF

  } // End of group saq

   /*
    * Service Subscriptions (SRVSUB)
    */
YannGarcia's avatar
YannGarcia committed
  group srv_sub {

    /**
     * @desc Check that the IUT responds with a list of subscriptions for notifications on services availability when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
      var SerAvailabilityNotificationSubscription v_ser_availability_notification_subscription;

      // 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);
      f_create_ser_availability_notification_subscription(v_ser_availability_notification_subscription);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_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_delete_ser_availability_notification_subscription(v_ser_availability_notification_subscription);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_SRVSUB_001_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_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
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_NON_EXISTENT_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(
YannGarcia's avatar
YannGarcia committed
                                             mw_http_response_404_not_found
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 404 Not Found ***");
          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_SRVSUB_001_NF

    /**
     * @desc Check that the IUT acknowledges the subscription by a MEC Application to notifications on service availability events
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_002_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
YannGarcia's avatar
YannGarcia committed
      var HttpMessage v_response;

      // 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_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_srv_avail_notif_subscription(
YannGarcia's avatar
YannGarcia committed
                                                                                                                         m_srv_avail_notif_subscription(
YannGarcia's avatar
YannGarcia committed
                                                                                                                                                        PX_SRV_AVAIL_NOTIF_CALLBACK_URI
                                                                                                                                                        )
                                                                                                                         )
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_201_created(
YannGarcia's avatar
YannGarcia committed
                                                                          mw_http_message_body_json(
                                                                                                    mw_body_json_srv_avail_notif_subscription(
                                                                                                                                              mw_srv_avail_notif_subscription(
                                                                                                                                                                              PX_SRV_AVAIL_NOTIF_CALLBACK_URI
                                                                                                                                                                              )))))) -> value v_response {
          tc_ac.stop;
YannGarcia's avatar
YannGarcia committed
          
          if (f_check_headers(valueof(v_response.response.header)) == true) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a SerAvailabilityNotificationSubscription ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } else {
            log("*** " & testcasename() & ": FAIL: Header 'Location' was not present in the response headers ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
          }
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement

      // Postamble
      f_delete_ser_availability_notification_subscription(v_response.response.body.json_body.serAvailabilityNotificationSubscription);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_APPSUB_002_OK

    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_002_BR() 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_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions",
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_srv_avail_notif_subscription(
YannGarcia's avatar
YannGarcia committed
                                                                                                                         m_srv_avail_notif_subscription_invalid(
                                                                                                                                                                PX_SRV_AVAIL_NOTIF_CALLBACK_URI
                                                                                                                                                                )
                                                                                                                         )
                                                                                )
                                                       )
                                   )
                    );
      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
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
          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_002_BR

    /**
     * @desc Check that the IUT responds with the information on a specific subscription when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_003_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
      var SerAvailabilityNotificationSubscription v_ser_availability_notification_subscription;
      var charstring v_uri;

      // 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);
      f_create_ser_availability_notification_subscription(v_ser_availability_notification_subscription);
      v_uri := regexp(
                      oct2char(unichar2oct(v_ser_availability_notification_subscription.links.self_.href)),
                      "?+(" & PX_MEC_SVC_MGMT_APPS_URI & "/?*)",
                      0
                      );
      httpPort.send(
                    m_http_request(
                                   m_http_request_get(
                                                      PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & v_uri,
                                                      v_headers
                                                      )
                                   )
                    );
      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_srv_avail_notif_subscription(
                                                                                                                                    mw_srv_avail_notif_subscription(
                                                                                                                                                                      v_ser_availability_notification_subscription.callbackReference
                                                                                                                                                                    )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a SerAvailabilityNotificationSubscription ***");
          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_ser_availability_notification_subscription(v_ser_availability_notification_subscription);
      f_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_SRVSUB_003_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_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_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions/" & oct2char(unichar2oct(PX_NON_EXISTENT_SUBSCRIPTION_ID, "UTF-8")),
                                                      v_headers
                                                      )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_003_NF

    /**
     * @desc Check that the IUT acknowledges the unsubscribe from service availability event notifications when commanded by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_004_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
      var SerAvailabilityNotificationSubscription v_ser_availability_notification_subscription;
      var charstring v_uri;

      // 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);
      f_create_ser_availability_notification_subscription(v_ser_availability_notification_subscription);
      v_uri := regexp(
                      oct2char(unichar2oct(v_ser_availability_notification_subscription.links.self_.href)),
                      "?+(" & PX_MEC_SVC_MGMT_APPS_URI & "/?*)",
                      0
                      );
      httpPort.send(
                    m_http_request(
                                   m_http_request_delete(
                                                         PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & v_uri,
                                                         v_headers
                                                         )));
      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_204_no_content
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with no content ***");
          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_SRVSUB_004_OK

    /**
     * @desc 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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/SRVSUB/PlatSrvSubscriptions.tplan2
     */
    testcase TC_MEC_MEC011_SRV_SRVSUB_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
      f_init_default_headers_list(-, -, v_headers);

      httpPort.send(
                    m_http_request(
                                   m_http_request_delete(
                                                       PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_URI & "/" & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/subscriptions/" & oct2char(unichar2oct(PX_SUBSCRIPTION_ID, "UTF-8")),
YannGarcia's avatar
YannGarcia committed
                                                       v_headers
                                                       )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_SRVSUB_004_NF
YannGarcia's avatar
YannGarcia committed
  } // End of group srv_sub

   /*
    * Timing capabilities (TIME)
    */
  group timing {

    /**
     * @desc Check that the IUT responds with timing capabilities when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TIME/PlatTiming.tplan2
     */
    testcase TC_MEC_MEC011_SRV_TIME_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
      var UInt64 v_time_stamp;

      // 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_TIMING_CAPS_URI,
      v_time_stamp := f_get_current_timestamp_utc() / 1000;
      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_timing_caps(
                                                                                                                    mw_timing_caps(
                                                                                                                                   { seconds := ( v_time_stamp - 60 .. v_time_stamp + 60), nanoSeconds := ? }
                                                                                                                                   )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a TimingCaps ***");
          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_TIME_001_OK

    /**
     * @desc Check that the IUT responds with current time when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TIME/PlatTiming.tplan2
     */
    testcase TC_MEC_MEC011_SRV_TIME_002_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
YannGarcia's avatar
YannGarcia committed
      var UInt64 v_current_time;

      // 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_TIMING_CURRENT_URI,
      v_current_time := f_get_current_time_utc() / 1000;
      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_current_time(
                                                                                                                     mw_current_time(
                                                                                                                                     (v_current_time - 60 .. v_current_time + 60)
YannGarcia's avatar
YannGarcia committed
                                                                                                                                     )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a CurrentTime ***");
          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_TIME_002_OK
YannGarcia's avatar
YannGarcia committed
  } // End of group timing

   /*
    * Traffic rules (TRAF)
    */
YannGarcia's avatar
YannGarcia committed
  group traffic_rules {

    /**
     * @desc Check that the IUT responds with a list of available traffic rules when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRAF/PlatTrafficRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_TRAF_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
Yann Garcia's avatar
Yann Garcia committed
      var Headers v_headers;
      var UInt64 v_time_stamp;

      // 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")) & "/traffic_rules",
                                                      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_traffic_rule_list
                                                                                           )))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a TrafficRuleList ***");
          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_TRAF_001_OK

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRAF/PlatTrafficRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_TRAF_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
      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_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/traffic_rules",
                                                      v_headers
                                                      )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_SRVSUB_001_NF

    /**
     * @desc Check that the IUT responds with the information on a specific traffic rule when queried by a MEC Application
YannGarcia's avatar
YannGarcia committed
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRAF/TrafficRules.tplan2
    testcase TC_MEC_MEC011_SRV_TRAF_002_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")) & "/traffic_rules/" & oct2char(unichar2oct(PX_TRAFFIC_RULE_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_ok(
                                                                 mw_http_message_body_json(
YannGarcia's avatar
YannGarcia committed
                                                                                           mw_body_json_traffic_rule(
                                                                                                                     mw_traffic_rule(
                                                                                                                                     PX_TRAFFIC_RULE_ID
                                                                                                                                     )))))) {
          tc_ac.stop;
YannGarcia's avatar
YannGarcia committed
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
          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_TRAF_002_OK
YannGarcia's avatar
YannGarcia committed
     * @desc Check that the IUT updates a specific traffic rule when commanded by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRAF/TrafficRules.tplan2
    testcase TC_MEC_MEC011_SRV_TRAF_003_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(
YannGarcia's avatar
YannGarcia committed
                                   m_http_request_post(
                                                       PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/traffic_rules/" & oct2char(unichar2oct(PX_TRAFFIC_RULE_ID, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
YannGarcia's avatar
YannGarcia committed
                                                                                m_body_json_traffic_rule(
                                                                                                         m_traffic_rule(
                                                                                                                        PX_TRAFFIC_RULE_ID,
                                                                                                                        -,
                                                                                                                        -,
                                                                                                                        -,
                                                                                                                        DROP
                                                                                                                        )
                                                                                                         )
                                                                                )
                                                       )
                                   )
                    );
      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(
YannGarcia's avatar
YannGarcia committed
                                                                                           mw_body_json_traffic_rule(
                                                                                                                     mw_traffic_rule(
                                                                                                                                     PX_TRAFFIC_RULE_ID
                                                                                                                                     )))))) {
          tc_ac.stop;
YannGarcia's avatar
YannGarcia committed
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
          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_TRAF_003_OK
    /**
     * @desc Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRAF/PlatTrafficRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_TRAF_003_BR() 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
      // do a GET first to have the value
      f_init_default_headers_list(-, -, v_headers);

      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
                                                      PICS_ROOT_API & PX_ME_APP_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/traffic_rules/" & oct2char(unichar2oct(PX_TRAFFIC_RULE_ID, "UTF-8")),
                                                       v_headers,
                                                       m_http_message_body_json(
YannGarcia's avatar
YannGarcia committed
                                                                                m_body_json_traffic_rule(
                                                                                                         m_traffic_rule(
                                                                                                                        PX_NON_EXISTENT_TRAFFIC_RULE_ID
                                                                                                                        )
                                                                                                    )
                                                                                )
                                                       )
                                   )
                    );
      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
                                             )) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
          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_TRAF_003_BR

    /**
     * @desc Check that the IUT responds with an error when a request for an unknown URI is sent by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRAF/PlatTrafficRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_TRAF_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
      // 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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/traffic_rules/" & oct2char(unichar2oct(PX_NON_EXISTENT_TRAFFIC_RULE_ID, "UTF-8")),
YannGarcia's avatar
YannGarcia committed
                                                      v_headers,
                                                      m_http_message_body_json(
                                                                               m_body_json_traffic_rule(
                                                                                                        m_traffic_rule(
                                                                                                                       PX_TRAFFIC_RULE_ID,
                                                                                                                       -, -, -,
                                                                                                                       DROP
                                                                                                                       )
                                                                                                        )
                                                                               )
                                                      )
                                   )
                    );
      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 a ProblemDetails set to 404 Not Found ***");
          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_TRAF_003_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
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRAF/PlatTrafficRules.tplan2
     */
    testcase TC_MEC_MEC011_SRV_TRAF_003_PF() 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);
Yann Garcia's avatar
Yann Garcia committed
      // If-Match header needs to have an INVALID_ETAG
      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_SUPPORT_URI & "/" & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/traffic_rules/" & oct2char(unichar2oct(PX_NON_EXISTENT_TRAFFIC_RULE_ID, "UTF-8")),
YannGarcia's avatar
YannGarcia committed
                                                      v_headers,
                                                      m_http_message_body_json(
                                                                               m_body_json_traffic_rule(
                                                                                                        m_traffic_rule(
                                                                                                                       PX_TRAFFIC_RULE_ID,
                                                                                                                       -, -, -,
                                                                                                                       DROP
                                                                                                                       )
                                                                                                        )
                                                                                )
                                                       )
                                   )
                    );
      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_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_TRAF_003_PF
YannGarcia's avatar
YannGarcia committed
  } // End of group traffic_rules

   /*
    * Transport (TRANS)
    */
YannGarcia's avatar
YannGarcia committed
  group transport_rules {
YannGarcia's avatar
YannGarcia committed
     * @desc Check that the IUT responds with a list of available transports when queried by a MEC Application
     * @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/TRANS/PlatTransport.tplan2
    testcase TC_MEC_MEC011_SRV_TRANS_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_SVC_MGMT_TRANS_URI,
                                                      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_transport_info_list
                                                                                           )))) {
          tc_ac.stop;
YannGarcia's avatar
YannGarcia committed
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a UeIdentityTag ***");
          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_cf_01_http_down();
    } // End of testcase TC_MEC_MEC011_SRV_TRANS_001_OK
YannGarcia's avatar
YannGarcia committed
  } // End of group transport_rules
YannGarcia's avatar
YannGarcia committed
} // End of module AtsMec_AppEnablementAPI_TestCases