AtsMec_AppLifecycleManagement_TestCases.ttcn 58.6 KB
Newer Older
Elian Kraja's avatar
Elian Kraja committed
/**
*    @author   ETSI / STF569
*    @version  $URL:$
*              $ID:$
*    @desc     This module provides the MEC test cases.
*    @copyright   ETSI Copyright Notification
*                 No part may be reproduced except as authorized by written permission.
*                 The copyright and the foregoing restriction extend to reproduction in all media.
*                 All rights reserved.
*    @see      ETSI GS MEC 003, Draft ETSI GS MEC 010-2 V2.1.1
Elian Kraja's avatar
Elian Kraja committed
*/
module AtsMec_AppLifecycleManagement_TestCases {
Elian Kraja's avatar
Elian Kraja committed

  // Libcommon
  import from LibCommon_Sync all;
Elian Kraja's avatar
Elian Kraja committed

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

  // 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 App_lifecycle_management {
Elian Kraja's avatar
Elian Kraja committed
    
    /**
     * @desc: Check that MEC API provider creates a new App Package when requested
     *        ETSI GS MEC 010-2 2.0.10, clause 7.5.1.3.1
     *        ETSI GS MEC 010-2 2.0.10, Table 6.2.2.3.2-1      //CreateAppInstanceRequest
     *		 ETSI GS MEC 010-2 2.0.10, Table 6.2.2.4.2-1      //AppInstanceInfo
     */
    testcase TC_MEC_MEC010p2_MEX_LCM_001_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI,
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management(
                                   m_lifecycle_management_create(
                                       PX_APP_D_ID
                                   )
                             )
                        )
                  )
            ));
                
        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_mex_lcm_instance_info(
    									mw_lcm_instance_info(
    										-,
    										PX_APP_D_ID,
    										PX_INSTANTIATION_STATE
    									)
          ))))) -> value v_response {
          tc_ac.stop;
          log("*** " & testcasename() & ": PASS: IUT successfully responds with the App LCM Instance info details ***");
          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_MEX_LCM_001_OK
Elian Kraja's avatar
Elian Kraja committed
 
 
 
    /**
    * @desc: Check that MEC API provider sends an error when it receives  
    *      	 a malformed request for the creation of a new App Instance
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.1.3.1
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.2.3.2-1      //CreateAppInstanceRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_001_BR() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI,
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_with_error(
                                   m_lifecycle_management_create_with_error(
                                       PX_APP_D_ID
                                   )
                             )
                        )
                )));
        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;
          
          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_MEX_LCM_001_BR 
Elian Kraja's avatar
Elian Kraja committed



    /**
    * @desc: Check that MEC API provider retrieves the list of App instances when requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.1.3.2
    *		 ETSI GS MEC 010-2 2.0.10, Table 6.2.3.3.2-1      //AppInstanceInfo
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_002_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_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_mex_lcm_instance_info_list({
                             *,
                             mw_lcm_instance_info(
                             	PX_APP_INSTANCE_ID,
                             	-, -
                             ),
                             * 
                            }
          					)
          				)
                	)
          )) -> value v_response {
          tc_ac.stop;
          log("*** " & testcasename() & ": PASS: IUT successfully responds with an App LCM instance info and 200 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_MEX_LCM_002_OK
Elian Kraja's avatar
Elian Kraja committed


    /**
    * @desc: Check that MEC API provider retrieves an App Package when requested
    * @see:  ETSI GS MEC 010-2 2.0.10, clause 7.5.2.3.2
	*		 ETSI GS MEC 010-2 2.0.10, Table 6.2.2.4.2-1
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_003_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_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_ok(
	                    mw_http_message_body_json(
                            mw_body_json_mex_lcm_instance_info(
								mw_lcm_instance_info(
									PX_APP_INSTANCE_ID, 
									-, 
									-
								)
          ))))) -> value v_response {
          tc_ac.stop;
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a App instance info ***");
          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_MEX_LCM_003_OK
Elian Kraja's avatar
Elian Kraja committed





	/**
    * @desc: Check that MEC API provider fails on retrieving an App Instance when requested using wrong appInstanceId
    * @see:  ETSI GS MEC 010-2 2.0.10, clause 7.5.2.3.2
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_003_NF() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) &"/app_descriptor",
                        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(
            ))) -> value v_response {
          tc_ac.stop;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 404 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_MEX_LCM_003_NF
Elian Kraja's avatar
Elian Kraja committed


    /**
    * @desc: Check that MEC API provider service deletes an App Instance when requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.2.3.4
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_004_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_delete(
                    "/" & PICS_ROOT_API & PX_MEX_LCM_URI & oct2char(unichar2oct(PX_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_204_no_content(
		    ))) -> value v_response {
          tc_ac.stop;
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 204 no content 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_MEX_LCM_004_OK
Elian Kraja's avatar
Elian Kraja committed

	/**
    * @desc: Check that MEC API provider fails on deletion of an App Instance when requested using wrong appInstanceId
    * @see:  ETSI GS MEC 010-2 2.0.10, clause 7.5.2.3.2
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_004_NF() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_delete(
                    "/" & PICS_ROOT_API & PX_MEX_LCM_URI & 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_404_not_found(
            ))) -> value v_response {
          tc_ac.stop;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 404 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_MEX_LCM_004_NF
Elian Kraja's avatar
Elian Kraja committed
    
    
    /**
    * @desc: Check that MEC API provider service instantiates an App Instance when requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.6.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.7.2-1   //InstantiateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_005_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/instantiate",
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_instantiate(
                                   m_lifecycle_management_instantiate(
                                       PX_APP_D_ID
                                   )
                             )
                        )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_202_accepted(
		    ))) -> value v_response {
          tc_ac.stop;
    	  if (f_check_headers(v_response.response.header) == true) {
        	log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted***");
        	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
    } // End of testcase TC_MEC_MEC010p2_MEX_LCM_005_OK
Elian Kraja's avatar
Elian Kraja committed
    
    
	/**
    * @desc: Check that MEC API providerservice fails to instantiate an App Instance when 
	*		 it receives a request related to a not existing App Instance
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.6.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.7.2-1   //InstantiateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_005_NF() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/instantiate",
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_instantiate(
                                   m_lifecycle_management_instantiate(
                                       PX_APP_D_ID
                                   )
                             )
                        )
                )));
        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;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 404 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_MEX_LCM_005_NF
Elian Kraja's avatar
Elian Kraja committed
    

	/**
    * @desc: Check that MEC API provider service fails to instantiate an App Instance when it receives a malformed request
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.6.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.7.2-1   //InstantiateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_005_BR() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/instantiate",
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_instantiate_with_error(
                                   m_lifecycle_management_instantiate_with_error(
                                       PX_APP_D_ID
                                   )
                             )
                        )
                )));
        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;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 400 bad request 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_MEX_LCM_005_BR
Elian Kraja's avatar
Elian Kraja committed
    
    
    /**
    * @desc: Check that MEC API provider service terminates an App Instance when requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.7.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.9.2-1 	//TerminateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_006_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/terminate",
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_terminate(
                                   m_lifecycle_management_terminate(
                                       PX_APP_TERMINATION_TYPE
                                   )
                             )
                        )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_202_accepted(
		    ))) -> value v_response {
          tc_ac.stop;
    	  if (f_check_headers(v_response.response.header) == true) {
        	log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted***");
        	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
    } // End of testcase TC_MEC_MEC010p2_MEX_LCM_006_OK
Elian Kraja's avatar
Elian Kraja committed
    
    
	/**
    * @desc: Check that MEC API providerservice fails to terminate an App Instance when 
	*		 it receives a request related to a not existing App Instance
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.7.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.9.2-1	//TerminateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_006_NF() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/terminate",
                        v_headers,
                        m_http_message_body_json(
                        	m_body_json_lifecycle_management_terminate(
                                   m_lifecycle_management_terminate(
                                       PX_APP_TERMINATION_TYPE
                                   )
                             )
                        )
                )));
        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;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 404 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_MEX_LCM_006_NF
Elian Kraja's avatar
Elian Kraja committed
    

	/**
    * @desc: Check that MEC API providerservice fails to terminate an App Instance when it receives a malformed request
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.7.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.9.2-1 	//TerminateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_006_BR() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/terminate",
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_terminate_with_error(
                                   m_lifecycle_management_terminate_with_error(
                                       PX_APP_TERMINATION_TYPE_WITH_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;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 400 Bad Request 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_MEX_LCM_006_BR
Elian Kraja's avatar
Elian Kraja committed
    
    
    /**
    * @desc: Check that MEC API provider service terminates an App Instance when requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.8.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.8.2-1 	//OperateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_007_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/operate",
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_operate(
                                   m_lifecycle_management_operate(
                                       PX_CHANGE_STATE_TO
                                   )
                             )
                        )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_202_accepted(
		    ))) -> value v_response {
          tc_ac.stop;
    	  if (f_check_headers(v_response.response.header) == true) {
        	log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted***");
        	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
    } // End of testcase TC_MEC_MEC010p2_MEX_LCM_007_OK
Elian Kraja's avatar
Elian Kraja committed
    
    
	/**
    * @desc: Check that MEC API provider service fails to change the status of an App Instance 
	*		 when it receives a request related to a not existing App Instance
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.8.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.8.2-1 	//OperateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_007_NF() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_NON_EXISTENT_APP_INSTANCE_ID, "UTF-8")) & "/operate",
                        v_headers,
                        m_http_message_body_json(
                        	m_body_json_lifecycle_management_operate(
                                   m_lifecycle_management_operate(
                                       PX_CHANGE_STATE_TO
                                   )
                             )
                        )
                )));
        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;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 404 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_MEX_LCM_007_NF
Elian Kraja's avatar
Elian Kraja committed
    

	/**
    * @desc: Check that MEC API provider service fails to operate on an App Instance when it receives a malformed request
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.8.3.1
	*		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.8.2-1 	//OperateAppRequest
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_007_BR() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_URI & oct2char(unichar2oct(PX_APP_INSTANCE_ID, "UTF-8")) & "/operate",
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_lifecycle_management_operate_with_error(
                                   m_lifecycle_management_operate_with_error(
                                       PX_CHANGE_STATE_TO_WITH_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;
          
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 400 Bad Request 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_MEX_LCM_007_BR
Elian Kraja's avatar
Elian Kraja committed



    /**
    * @desc: Check that MEC API provider service retrieves info about LCM Operation Occurrency on App Instances when requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.5.9.3.2
    *		 ETSI GS MEC 010-2 2.0.10, table 6.2.2.14.2-1" 	//AppLcmOpOcc 
    */
    testcase TC_MEC_MEC010p2_MEX_LCM_008_OK() runs on HttpComponent system HttpTestAdapter {
Elian Kraja's avatar
Elian Kraja committed
        // Local variables
Yann Garcia's avatar
Yann Garcia committed
        var Headers v_headers;
Elian Kraja's avatar
Elian Kraja committed
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_LCM_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_LCM_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_MEX_LCM_OP_OCC_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_lifecycle_op_occ_list({
                             *,
                             mw_lifecycle_management_op_occ(
                             	PX_APP_LCM_OP_OCC_ID
                             ),
                             * 
                            }