Commit 99b9962a authored by YannGarcia's avatar YannGarcia
Browse files

Add HTTP Headers check and registration function

parent e3c32662
Loading
Loading
Loading
Loading
+138 −139
Original line number Diff line number Diff line
@@ -31,11 +31,14 @@ import from LibMec_Functions all;
import from LibMec_Pics all;
import from LibMec_Pixits all;


  group appMobilityServices {

    testcase TP_MEC_SRV_AMS_001_OK() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines v_headers;
      var HttpMessage v_response;

      // Test control
      if (not(PICS_AMS) or not(PICS_AMS_API_SUPPORTED)){
        log("*** " & testcasename() & ": PICS_AMS required for executing the TC ***");
        setverdict(inconc);
@@ -45,7 +48,6 @@ group appMobilityServices {
      // Test component configuration
      f_cf_01_http_up();


      // Preamble
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
@@ -53,9 +55,7 @@ group appMobilityServices {
                                   m_http_request_get(
                                                      "/" & PICS_ROOT_API & PX_ME_APP_AMS_URI,
                                                      v_headers
        )
      )
    );
                                                      )));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
@@ -68,34 +68,49 @@ group appMobilityServices {
                                                                                           mw_body_json_app_mobility_service_info(
                                                                                                                                  mw_app_mobility_service_info(
                                                                                                                                                               {
                    *,
                    mw_app_mobility_service_info(PX_APP_MOBILITY_SERVICE_ID)
                  }
                )
              )
            )
                                                                                                                                                                 mw_app_mobility_registration_info(
                                                                                                                                                                                                   mw_service_consumer_id(
                                                                                                                                                                                                                          PX_APP_INS_ID,
                                                                                                                                                                                                                          PX_MEP_ID
                                                                                                                                                                                                                          )
                                                                                                                                                                                                   )
      ) 
      {
                                                                                                                                                                 }
                            )))))) -> value v_response {
          // TODO Need to check Location header
          var boolean v_header_matched := false;
          
          tc_ac.stop;
          
        log("*** " & testcasename() & ": PASS: IUT successfully responds with a AppMobilityServiceInfo ***");
          v_headers := v_response.response.header;
          for (var integer v_idx := 0; v_idx < lengthof(v_headers); v_idx := v_idx + 1) {
            if (v_headers[v_idx].header_name == "Location") {
              if (match(v_headers[v_idx].header_value[0], "<my expected value or a receive template>") == true) { 
                v_header_matched := true;
              } // else, nothing to do
              break;
            }
          } // End of 'for' statement
          
          if (v_header_matched == true) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a AppTerminationNotificationSubscription ***");
            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 TP_MEC_SRV_AMS_001_OK

    testcase TP_MEC_SRV_AMS_001_BR() runs on HttpComponent system HttpTestAdapter {
      // Local variables
      var HeaderLines v_headers;

      // Test control
      if (not(PICS_AMS) or not(PICS_AMS_API_SUPPORTED)){
        log("*** " & testcasename() & ": PICS_AMS required for executing the TC ***");
        setverdict(inconc);
@@ -105,7 +120,6 @@ group appMobilityServices {
      // Test component configuration
      f_cf_01_http_up();


      // Preamble
      f_init_default_headers_list(-, -, v_headers);
      httpPort.send(
@@ -113,9 +127,7 @@ group appMobilityServices {
                                   m_http_request_get(
                                                      "/" & PICS_ROOT_API & PX_ME_APP_AMS_URI & "?appMobilityService=" & oct2char(unichar2oct(PX_APP_MOBILITY_SERVICE_ID, "UTF-8")),
                                                      v_headers
        )
      )
    );
                                                      )));
      f_selfOrClientSyncAndVerdict(c_prDone, e_success);

      // Test Body
@@ -127,16 +139,10 @@ group appMobilityServices {
                                                                              mw_http_message_body_json(
                                                                                                        mw_body_json_ams_problem_details(
                                                                                                                                         mw_problem_details(
                  {
                    -, -, 400
                  }
                )
              )
            )
          )
        )
      ) 
      {
                                                                                                                                                            -, 
                                                                                                                                                            -, 
                                                                                                                                                            400
                                                                                                                                                            )))))) {
          tc_ac.stop;

          log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
@@ -148,8 +154,9 @@ group appMobilityServices {
        }
      } // End of 'alt' statement

  }
    }  // End of testcase TP_MEC_SRV_AMS_001_BR
    
