AtsMec_EdgePlatformApplicationEnablementAPI_TestCases.ttcn 170 KB
Newer Older
                            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