Commit 96deb314 authored by YannGarcia's avatar YannGarcia
Browse files

Start implementing MEC-10-2 V2.2.1

parent dcb5cc73
Loading
Loading
Loading
Loading
+0 −1622

File deleted.

Preview size limit exceeded, changes collapsed.

+1119 −0

File added.

Preview size limit exceeded, changes collapsed.

+0 −397
Original line number Diff line number Diff line
/**
*    @Author   ETSI / STF569
*    @version  $URL:$
*              $ID:$
*    @desc     This module provides the MEC test cases.
*    @copyright   ETSI Copyright Notification
*                 No part may be reproduced except as authorized by written permission.
*                 The copyright and the foregoing restriction extend to reproduction in all media.
*                 All rights reserved.
*    @see      ETSI GS MEC 003, Draft ETSI GS MEC 010-2 V2.1.1
*/
module AtsMec_Granting_TestCases {

  // 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
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.1,
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.2.2-1,      //GrantRequest
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.4.2-1       //Grant
    */
    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_OPERATION
                                   )
                            )
                  )
                        
                )));
        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_response(
                                    PX_APP_INSTANCE_ID
                                )
          ))))) -> value v_response {
          tc_ac.stop;
          
          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
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.1,
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.2.2-1,      //GrantRequest
    */
    testcase TC_MEC_MEC010p2_MEO_GRANT_001_BR() 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_with_error(
                                   m_grant_request_with_error(
                                        PX_APP_INSTANCE_ID,
                                        PX_APP_OPERATION_ERROR
                                   )
                            )
                  )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_400_bad_request(
            ))) -> value v_response {
          tc_ac.stop;
          
          if (v_response.response.statuscode == 400) {
            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 asynchronous grant response when a grant request is requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.1,
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.2.2-1,      //GrantRequest
    */
    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_OPERATION
                                   )
                            )
                  )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
          //@TODO: Need to add 202 accepted to the library      
                    mw_http_response_202_accepted()
		  )) -> value v_response {
          tc_ac.stop;
          //@TODO: How to check Location???
          if (v_response.response.statuscode == 202) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted status 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
    } // End of testcase TC_MEC_MEC010p2_MEO_GRANT_002_OK


    /**
    * @desc: Check that MEO sends the status of a grant request when a query on a granting ID is performed
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.2,
    */
    testcase TC_MEC_MEC010p2_MEO_GRANT_003_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_get(
                    PICS_ROOT_API & PX_MEO_GRANT_URI & oct2char(unichar2oct(PX_GRANTING_ID, "UTF-8")),
                        v_headers
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
          //@TODO: Need to add 202 accepted to the library      
                    mw_http_response_202_accepted()
          )) -> value v_response {
          tc_ac.stop;
          //@TODO: How to check Location???
          if (v_response.response.statuscode == 201) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted status 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
    } // End of testcase TC_MEC_MEC010p2_MEO_GRANT_003_OK


    /**
    * @desc: Check that MEO responds with an error when it receives a request for returning a grant referred with a wrong ID
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.2
    */
    testcase TC_MEC_MEC010p2_MEO_GRANT_003_NF() 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_get(
                    PICS_ROOT_API & PX_MEO_GRANT_URI & oct2char(unichar2oct(PX_NON_EXISTANT_GRANTING_ID, "UTF-8")),
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_grant_request(
                                   m_grant_request(
                                        PX_APP_INSTANCE_ID,
                                        PX_APP_OPERATION
                                   )
                            )
                  )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_404_not_found(
            ))) -> value v_response {
          tc_ac.stop;
          
          if (v_response.response.statuscode == 404) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a not found status 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
    } // End of testcase TC_MEC_MEC010p2_MEO_GRANT_003_NF  


    /**
    * @desc: Check that MEO sends the status of a grant request when a query on a granting ID is performed
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.2
    *	     ETSI GS MEC 010-2 2.0.10, Table 6.2.4.4.2-1 //Grant
    */
    testcase TC_MEC_MEC010p2_MEO_GRANT_004_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_get(
                    PICS_ROOT_API & PX_MEO_GRANT_URI & oct2char(unichar2oct(PX_GRANTING_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(
                            mw_body_json_grant_response(
                                mw_grant_response(
                                    PX_APP_INSTANCE_ID
                                )
          ))))) -> value v_response {
          tc_ac.stop;
          //@TODO: How to check Location???
          if (v_response.response.statuscode == 200) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted status 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
    } // End of testcase TC_MEC_MEC010p2_MEO_GRANT_004_OK

}


  
} 
+0 −1260

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −937

File deleted.

Preview size limit exceeded, changes collapsed.

Loading