Skip to content
AtsMec_AppLCM_TestCases.ttcn 57.9 KiB
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 013 V2.0.3 (2018-10)
*/
module AtsMec_AppLCM_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;
    

    import from AppLCM_Templates all;
    import from AppLCM_Pics all;
    import from AppLCM_Pixits all;
    
    // LibMec
    import from LibMec_Functions all;
    import from LibMec_Pics all;
    import from LibMec_Pixits all;
    
    group App_lifecycle_management {
  
    /**
    * @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 TP_MEC_MEX_LCM_001_OK() runs on HttpComponent system HttpTestAdapter {
        // 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 TP_MEC_MEX_LCM_001_OK
 
 
 
    /**
    * @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 TP_MEC_MEX_LCM_001_BR() runs on HttpComponent system HttpTestAdapter {
        // 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 TP_MEC_MEX_LCM_001_BR 



    /**
    * @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 TP_MEC_MEX_LCM_002_OK() runs on HttpComponent system HttpTestAdapter {
        // 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(
Loading
Loading full blame…