/*

  testcase TP_MEC_SRV_AMS_002_OK() runs on HttpComponent system HttpTestAdapter {
    var HeaderLines v_headers;
@@ -310,7 +317,7 @@ group appMobilityServicesSubscriptions {
    httpPort.send(
      m_http_request(
        m_http_request_get(
          "/" & PICS_ROOT_API & X_ME_APP_AMS_SUBS & "?subscriptionType=" & oct2char(unichar2oct(PX_SUBSCRIPTION_TYPE, "UTF-8")),
          "/" & PICS_ROOT_API & PX_ME_APP_AMS_SUBS & "?subscriptionType=" & oct2char(unichar2oct(PX_SUBSCRIPTION_TYPE, "UTF-8")),
          v_headers
        )
      )
@@ -363,7 +370,7 @@ group appMobilityServicesSubscriptions {
    httpPort.send(
      m_http_request(
        m_http_request_get(
          "/" & PICS_ROOT_API & X_ME_APP_AMS_SUBS & "?subscriptionTyp=" & oct2char(unichar2oct(PX_SUBSCRIPTION_TYPE, "UTF-8")),
          "/" & PICS_ROOT_API & PX_ME_APP_AMS_SUBS & "?subscriptionTyp=" & oct2char(unichar2oct(PX_SUBSCRIPTION_TYPE, "UTF-8")),
          v_headers
        )
      )
@@ -420,18 +427,15 @@ group appMobilityServicesSubscriptions {
    httpPort.send(
      m_http_request(
        m_http_request_post(
         "/" & PICS_ROOT_API & X_ME_APP_AMS_SUBS,
         "/" & PICS_ROOT_API & PX_ME_APP_AMS_SUBS,
          v_headers,
          m_http_message_body_json(
            m_body_json_ams_subscriptions({
            m_body_json_ams_subscriptions({*, 
				m_ams_subscription(
					PX_SUBSCRIPTION_TYPE,
  					PX_CALLBACK_REFERENCE,
  					*,
					*,
					*
  					PX_CALLBACK_REFERENCE
				)
            })
            }, *)
          )
        )
      )
@@ -446,13 +450,12 @@ group appMobilityServicesSubscriptions {
          mw_http_response_201_created(
            mw_http_message_body_json(
              mw_body_json_ams_subscriptions(
                mw_ams_subscription(
                { *, mw_ams_subscription(
                  PX_SUBSCRIPTION_TYPE,
  					PX_CALLBACK_REFERENCE,
  					*,
					*,
                  PX_CALLBACK_REFERENCE
                ),
                *
                )
                }
              )
            )
          )
@@ -490,13 +493,12 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter {
    httpPort.send(
      m_http_request(
        m_http_request_post(
          "/" & PICS_ROOT_API & X_ME_APP_AMS_SUBS,
          "/" & PICS_ROOT_API & PX_ME_APP_AMS_SUBS,
          v_headers,
          m_http_message_body_json(
            m_body_json_ams_subscriptions(
              m_ams_subscription_error({
                PX_SUBSCRIPTION_TYPE, PX_CALLBACK_REFERENCE, *, *, *
              }
              m_ams_subscription_error(
                PX_SUBSCRIPTION_TYPE, PX_CALLBACK_REFERENCE
              )
            )
          )
@@ -514,9 +516,7 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter {
            mw_http_message_body_json(
              mw_body_json_ams_problem_details(
                mw_problem_details(
                  {
                    -, -, 400
                  }
                )
              )
            )
@@ -535,10 +535,9 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter {
      }
    } // End of 'alt' statement

  }

  }*/

}
  } // End of group appMobilityServices


} // End of module AtsMec_Ams_TestCases 
+39 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ module AtsMec_RnisAPI_TestCases {
  
  // LibHttp
  import from LibItsHttp_TypesAndValues all;
  import from LibItsHttp_JsonMessageBodyTypes all;
  import from LibItsHttp_Functions all;
  import from LibItsHttp_Templates all;
  import from LibItsHttp_JsonTemplates all;
@@ -1031,6 +1032,9 @@ module AtsMec_RnisAPI_TestCases {
    testcase TC_MEC_SRV_RNIS_001_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var integer v_result;
        var JsonBody v_json_body;
        var charstring v_subscription_id;
        
        // Test control
        if (not(PICS_RNIS) or not(PICS_RNIS_NOTIFICATIONS)) {
@@ -1046,6 +1050,36 @@ module AtsMec_RnisAPI_TestCases {
        
        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        v_result := f_register_for_notification(
                                                "/" & PICS_ROOT_API & PX_RNIS_SUBSCRITIONS_URI,
                                                v_headers,
                                                m_body_json_cell_change_subscription(
                                                                                     m_cell_change_subscription(
                                                                                                                PX_CALLBACK_REFERENCE,
                                                                                                                PX_LINKS_SELF,
                                                                                                                m_filter_criteria_ho(
                                                                                                                                     "01",
                                                                                                                                     { m_associate_id(UE_IPV4_ADDRESS, PX_ASSOCIATE_ID_VALUE) },
                                                                                                                                     m_plmn("01", "001"),
                                                                                                                                     PX_CELL_ID,
                                                                                                                                     COMPLETED
                                                                                                                                     )
                                                                                                                )
                                                                                     ),
                                                 v_json_body
                                                 );
        if (v_result == 0) {
          // Extract subscription ID for de-registration
          if (ispresent(v_json_body.cellChangeSubscription)) {
            v_subscription_id := oct2char(unichar2oct(v_json_body.cellChangeSubscription.links.self_, "UTF-8"));
          } else {
            log("*** " & testcasename() & ": INCONC: Unexpected JSON message ***");
            f_selfOrClientSyncAndVerdict(c_prDone, e_timeout); // Fail with incoclusive verdict, testcase execution will terminate here
          }
        } else {
          log("*** " & testcasename() & ": INCONC: Failed to register subsciption ***");
          f_selfOrClientSyncAndVerdict(c_prDone, e_timeout); // Fail with incoclusive verdict, testcase execution will terminate here
        }
        action("Trigger a cell change event");
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);
        
@@ -1078,6 +1112,10 @@ module AtsMec_RnisAPI_TestCases {
        } // End of 'alt' statement
        
        // Postamble
        f_unregister_for_notification(
                                      "/" & PICS_ROOT_API & PX_RNIS_SUBSCRITIONS_URI & "/cell_change/" & v_subscription_id,
                                      v_headers
                                      );
        f_cf_01_http_notif_down();
    } // End of testcase TC_MEC_SRV_RNIS_001_OK
    
+10 −8
Original line number Diff line number Diff line
module Ams_Pixits {
  
  // LibCommon
  import from LibCommon_BasicTypesAndValues all;
  // JSON
  import from JSON all;

  // LibMec/LocationAPI
  import from Ams_TypesAndValues all;
  
  modulepar charstring PX_APP_MOBILITY_SERVICE_ID := "KtRGymNQ84dG3mQfRepa"
  modulepar JSON.String PX_APP_MOBILITY_SERVICE_ID := "KtRGymNQ84dG3mQfRepa"
  
  modulepar charstring PX_APP_INS_ID := "5abe4782-2c70-4e47-9a4e-0ee3a1a0fd1f"
  modulepar JSON.String PX_APP_INS_ID := "5abe4782-2c70-4e47-9a4e-0ee3a1a0fd1f"
  
  modulepar charstring PX_SUBSCRIPTION_TYPE := "MobilityProcedureSubscription"
  modulepar JSON.String PX_SUBSCRIPTION_TYPE := "MobilityProcedureSubscription"
  
  modulepar charstring PX_SUBSCRIPTION_ID := "e0deee2b-6e50-4f33-ab09-8bf0585025d3"
  modulepar JSON.String PX_SUBSCRIPTION_ID := "e0deee2b-6e50-4f33-ab09-8bf0585025d3"
  
  modulepar charstring PX_NON_EXISTENT_SUBSCRIPTION_ID := "NON_EXISTENT_SUBSCRIPTION_ID"
  modulepar JSON.String PX_NON_EXISTENT_SUBSCRIPTION_ID := "NON_EXISTENT_SUBSCRIPTION_ID"
  
  modulepar charstring PX_CALLBACK_REFERENCE :=	"http://127.0.0.1/callback"
  modulepar JSON.String PX_CALLBACK_REFERENCE :=	"http://127.0.0.1/callback"
  
  modulepar JSON.String PX_MEP_ID := "";
  
} // End of module LocationAPI_Pixits 
+83 −63
Original line number Diff line number Diff line
@@ -27,6 +27,42 @@ module Ams_Templates {
    appMobilityServiceId         := p_app_mobility_service_id
  } 

  template (omit) RegistrationInfo m_app_mobility_registration_info(
                                                                    in template (value) ServiceConsumerId p_serviceConsumerId,
                                                                    in template (omit) DeviceInformations p_deviceInformation := omit,
                                                                    in template (omit) UInt32 p_expiryTime := omit
  ) := {
    serviceConsumerId := p_serviceConsumerId,
    deviceInformation := p_deviceInformation,
    expiryTime        := p_expiryTime
  }

  template RegistrationInfo mw_app_mobility_registration_info(
                                                              template (present) ServiceConsumerId p_serviceConsumerId := ?,
                                                              template DeviceInformations p_deviceInformation := *,
                                                              template UInt32 p_expiryTime := *
  ) := {
    serviceConsumerId := p_serviceConsumerId,
    deviceInformation := p_deviceInformation,
    expiryTime        := p_expiryTime
  }

  template (omit) ServiceConsumerId m_service_consumer_id(
                                                          in template (omit) String p_appInstanceId := omit,
                                                          in template (omit) String p_mepId := omit
  ) := {
    appInstanceId := p_appInstanceId,
    mepId         := p_mepId
  }

  template ServiceConsumerId mw_service_consumer_id(
                                                    template String p_appInstanceId := *,
                                                    template String p_mepId := *
  ) := {
    appInstanceId := p_appInstanceId,
    mepId         := p_mepId
  }

  template (omit) RegistrationRequest m_registration_request (
                                                              in template (omit) ServiceConsumerId p_service_consumer_id := omit,
                                                              in template (omit) DeviceInformations p_device_info  := omit,
@@ -77,27 +113,6 @@ module Ams_Templates {
    mepId := p_mep_id
  }


  template (value) ServiceConsumerId m_service_consumer_id (
  		in String p_app_instance_id,
  		in String p_mep_id 
  ) := {
    appInstanceId := p_app_instance_id,
    mepId := p_mep_id
  }
  
  
  
  template ServiceConsumerId mw_service_consumer_id(
                                                    template (present) String p_app_instance_id := ?,
                                                    template (present) String p_mep_id := ?
  ) := {
    appInstanceId := p_app_instance_id,
    mepId := p_mep_id
  }
  
  
  
  template (value) DeviceInformation m_device_info (
      in String p_associate_id
  ) := {
@@ -109,6 +124,11 @@ module Ams_Templates {
  ) := {
    associateId := p_associate_id
  }  
  type record AmsSubscriptionLinkList {
    JSON.AnyURI links,
    Subscription subscription
  }
  
  
 
   template (value) MobilityProcedureSubscription m_ams_subscription (
@@ -128,7 +148,7 @@ module Ams_Templates {
  
  
  template (value) MobilityProcedureSubscriptionError m_ams_subscription_error (
  	in SubscriptionTyp p_subscriptionType,
    in SubscriptionType p_subscriptionType,
    in JSON.AnyURI p_callbackReference,
    in JSON.AnyURI p_links,
    in FilterCriteria p_filterCriteria,
+1 −8
Original line number Diff line number Diff line
@@ -54,13 +54,6 @@ type enumerated SubscriptionType {
	ADJACENT_APPINFO
}


type enumerated SubscriptionTyp {
	RESERVED,
	MOBILITY_PROCEDURE,
	ADJACENT_APPINFO
}

type record Subscription {
  JSON.AnyURI href,
  SubscriptionType subscriptionType
@@ -75,7 +68,7 @@ type record AmsSubscriptionLinkList {


type record MobilityProcedureSubscriptionError {
  SubscriptionTyp subscriptionType,
  SubscriptionType subscriptionType,
  JSON.AnyURI callbackReference,
  JSON.AnyURI links optional,
  FilterCriteria filterCriteria,
Loading