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

Add HTTP Headers check and registration function

parent e3c32662
...@@ -31,125 +31,132 @@ import from LibMec_Functions all; ...@@ -31,125 +31,132 @@ import from LibMec_Functions all;
import from LibMec_Pics all; import from LibMec_Pics all;
import from LibMec_Pixits all; import from LibMec_Pixits all;
group appMobilityServices {
group appMobilityServices {
testcase TP_MEC_SRV_AMS_001_OK() runs on HttpComponent system HttpTestAdapter {
testcase TP_MEC_SRV_AMS_001_OK() runs on HttpComponent system HttpTestAdapter { // Local variables
var HeaderLines v_headers; var HeaderLines v_headers;
if (not(PICS_AMS) or not(PICS_AMS_API_SUPPORTED)){ var HttpMessage v_response;
log("*** " & testcasename() & ": PICS_AMS required for executing the TC ***");
setverdict(inconc); // Test control
stop; if (not(PICS_AMS) or not(PICS_AMS_API_SUPPORTED)){
} log("*** " & testcasename() & ": PICS_AMS required for executing the TC ***");
setverdict(inconc);
// Test component configuration stop;
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_ME_APP_AMS_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_app_mobility_service_info(
mw_app_mobility_service_info(
{
*,
mw_app_mobility_service_info(PX_APP_MOBILITY_SERVICE_ID)
}
)
)
)
)
)
)
{
tc_ac.stop;
log("*** " & testcasename() & ": PASS: IUT successfully responds with a AppMobilityServiceInfo ***");
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
}
testcase TP_MEC_SRV_AMS_001_BR() runs on HttpComponent system HttpTestAdapter {
var HeaderLines v_headers;
if (not(PICS_AMS) or not(PICS_AMS_API_SUPPORTED)){
log("*** " & testcasename() & ": PICS_AMS 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_ME_APP_AMS_URI & "?appMobilityService=" & oct2char(unichar2oct(PX_APP_MOBILITY_SERVICE_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_400_bad_request(
mw_http_message_body_json(
mw_body_json_ams_problem_details(
mw_problem_details(
{
-, -, 400
}
)
)
)
)
)
)
{
tc_ac.stop;
log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***"); // Test component configuration
f_selfOrClientSyncAndVerdict(c_tbDone, e_success); 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_ME_APP_AMS_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_app_mobility_service_info(
mw_app_mobility_service_info(
{
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;
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);
stop;
} }
[] tc_ac.timeout {
log("*** " & testcasename() & ": INCONC: Expected message not received ***");
f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
}
} // End of 'alt' statement
}
// 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_ME_APP_AMS_URI & "?appMobilityService=" & oct2char(unichar2oct(PX_APP_MOBILITY_SERVICE_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_400_bad_request(
mw_http_message_body_json(
mw_body_json_ams_problem_details(
mw_problem_details(
-,
-,
400
)))))) {
tc_ac.stop;
log("*** " & testcasename() & ": PASS: IUT successfully responds with a ProblemDetails set to 400 Bad Request ***");
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_SRV_AMS_001_BR
/*
testcase TP_MEC_SRV_AMS_002_OK() runs on HttpComponent system HttpTestAdapter { testcase TP_MEC_SRV_AMS_002_OK() runs on HttpComponent system HttpTestAdapter {
var HeaderLines v_headers; var HeaderLines v_headers;
...@@ -310,7 +317,7 @@ group appMobilityServicesSubscriptions { ...@@ -310,7 +317,7 @@ group appMobilityServicesSubscriptions {
httpPort.send( httpPort.send(
m_http_request( m_http_request(
m_http_request_get( 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 v_headers
) )
) )
...@@ -363,7 +370,7 @@ group appMobilityServicesSubscriptions { ...@@ -363,7 +370,7 @@ group appMobilityServicesSubscriptions {
httpPort.send( httpPort.send(
m_http_request( m_http_request(
m_http_request_get( 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 v_headers
) )
) )
...@@ -420,18 +427,15 @@ group appMobilityServicesSubscriptions { ...@@ -420,18 +427,15 @@ group appMobilityServicesSubscriptions {
httpPort.send( httpPort.send(
m_http_request( m_http_request(
m_http_request_post( m_http_request_post(
"/" & PICS_ROOT_API & X_ME_APP_AMS_SUBS, "/" & PICS_ROOT_API & PX_ME_APP_AMS_SUBS,
v_headers, v_headers,
m_http_message_body_json( m_http_message_body_json(
m_body_json_ams_subscriptions({ m_body_json_ams_subscriptions({*,
m_ams_subscription( m_ams_subscription(
PX_SUBSCRIPTION_TYPE, PX_SUBSCRIPTION_TYPE,
PX_CALLBACK_REFERENCE, PX_CALLBACK_REFERENCE
*,
*,
*
) )
}) }, *)
) )
) )
) )
...@@ -446,13 +450,12 @@ group appMobilityServicesSubscriptions { ...@@ -446,13 +450,12 @@ group appMobilityServicesSubscriptions {
mw_http_response_201_created( mw_http_response_201_created(
mw_http_message_body_json( mw_http_message_body_json(
mw_body_json_ams_subscriptions( mw_body_json_ams_subscriptions(
mw_ams_subscription( { *, mw_ams_subscription(
PX_SUBSCRIPTION_TYPE, 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 { ...@@ -490,13 +493,12 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter {
httpPort.send( httpPort.send(
m_http_request( m_http_request(
m_http_request_post( m_http_request_post(
"/" & PICS_ROOT_API & X_ME_APP_AMS_SUBS, "/" & PICS_ROOT_API & PX_ME_APP_AMS_SUBS,
v_headers, v_headers,
m_http_message_body_json( m_http_message_body_json(
m_body_json_ams_subscriptions( m_body_json_ams_subscriptions(
m_ams_subscription_error({ m_ams_subscription_error(
PX_SUBSCRIPTION_TYPE, PX_CALLBACK_REFERENCE, *, *, * PX_SUBSCRIPTION_TYPE, PX_CALLBACK_REFERENCE
}
) )
) )
) )
...@@ -514,9 +516,7 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter { ...@@ -514,9 +516,7 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter {
mw_http_message_body_json( mw_http_message_body_json(
mw_body_json_ams_problem_details( mw_body_json_ams_problem_details(
mw_problem_details( mw_problem_details(
{
-, -, 400 -, -, 400
}
) )
) )
) )
...@@ -535,10 +535,9 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter { ...@@ -535,10 +535,9 @@ testcase TP_MEC_SRV_AMS_004_BR() runs on HttpComponent system HttpTestAdapter {
} }
} // End of 'alt' statement } // End of 'alt' statement
} }*/
} } // End of group appMobilityServices
} // End of module AtsMec_Ams_TestCases } // End of module AtsMec_Ams_TestCases
...@@ -42,7 +42,7 @@ module AtsMec_AppEnablementAPI_TestCases { ...@@ -42,7 +42,7 @@ module AtsMec_AppEnablementAPI_TestCases {
testcase TC_MEC_SRV_TRANS_001_OK() runs on HttpComponent system HttpTestAdapter { testcase TC_MEC_SRV_TRANS_001_OK() runs on HttpComponent system HttpTestAdapter {
// Local variables // Local variables
var HeaderLines v_headers; var HeaderLines v_headers;
// Test control // Test control
if (not(PICS_MEC_PLAT) or not(PICS_SERVICES) or not(PICS_ENABLE_APP_API_SUPPORTED)) { 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 ***"); 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 { ...@@ -18,6 +18,7 @@ module AtsMec_RnisAPI_TestCases {
// LibHttp // LibHttp
import from LibItsHttp_TypesAndValues all; import from LibItsHttp_TypesAndValues all;
import from LibItsHttp_JsonMessageBodyTypes all;
import from LibItsHttp_Functions all; import from LibItsHttp_Functions all;
import from LibItsHttp_Templates all; import from LibItsHttp_Templates all;
import from LibItsHttp_JsonTemplates all; import from LibItsHttp_JsonTemplates all;
...@@ -1025,12 +1026,15 @@ module AtsMec_RnisAPI_TestCases { ...@@ -1025,12 +1026,15 @@ module AtsMec_RnisAPI_TestCases {
group rnis_notifications { 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 * @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 { testcase TC_MEC_SRV_RNIS_001_OK() runs on HttpComponent system HttpTestAdapter {
// Local variables // Local variables
var HeaderLines v_headers; var HeaderLines v_headers;
var integer v_result;
var JsonBody v_json_body;
var charstring v_subscription_id;
// Test control // Test control
if (not(PICS_RNIS) or not(PICS_RNIS_NOTIFICATIONS)) { if (not(PICS_RNIS) or not(PICS_RNIS_NOTIFICATIONS)) {
...@@ -1046,6 +1050,36 @@ module AtsMec_RnisAPI_TestCases { ...@@ -1046,6 +1050,36 @@ module AtsMec_RnisAPI_TestCases {
// Preamble // Preamble
f_init_default_headers_list(-, -, v_headers); 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"); action("Trigger a cell change event");
f_selfOrClientSyncAndVerdict(c_prDone, e_success); f_selfOrClientSyncAndVerdict(c_prDone, e_success);
...@@ -1078,6 +1112,10 @@ module AtsMec_RnisAPI_TestCases { ...@@ -1078,6 +1112,10 @@ module AtsMec_RnisAPI_TestCases {
} // End of 'alt' statement } // End of 'alt' statement
// Postamble // 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(); f_cf_01_http_notif_down();
} // End of testcase TC_MEC_SRV_RNIS_001_OK } // End of testcase TC_MEC_SRV_RNIS_001_OK
......
module Ams_Pixits { module Ams_Pixits {
// LibCommon // JSON
import from LibCommon_BasicTypesAndValues all; import from JSON all;
// LibMec/LocationAPI // LibMec/LocationAPI
import from Ams_TypesAndValues all; 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 } // End of module LocationAPI_Pixits
...@@ -27,9 +27,45 @@ module Ams_Templates { ...@@ -27,9 +27,45 @@ module Ams_Templates {
appMobilityServiceId := p_app_mobility_service_id 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 ( template (omit) RegistrationRequest m_registration_request (
in template (omit) ServiceConsumerId p_service_consumer_id := omit, 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 in UInt32 p_expire_time
) := { ) := {
serviceConsumerId := p_service_consumer_id, serviceConsumerId := p_service_consumer_id,
...@@ -39,121 +75,105 @@ module Ams_Templates { ...@@ -39,121 +75,105 @@ module Ams_Templates {
template RegistrationRequest mw_registration_request( template RegistrationRequest mw_registration_request(
template ServiceConsumerId p_service_consumer_id := ?, template ServiceConsumerId p_service_consumer_id := ?,
template DeviceInformations p_device_info := omit, template DeviceInformations p_device_info := omit,
template UInt32 p_expire_time := omit template UInt32 p_expire_time := omit
) := { ) := {
serviceConsumerId := p_service_consumer_id, serviceConsumerId := p_service_consumer_id,
deviceInformation := p_device_info, deviceInformation := p_device_info,
expiryTime := p_expire_time expiryTime := p_expire_time
} }