AtsMec_MeoPkgm_TestCases.ttcn 43.7 KB
Newer Older
Elian Kraja's avatar
Elian Kraja committed
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_ok(
                        mw_http_message_body_json(
                            mw_body_json_pkgm_subscription_info(
                            	mw_app_package_subscription_info(
    								PX_SUBSCRIPTION_ID,
    								PX_SUBSCRIPTION_TYPE,
    								PX_CALLBACK_URI
    								)
          ))))) -> value v_response {
          tc_ac.stop;
          
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a App Package Subscription Info identified by the given ID ***");
          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_MEO_PKGM_009_OK


 	/**
    * @desc: Check that MEO service sends an error when it receives a query 
	*		 for a subscription on AppPackages with a wrong identifier
    *        ETSI GS MEC 010-2 2.0.10, clause 7.3.4.3.2
    */
    testcase TP_MEC_MEO_PKGM_009_NF() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_PACKAGE_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_PACKAGE_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_PKGM_SUBS & "/" & 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(
		  ))) -> value v_response {
          tc_ac.stop;
          
          log("*** " & testcasename() & ": PASS: IUT successfully responds with 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
    } // End of testcase TP_MEC_MEO_PKGM_009_NF
      
 	 	/**
    * @desc: Check that MEO service deletes an Application Package Subscription when requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.3.4.3.4
    */
    testcase TP_MEC_MEO_PKGM_010_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_PACKAGE_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_PACKAGE_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_MEO_PKGM_SUBS & "/" & 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(
          ))) -> value v_response {
          tc_ac.stop;
          
          log("*** " & testcasename() & ": PASS: IUT successfully responds 204 No Content removing the AppPkgSubscription identified by the given ID ***");
          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_MEO_PKGM_010_OK


 	/**
    * @desc: Check that MEO service sends an error when it receives a deletion 
    *     request for a subscription on AppPackages with a wrong identifier
    *        ETSI GS MEC 010-2 2.0.10, clause 7.3.4.3.4
    */
    testcase TP_MEC_MEO_PKGM_010_NF() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_APP_PACKAGE_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_APP_PACKAGE_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_MEO_PKGM_SUBS & "/" & 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(
		  ))) -> value v_response {
          tc_ac.stop;
          
          log("*** " & testcasename() & ": PASS: IUT successfully responds with 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
    } // End of testcase TP_MEC_MEO_PKGM_010_NF
            
} // end of group pkg_mgmt_subscriptions

group pkg_management_notification {
  
     /**
     * @desc Check that the MEO service sends a application package notification
     *       if the MEO service has an associated subscription and the event is generated
     * @see  ETSI GS MEC 010-2 2.0.10, clause 7.3.5.1
     */  
  testcase TP_MEC_MEO_PKGM_011_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        
        // Test control
        if (not(PIC_APP_PACKAGE_NOTIFICATIONS)) {
            log("*** " & testcasename() & ": PIC_APP_PACKAGE_NOTIFICATIONS required for executing the TC ***");
            setverdict(inconc);
            stop;
        }
        
        // Test component configuration
        f_cf_01_http_notif_up();
        
        // Test adapter configuration
        
        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        action("Trigger a expire notification event");
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);
        
        // Test Body
        tc_wait.start;
        alt {
          [] httpPort_notif.receive(
          		mw_http_request(
                	mw_http_request_post(
						unichar2char(PX_CALLBACK_URI),
                        -,
                    	mw_http_message_body_json(
                        	mw_body_json_app_package_notification(
								mw_app_package_notification(
									-, 
									PX_NOTIFICATION_TYPE,
									PX_SUBSCRIPTION_ID,
									PX_CALLBACK_URI)
                            )
                        )
                    )
                )
            ) {
            tc_wait.stop;
            log("*** " & testcasename() & ": INFO: IUT successfully sends notification ***");
            
            // Send 204 No Content
            httpPort_notif.send(m_http_response(m_http_response_204_no_content(v_headers)));
            
            log("*** " & testcasename() & ": PASS: IUT successfully sends notification ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          }
          [] tc_wait.timeout {
            log("*** " & testcasename() & ": INCONC: Expected message not received ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
          }
        } // End of 'alt' statement
        
        // Postamble
        f_cf_01_http_notif_down();
    } 
  
  
} // end of group pkg_management_notification


} // End of module AtsMec_PkgMgmt_mm1_TestCases