AtsMec_AppEnablementAPI_TestCases.ttcn 137 KB
Newer Older

      // 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(
YannGarcia's avatar
YannGarcia committed
                                                       "/" & 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(
                                                                                                                 m_srv_avail_notif_subscription(
                                                                                                                                PX_SRV_AVAIL_NOTIF_SUBSCRIPTION, //subscriptionType
                                                                                                                                PX_SRV_AVAIL_NOTIF_CALLBACK_URI // callbackReference
                                                                                                                               )
                                                                                                                 )
                                                                                )
                                                       )
                                   )
                    );
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
      tc_ac.start;
      alt {
        [] httpPort.receive(
                            mw_http_response(
                                             mw_http_response_201_created(
                                                                 mw_http_message_body_json(
                                                                                mw_body_json_srv_avail_notif_subscription(
                                                                                                                 mw_srv_avail_notif_subscription(
                                                                                                                                PX_SRV_AVAIL_NOTIF_SUBSCRIPTION, //subscriptionType
                                                                                                                                PX_SRV_AVAIL_NOTIF_CALLBACK_URI // callbackReference
                                                                                                                               )
                                                                                                                 )
                                                                                                                                                     )))) {
          // TODO Need to check Location header

          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_cf_01_http_down();
    } // End of testcase TP_MEC_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 TP_MEC_SRV_SRVSUB_002_BR() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                       "/" & 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(
                                                                                                                 m_srv_avail_notif_subscription(
                                                                                                                                PX_INVALID_SUBSCRIPTION, //subscriptionType
                                                                                                                                PX_SRV_AVAIL_NOTIF_CALLBACK_URI // callbackReference
                                                                                                                               )
                                                                                                                 )
                                                                                )
                                                       )
                                   )
                    );
      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 TP_MEC_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 TP_MEC_SRV_SRVSUB_003_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                       "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_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(
                                                                                m_body_json_srv_avail_notif_subscription(
                                                                                                                 m_srv_avail_notif_subscription(
                                                                                                                                PX_SRV_AVAIL_NOTIF_SUBSCRIPTION //subscriptionType
                                                                                                                               )
                                                                                                                 )
                                                                                                                  )))) {
          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_cf_01_http_down();
    } // End of testcase TP_MEC_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 TP_MEC_SRV_SRVSUB_003_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                       "/" & 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(
                                             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 TP_MEC_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 TP_MEC_SRV_SRVSUB_004_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                       "/" & PICS_ROOT_API & PX_MEC_SVC_MGMT_APPS_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_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 TP_MEC_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 TP_MEC_SRV_SRVSUB_004_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                       "/" & 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")),
                                                       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 TP_MEC_SRV_SRVSUB_004_NF

  } // End of group appSub



   /*
    * 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 TP_MEC_SRV_TIME_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
                                                      PX_ME_APP_SUPPORT_TIMING_CAPS_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_body_json_timing_caps(
                                                                                                mw_timing_caps(*) // TODO don't care about the content
YannGarcia's avatar
YannGarcia committed
                                                                                                                  )))) {
          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 TP_MEC_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 TP_MEC_SRV_TIME_002_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & PICS_ROOT_API & PX_ME_APP_SUPPORT_TIMING_CURRENT_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_body_json_current_time(
                                                                                                mw_current_time(*) // TODO don't care about the content
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 TP_MEC_SRV_TIME_002_OK

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

   /*
    * Traffic rules (TRAF)
    */
  group trafficRules {

    /**
     * @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 TP_MEC_SRV_TRAF_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & 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(
                                                                 mw_body_json_traffic_rule_list(
                                                                                                mw_traffic_rule_list(*) // TODO don't care about the content
YannGarcia's avatar
YannGarcia committed
                                                                                                                  )))) {
          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 TP_MEC_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 TP_MEC_SRV_TRAF_001_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & 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(
                                             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 TP_MEC_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
YannGarcia's avatar
YannGarcia committed
    testcase TC_MEC_SRV_TRAF_002_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & PICS_ROOT_API & PX_SVC_MGMT_APP_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();
YannGarcia's avatar
YannGarcia committed
    } // End of testcase TC_MEC_SRV_TRAF_002_OK
    
   /**
     * @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
YannGarcia's avatar
YannGarcia committed
    testcase TC_MEC_SRV_TRAF_003_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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_SVC_MGMT_APP_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();
YannGarcia's avatar
YannGarcia committed
    } // End of testcase TC_MEC_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 TP_MEC_SRV_TRAF_003_BR() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & 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(
                                                                                m_body_traffic_rule(
                                                                                                                 m_traffic_rule(
                                                                                                                                PX_TRF_RULE_INVALID // action
                                                                                                                               )
                                                                                                                 )
                                                                                )
                                                       )
                                   )
                    );
      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 TP_MEC_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 TP_MEC_SRV_TRAF_003_NF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & 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")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_traffic_rule(
                                                                                                                 m_traffic_rule(
                                                                                                                                PX_TRF_RULE_DROP // action
                                                                                                                               )
                                                                                                                 )
                                                                                )
                                                       )
                                   )
                    );
      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 TP_MEC_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/TRAF/PlatTrafficRules.tplan2
     */
    testcase TP_MEC_SRV_TRAF_003_PF() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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 an INVALID_ETAG
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_put(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & 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")),
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_traffic_rule(
                                                                                                                 m_traffic_rule(
                                                                                                                                PX_TRF_RULE_DROP // action
                                                                                                                               )
                                                                                                                 )
                                                                                )
                                                       )
                                   )
                    );
      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 TP_MEC_SRV_TRAF_003_PF
  } // End of group trafficRules

   /*
    * Transport (TRANS)
    */
  group transportRules {
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
YannGarcia's avatar
YannGarcia committed
    testcase TC_MEC_SRV_TRANS_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines 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(
YannGarcia's avatar
YannGarcia committed
                                                      "/" & 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();
YannGarcia's avatar
YannGarcia committed
    } // End of testcase TC_MEC_SRV_TRANS_001_OK
YannGarcia's avatar
YannGarcia committed
  } // End of group transportRules

} // End of module AtsMec_AppEnablementAPI_TestCases