Commit 99b9962a authored by YannGarcia's avatar YannGarcia

Add HTTP Headers check and registration function

parent e3c32662
This diff is collapsed.
......@@ -42,7 +42,7 @@ module AtsMec_AppEnablementAPI_TestCases {
testcase TC_MEC_SRV_TRANS_001_OK() runs on HttpComponent system HttpTestAdapter {
// Local variables
var HeaderLines v_headers;
// Test control
if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_ENABLE_APP_API_SUPPORTED)) {
log("*** " & testcasename() & ": PICS_MEC_PLAT and PICS_SERVICES and PICS_ENABLE_APP_API_SUPPORTED required for executing the TC ***");
......
......@@ -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;
......@@ -1025,12 +1026,15 @@ module AtsMec_RnisAPI_TestCases {
group rnis_notifications {
/**
* @desc Check that the RNIS service sends an RNIS notification about cell change if the RNIS service has an associated subscription and the event is generated.
* @desc Check that the RNIS service sends an RNIS notification about cell change if the RNIS service has an associated subscription and the event is generated.
* @see https://forge.etsi.org/gitlab/mec/gs032p2-test-purposes/blob/master/Test%20Purposes/SRV/RNIS/RnisNotifications.tplan2
*/
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
......
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
......@@ -27,9 +27,45 @@ 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,
in template (omit) DeviceInformations p_device_info := omit,
in UInt32 p_expire_time
) := {
serviceConsumerId := p_service_consumer_id,
......@@ -39,121 +75,105 @@ module Ams_Templates {
template RegistrationRequest mw_registration_request(
template ServiceConsumerId p_service_consumer_id := ?,
template DeviceInformations p_device_info := omit,
template DeviceInformations p_device_info := omit,
template UInt32 p_expire_time := omit
) := {
serviceConsumerId := p_service_consumer_id,
deviceInformation := p_device_info,
expiryTime := p_expire_time
expiryTime := p_expire_time
}
template (value) RegistrationInfo m_registration_info (
in template (omit) ServiceConsumerId p_service_consumer_id := omit,
in template (omit) DeviceInformations p_device_info := omit,
in UInt32 p_expire_time
in template (omit) ServiceConsumerId p_service_consumer_id := omit,
in template (omit) DeviceInformations p_device_info := omit,
in UInt32 p_expire_time
) := {
serviceConsumerId := p_service_consumer_id,
deviceInformation := p_device_info,
expiryTime := p_expire_time
expiryTime := p_expire_time
}
template (present) RegistrationInfo mw_registration_info(
template (present) ServiceConsumerId p_service_consumer_id := ?,
template (present) DeviceInformations p_device_info := ?,
template (present) DeviceInformations p_device_info := ?,
template (present) UInt32 p_expire_time
) := {
serviceConsumerId := p_service_consumer_id,
deviceInformation := p_device_info,
expiryTime := p_expire_time
expiryTime := p_expire_time
}
template (value) ServiceConsumer m_service_consumer (
in String p_app_instance,
in String p_mep_id
in String p_app_instance,
in String p_mep_id
) := {
appInstance := p_app_instance,
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
in String p_associate_id
) := {
associateId := p_associate_id
}
template (omit) DeviceInformation mw_device_info (
in String p_associate_id
in String p_associate_id
) := {
associateId := p_associate_id
}
type record AmsSubscriptionLinkList {
JSON.AnyURI links,
Subscription subscription
}
template (value) MobilityProcedureSubscription m_ams_subscription (
in SubscriptionType p_subscriptionType,
in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links,
in FilterCriteria p_filterCriteria,
in TimeStamp p_expiryDeadline
in SubscriptionType p_subscriptionType,
in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links,
in FilterCriteria p_filterCriteria,
in TimeStamp p_expiryDeadline
) := {
subscriptionType := p_subscriptionType ,
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
}
template (value) MobilityProcedureSubscriptionError m_ams_subscription_error (
in SubscriptionTyp p_subscriptionType,
in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links,
in FilterCriteria p_filterCriteria,
in TimeStamp p_expiryDeadline
in SubscriptionType p_subscriptionType,
in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links,
in FilterCriteria p_filterCriteria,
in TimeStamp p_expiryDeadline
) := {
subscriptionType := p_subscriptionType,
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
}
template (present) MobilityProcedureSubscription mw_ams_subscription (
in SubscriptionType p_subscriptionType,
in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links,
in FilterCriteria p_filterCriteria,
in TimeStamp p_expiryDeadline
in SubscriptionType p_subscriptionType,
in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links,
in FilterCriteria p_filterCriteria,
in TimeStamp p_expiryDeadline
) := {
subscriptionType := p_subscriptionType ,
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
}
......
......@@ -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,
......
......@@ -14,6 +14,7 @@ module LibMec_Functions {
// LibHttp
import from LibItsHttp_TypesAndValues all;
import from LibItsHttp_JsonMessageBodyTypes all;
import from LibItsHttp_Templates all;
import from LibItsHttp_TestSystem all;
import from LibItsHttp_Templates all;
......@@ -125,6 +126,7 @@ module LibMec_Functions {
var HttpMessage v_response;
var integer v_result := -1;
// Send request
httpPort.send(
m_http_request(
m_http_request_get(
......@@ -133,8 +135,7 @@ module LibMec_Functions {
)
)
);
// Test Body
// Await for the response
tc_ac.start;
alt {
[] httpPort.receive(
......@@ -172,6 +173,85 @@ module LibMec_Functions {
} // End of group helpers
group registration {
function f_register_for_notification(
in charstring p_uri,
in HeaderLines p_headers,
in template (value) JsonBody p_json_body,
out JsonBody p_notification
) runs on HttpComponent return integer {
var integer v_result := -1;
var HttpMessage v_response;
// Send the request
httpPort.send(
m_http_request(
m_http_request_get(
p_uri,
p_headers,
m_http_message_body_json(p_json_body)
)));
// Await for the response
tc_ac.start;
alt {
[] httpPort.receive(
mw_http_response(
mw_http_response_201_created(
mw_http_message_body_json
))) -> value v_response {
tc_ac.stop;
p_notification := v_response.response.body.json_body;
v_result := 0;
log("*** f_register_for_notification: INFO: Regustration for notification succeed ***");
}
[] tc_ac.timeout {
log("*** f_register_for_notification: INCONC: Expected message not received ***");
}
} // End of 'alt' statement
//log("<<< f_register_for_notification: v_result: ", v_result);
return v_result;
} // End of fiunction f_register_for_notification
function f_unregister_for_notification(
in charstring p_uri,
in HeaderLines p_headers
) runs on HttpComponent return integer {
var HttpMessage v_response;
var integer v_result := -1;
// Send the request
httpPort.send(
m_http_request(
m_http_request_delete(
p_uri,
p_headers
)));
// Await for the response
tc_ac.start;
alt {
[] httpPort.receive(
mw_http_response(
mw_http_response_ok
)) -> value v_response {
tc_ac.stop;
v_result := 0;
log("*** f_unregister_for_notification: INFO: Regustration for notification succeed ***");
}
[] tc_ac.timeout {
log("*** f_unregister_for_notification: INCONC: Expected message not received ***");
}
} // End of 'alt' statement
//log("<<< f_unregister_for_notification: v_result: ", v_result);
return v_result;
} // End of fiunction f_unregister_for_notification
} // End of group registration
group altsteps {
altstep a_default_requests() runs on HttpComponent {
......
......@@ -50,13 +50,13 @@ import from Ams_Templates all;
group ams_api {
template (value) JsonBody m_body_json_app_mobility_service_info(
in template (value) AppMobilityServiceInfo p_app_mobility_service_info
in template (value) AppMobilityServiceInfo p_app_mobility_service_info
) := {
appMobilityServiceInfo := p_app_mobility_service_info
} // End of template mw_body_json_app_mobility_service_info
template (present) JsonBody mw_body_json_app_mobility_service_info(
template (present) AppMobilityServiceInfo p_app_mobility_service_info := ?
template (present) AppMobilityServiceInfo p_app_mobility_service_info := ?
) := {
appMobilityServiceInfo := p_app_mobility_service_info
} // End of template mw_body_json_app_mobility_service_info
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment