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

Adding TPs for Granting operations. Fixing AMS TPs

parent d55aa377
This diff is collapsed.
/**
* @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
}
}
...@@ -10,7 +10,7 @@ module Ams_Pixits { ...@@ -10,7 +10,7 @@ module Ams_Pixits {
modulepar JSON.String PX_APP_INS_ID := "5abe4782-2c70-4e47-9a4e-0ee3a1a0fd1f" 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" modulepar JSON.String PX_SUBSCRIPTION_ID := "e0deee2b-6e50-4f33-ab09-8bf0585025d3"
...@@ -18,6 +18,8 @@ module Ams_Pixits { ...@@ -18,6 +18,8 @@ module Ams_Pixits {
modulepar JSON.String PX_CALLBACK_REFERENCE := "http://127.0.0.1/callback" 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 := ""; modulepar JSON.String PX_MEP_ID := "";
} // End of module LocationAPI_Pixits } // End of module LocationAPI_Pixits
...@@ -54,6 +54,14 @@ module Ams_Templates { ...@@ -54,6 +54,14 @@ module Ams_Templates {
appInstanceId := p_appInstanceId, appInstanceId := p_appInstanceId,
mepId := p_mepId mepId := p_mepId
} }
template (omit) ServiceConsumer m_service_consumer_error(
in template (omit) String p_appInstance := omit,
in template (omit) String p_mepId := omit
) := {
appInstance := p_appInstance,
mepId := p_mepId
}
template ServiceConsumerId mw_service_consumer_id( template ServiceConsumerId mw_service_consumer_id(
template String p_appInstanceId := *, template String p_appInstanceId := *,
...@@ -66,13 +74,25 @@ module Ams_Templates { ...@@ -66,13 +74,25 @@ module Ams_Templates {
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 template (omit) 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
} }
template (omit) RegistrationRequest m_registration_request_error (
in template (omit) ServiceConsumer p_service_consumer := omit,
in template (omit) DeviceInformations p_device_info := omit,
in template (omit) UInt32 p_expire_time := omit
) := {
serviceConsumerId := p_service_consumer,
deviceInformation := p_device_info,
expiryTime := p_expire_time
}
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,
...@@ -94,14 +114,12 @@ module Ams_Templates { ...@@ -94,14 +114,12 @@ module Ams_Templates {
expiryTime := p_expire_time expiryTime := p_expire_time
} }
template (present) RegistrationInfo mw_registration_info( template (present) RegistrationInfos mw_registration_info(
template (present) ServiceConsumerId p_service_consumer_id := ?, 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 template (present) UInt32 p_expire_time := ?
) := { ) := {
serviceConsumerId := p_service_consumer_id,
deviceInformation := p_device_info,
expiryTime := p_expire_time
} }
...@@ -112,6 +130,14 @@ module Ams_Templates { ...@@ -112,6 +130,14 @@ module Ams_Templates {
appInstance := p_app_instance, appInstance := p_app_instance,
mepId := p_mep_id mepId := p_mep_id
} }
template (omit) ServiceConsumer mw_service_consumer (
in String p_app_instance,
in template (omit) String p_mep_id := omit
) := {
appInstance := p_app_instance,
mepId := p_mep_id
}
template (value) DeviceInformation m_device_info ( template (value) DeviceInformation m_device_info (
in String p_associate_id in String p_associate_id
...@@ -129,14 +155,28 @@ module Ams_Templates { ...@@ -129,14 +155,28 @@ module Ams_Templates {
Subscription subscription Subscription subscription
} }
template (value) AdjacentAppInfoSubscription mw_adjacent_application_info_notification (
in template (omit) SubscriptionType p_subscriptionType := omit,
in JSON.AnyURI p_callbackReference,
in template (omit) JSON.AnyURI p_links := omit,
in template (omit) AdjacentFilterCriteria p_filterCriteria := omit,
in template (omit) TimeStamp p_expiryDeadline := omit
) := {
subscriptionType := p_subscriptionType ,
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
}
template (value) MobilityProcedureSubscription m_ams_subscription ( template (value) MobilityProcedureSubscription m_ams_subscription (
in SubscriptionType p_subscriptionType, in SubscriptionType p_subscriptionType := PX_SUBSCRIPTION_TYPE,
in JSON.AnyURI p_callbackReference, in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links, in template (omit) JSON.AnyURI p_links := omit,
in FilterCriteria p_filterCriteria, in template (omit) FilterCriteria p_filterCriteria := omit,
in TimeStamp p_expiryDeadline in template (omit) TimeStamp p_expiryDeadline := omit
) := { ) := {
subscriptionType := p_subscriptionType , subscriptionType := p_subscriptionType ,
...@@ -147,12 +187,28 @@ module Ams_Templates { ...@@ -147,12 +187,28 @@ module Ams_Templates {
} }
template (value) MobilityProcedureSubscription mw_mobility_procedure_notification (
in template (omit) SubscriptionType p_subscriptionType := omit,
in JSON.AnyURI p_callbackReference,
in template (omit) JSON.AnyURI p_links := omit,
in template (omit) FilterCriteria p_filterCriteria := omit,
in template (omit) TimeStamp p_expiryDeadline := omit
) := {
subscriptionType := p_subscriptionType ,
callbackReference := p_callbackReference,
links := p_links,
filterCriteria := p_filterCriteria,
expiryDeadline := p_expiryDeadline
}
template (value) MobilityProcedureSubscriptionError m_ams_subscription_error ( template (value) MobilityProcedureSubscriptionError m_ams_subscription_error (
in SubscriptionType p_subscriptionType, in SubscriptionType p_subscriptionType,
in JSON.AnyURI p_callbackReference, in JSON.AnyURI p_callbackReference,
in JSON.AnyURI p_links, in template (omit) JSON.AnyURI p_links := omit,
in FilterCriteria p_filterCriteria, in template (omit) FilterCriteria p_filterCriteria := omit,
in TimeStamp p_expiryDeadline in template (omit) TimeStamp p_expiryDeadline := omit
) := { ) := {
subscriptionType := p_subscriptionType, subscriptionType := p_subscriptionType,
...@@ -164,10 +220,10 @@ module Ams_Templates { ...@@ -164,10 +220,10 @@ module Ams_Templates {
template (present) MobilityProcedureSubscription mw_ams_subscription ( template (present) MobilityProcedureSubscription mw_ams_subscription (
in SubscriptionType p_subscriptionType, in Subscrip