Commit 33239901 authored by Elian Kraja's avatar Elian Kraja
Browse files

Adding TPs for Granting operations. Fixing AMS TPs

parent d55aa377
Loading
Loading
Loading
Loading
+1060 −1

File changed.

Preview size limit exceeded, changes collapsed.

+399 −0
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 013 V2.0.3 (2018-10)
*/
module AtsMec_Grant_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_LocationAPI
import from Grant_Templates all;
import from Grant_Pics all;
import from Grant_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 TP_MEC_MEO_GRANT_001_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines 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_ok(
                        mw_http_message_body_json(
                            mw_body_json_grant_response(
                                mw_grant_response(
                                    PX_APP_INSTANCE_ID
                                )
          ))))) -> value v_response {
          tc_ac.stop;
          
          if (v_response.response.statuscode == 201) {
            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 TP_MEC_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 TP_MEC_MEO_GRANT_001_BR() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines 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 TP_MEC_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 TP_MEC_MEO_GRANT_002_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines 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 TP_MEC_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 TP_MEC_MEO_GRANT_003_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines 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 TP_MEC_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 TP_MEC_MEO_GRANT_003_NF() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines 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 TP_MEC_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 TP_MEC_MEO_GRANT_004_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines 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 TP_MEC_MEO_GRANT_004_OK

}


  
} 
+3 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ module Ams_Pixits {
  
  modulepar JSON.String PX_APP_INS_ID := "5abe4782-2c70-4e47-9a4e-0ee3a1a0fd1f"
  
  modulepar JSON.String PX_SUBSCRIPTION_TYPE := "MobilityProcedureSubscription"
  modulepar SubscriptionType PX_SUBSCRIPTION_TYPE := MobilityProcedureSubscription
  
  modulepar JSON.String PX_SUBSCRIPTION_ID := "e0deee2b-6e50-4f33-ab09-8bf0585025d3"
  
@@ -18,6 +18,8 @@ module Ams_Pixits {
  
  modulepar JSON.String PX_CALLBACK_REFERENCE :=	"http://127.0.0.1/callback"
  
  modulepar charstring PX_CALLBACK_URI := "http://127.0.0.1/callback"
   
  modulepar JSON.String PX_MEP_ID := "";
  
} // End of module LocationAPI_Pixits 
+83 −161

File changed.

Preview size limit exceeded, changes collapsed.

+12 −3
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import from JSON all;
// LibCommon
import from LibCommon_BasicTypesAndValues all;


type record of AppMobilityServiceInfo AppMobilityServiceInfos;
type record AppMobilityServiceInfo {
  RegistrationInfos registeredAppMobilityService ,
@@ -49,9 +50,8 @@ type record DeviceInformation {
type JSON.AnyURI links;

type enumerated SubscriptionType {
	RESERVED,
	MOBILITY_PROCEDURE,
	ADJACENT_APPINFO
	MobilityProcedureSubscription,
	AdjacentAppInfoSubscription
}

type record Subscription {
@@ -76,6 +76,8 @@ type record MobilityProcedureSubscriptionError {
}




type record of MobilityProcedureSubscription MobilityProcedureSubscriptions;
type record MobilityProcedureSubscription {
  SubscriptionType subscriptionType,
@@ -111,6 +113,13 @@ type record AdjacentFilterCriteria {
}


type record of ExpiryNotification ExpiryNotifications;
type record ExpiryNotification {
  TimeStamp timeStamp,
  JSON.AnyURI links optional,
  TimeStamp expiryDeadline
}

type record of AdjacentAppInfoSubscription  AdjacentAppInfoSubscriptions;
type record AdjacentAppInfoSubscription {
  SubscriptionType subscriptionType,
Loading