Skip to content
AtsMec_ApplicationPackageLifecycleAndOperationGrantingAPI_TestCases.ttcn 76.4 KiB
Newer Older
/**
*    @Author   ETSI / STF569 / TTF012
*    @version  $URL:$
*              $ID:$
*    @desc     This module provides the MEC test cases.
*    @copyright   ETSI Copyright Notification
*                 No part may be reproduced except as authorized by written permission.
*                 The copyright and the foregoing restriction extend to reproduction in all media.
*                 All rights reserved.
*    @see      ETSI GS MEC 003, Draft ETSI GS MEC 010-2 V2.2.1
*/
module AtsMec_ApplicationPackageLifecycleAndOperationGrantingAPI_TestCases {

  // JSON
  import from JSON all;

  // Libcommon
  import from LibCommon_Sync all;

  // LibHttp
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_Functions all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_JsonTemplates all;
  import from LibItsHttp_TestSystem all;

  // LibMec_ApplicationPackageLifecycleAndOperationGrantingAPI
  import from ApplicationPackageLifecycleAndOperationGrantingAPI_Templates all;
  import from ApplicationPackageLifecycleAndOperationGrantingAPI_Pics all;
  import from ApplicationPackageLifecycleAndOperationGrantingAPI_Pixits all;

  // LibMec
  import from LibMec_Functions all;
  import from LibMec_Pics all;
  import from LibMec_Pixits all;

  group grant {
    
    /**
     * @desc Check that MEO sends a synchronous grant response when a grant request is requested - INSTANTIATE
     */
    testcase TC_MEC_MEC010p2_MEO_GRANT_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var Headers v_headers;
      var HttpMessage v_response;

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

      // Test component configuration
      f_cf_01_http_up();

      // Preamble
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                       PICS_ROOT_API & PX_MEO_GRANT_URI,
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_grant_request(
                                                                                                          m_grant_request(
                                                                                                                          PX_APP_INSTANCE_ID,
                                                                                                                          PX_APP_LCM_OP_OCC_ID,
                                                                                                                          PX_APP_ID,
                                                                                                                          INSTANTIATE,
                                                                                                                          m_grant_request_link(
                                                                                                                                               m_link_type(""), // TODO
                                                                                                                                               m_link_type("")  // TODO
                    )))))));
        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_grant_response(
                                                                                                                                    mw_grant
                                ))))) -> value v_response {
          tc_ac.stop;
          
          if (f_check_headers(valueof(v_response.response.header)) == false) {
            log("*** " & testcasename() & ": FAIL: Header 'Location' was not present in the response headers ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_error);
          } else {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a Grant Response ***");
            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
    } // End of testcase TC_MEC_MEC010p2_MEO_GRANT_001_OK

    /**
     * @desc Check that MEO responds with an error when it receives a malformed request when a new grant request is performed
     */
    testcase TC_MEC_MEC010p2_MEO_GRANT_001_BR() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var Headers v_headers;

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

      // Test component configuration
      f_cf_01_http_up();

      // Preamble
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                       PICS_ROOT_API & PX_MEO_GRANT_URI,
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_grant_request(
                                                                                                          m_grant_request(
                                                                                                                          PX_APP_INSTANCE_ID,
                                                                                                                          PX_APP_LCM_OP_OCC_ID,
                                                                                                                          PX_APP_ID,
                                                                                                                          INVALID_OPERATE,
                                                                                                                          m_grant_request_link(
                                                                                                                                               m_link_type(""), // TODO
                                                                                                                                               m_link_type("")  // TODO
                    )))))));
        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 Bad response ***");
          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
    } // End of testcase TC_MEC_MEC010p2_MEO_GRANT_001_BR  

    /**
     * @desc Check that MEO sends a synchronous grant response when a grant request is requested
     */
    testcase TC_MEC_MEC010p2_MEO_GRANT_002_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var Headers v_headers;
      var HttpMessage v_response;

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

      // Test component configuration
      f_cf_01_http_up();

      // Preamble
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
                    m_http_request(
                                   m_http_request_post(
                                                       PICS_ROOT_API & PX_MEO_GRANT_URI,
                                                       v_headers,
                                                       m_http_message_body_json(
                                                                                m_body_json_grant_request(
                                                                                                          m_grant_request(
                                                                                                                          PX_APP_INSTANCE_ID,
                                                                                                                          PX_APP_LCM_OP_OCC_ID,
                                                                                                                          PX_APP_ID,
                                                                                                                          PX_APP_OPERATION,
                                                                                                                          m_grant_request_link(
                                                                                                                                               m_link_type(""), // TODO
                                                                                                                                               m_link_type("")  // TODO
                    )))))));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
Loading full blame...