-
Miguel Angel Reina Ortega authored
Signed-off-by:
reinaortega <miguelangel.reinaortega@etsi.org>
Miguel Angel Reina Ortega authoredSigned-off-by:
reinaortega <miguelangel.reinaortega@etsi.org>
OneM2M_Functions.ttcn 149.42 KiB
/**
* Copyright Notification
* No part of this document may be reproduced, in an electronic retrieval system or otherwise, except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* © 2016, oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TSDSI, TTA, TTC).
* All rights reserved.
*
* @author ETSI
* @version $URL: https://oldforge.etsi.org/svn/oneM2M/branches/Release1/ttcn/LibOneM2M/OneM2M_Functions.ttcn $
* $Id: OneM2M_Functions.ttcn 347 2017-08-11 08:48:20Z reinaortega $
* @desc Module containing functions for oneM2M
*
*/
module OneM2M_Functions {
import from XSD all;
import from LibCommon_Time all;
import from OneM2M_Templates all;
import from OneM2M_Types all;
import from OneM2M_TypesAndValues all;
import from OneM2M_TestSystem all;
import from OneM2M_Pixits all;
import from OneM2M_Pics all;
group ConfigFunctions {
/**
@desc Ports mapping and default behaviour activation for Config 1
*/
function f_cf01Up(in boolean p_auxiliaryAe2Required := false) runs on AeSimu {
// Variables
vc_config := e_cf01;
vc_testSystemRole := e_ae;
// Map
map(self:mcaPort, system:mcaPort);
map(self:mcaPortIn, system:mcaPortIn);
map(self:acPort, system:acPort);
activate(a_default());
vc_a_cse := activate(a_cse_cf01());
// Initialize AE2
if(p_auxiliaryAe2Required) {
vc_auxiliaryAe2Up := p_auxiliaryAe2Required;
vc_ae2 := AeSimu.create("AE2") alive;
vc_ae2.start(f_cf01UpAe2());
vc_ae2.done;
}
//Initialze the IUT
} // end f_cf01Up
/**
@desc Ports mapping and default behaviour activation for Config 1 on the auxiliary AE2
*/
function f_cf01UpAe2() runs on AeSimu {
// Variables
vc_config := e_cf01;
vc_testSystemRole := e_ae;
// Map
map(self:mcaPort, system:mcaPort);
map(self:mcaPortIn, system:mcaPortIn);
map(self:acPort, system:acPort);
//Initialze the IUT
} // end f_cf01Up
/**
* @desc Ports mapping and default behaviour activation for Config 02
*/
function f_cf02Up() runs on AeSimu {
// Variables
vc_config := e_cf02;
vc_testSystemRole := e_ae;
vc_cse1 := CseSimu.create("CSE1") alive;
// Map
map(self:mcaPort, system:mcaPort);
map(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED) {
map(self:utPort, system:utPort);
}
activate(a_default());
vc_a_cse := activate(a_cse_cf02_ae1());
vc_cse1.start(f_cf02UpCse1());
vc_cse1.done;
// Connect
//Initialze the IUT
} // end f_cf02Up
/**
@desc Ports mapping and default behaviour activation for Config 2 on the CSE1
*/
function f_cf02UpCse1() runs on CseSimu {
// Variables
var PrimitiveContent v_cSEBaseResource;
vc_config := e_cf02;
vc_testSystemRole := e_cse;
// Map
map(self:mccPort, system:mccPort);
map(self:mccPortIn, system:mccPortIn);
map(self:acPort, system:acPort);
v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
//Initialze the IUT
} // end f_cf02UpCse1
/**
* @desc Ports mapping and default behaviour activation for Config 02
*/
function f_cf02UpCseSimuMaster() runs on CseSimu {
// Variables
var PrimitiveContent v_cSEBaseResource;
vc_config := e_cf02CseSimuMaster;
vc_testSystemRole := e_cse;
vc_ae1 := AeSimu.create("AE1") alive;
//Initialization of local CSEBase
v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
// Map
map(self:mccPort, system:mccPort);
map(self:mccPortIn, system:mccPortIn);
map(self:acPort, system:acPort);
activate(a_default());
vc_a_cse := activate(a_cse_cf02_cse1());
vc_ae1.start(f_cf02UpAe1());
vc_ae1.done;
// Connect
//Initialze the IUT
} // end f_cf02UpCseSimuMaster
/**
@desc Ports mapping and default behaviour activation for Config 2 on the AE1
*/
function f_cf02UpAe1() runs on AeSimu {
// Variables
vc_config := e_cf02CseSimuMaster;
vc_testSystemRole := e_ae;
// Map
map(self:mcaPort, system:mcaPort);
map(self:mcaPortIn, system:mcaPortIn);
map(self:acPort, system:acPort);
//Initialze the IUT
} // end f_cf02UpAe1
/**
* @desc Ports mapping and default behaviour activation for Config 03
*/
function f_cf03Up() runs on CseSimu {
// Variables
var PrimitiveContent v_cSEBaseResource;
vc_config := e_cf03;
vc_testSystemRole := e_cse;
//Creation of CSEBase
v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
// Map
map(self:mcaPortIn, system:mcaPortIn);//TODO To be consistent, we should use mcaPortIn for AE testing
map(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED) {
map(self:utPort, system:utPort);
}
activate(a_default());
vc_a_ae := activate(a_ae_cf03());
// Connect
//Initialze the IUT
} // end f_cf03Up
/**
* @desc Ports mapping and default behaviour activation for Config 04
*/
function f_cf04Up() runs on CseSimu {
// Variables
var PrimitiveContent v_cSEBaseResource;
vc_config := e_cf04;
vc_testSystemRole := e_cse;
//Creation of CSEBase
v_cSEBaseResource := f_cse_generateLocalResource(-, -1, int5);
vc_cSEBaseIndex := f_setLocalResource(v_cSEBaseResource, int5, -1);
// Map
map(self:mccPort, system:mccPort);
map(self:mccPortIn, system:mccPortIn);
map(self:acPort, system:acPort);
activate(a_default());
vc_a_cse := activate(a_cse_cf04());
// Connect
//Initialize the IUT
} // end f_cf03Up
/**
* @desc Ports unmapping
*/
function f_cf01Down() runs on AeSimu {
unmap(self:mcaPort, system:mcaPort);
unmap(self:acPort, system:acPort);
if(vc_auxiliaryAe2Up) {
vc_ae2.start(f_cf01DownAe2());
vc_ae2.done;
}
}
/**
* @desc Ports unmapping
*/
function f_cf01DownAe2() runs on AeSimu {
unmap(self:mcaPort, system:mcaPort);
unmap(self:acPort, system:acPort);
unmap(self:mcaPortIn, system:mcaPortIn);
}
/**
* @desc Ports unmapping
*/
function f_cf02Down() runs on AeSimu {
unmap(self:mcaPort, system:mcaPort);
unmap(self:acPort, system:acPort);
if(PX_UT_IMPLEMENTED){
unmap(self:utPort, system:utPort);
}
unmap(vc_cse1:mccPort, system:mccPort);
unmap(vc_cse1:mccPortIn, system:mccPortIn);
unmap(vc_cse1:acPort, system:acPort);
}
/**
* @desc Ports unmapping
*/
function f_cf02DownCseSimuMaster() runs on CseSimu {
unmap(self:mccPort, system:mccPort);
unmap(self:mccPortIn, system:mccPortIn);
unmap(self:acPort, system:acPort);
unmap(vc_ae1:mcaPort, system:mcaPort);
unmap(vc_ae1:acPort, system:acPort);
}
/**
* @desc Ports unmapping for Config 03
*/
function f_cf03Down() runs on CseSimu {
unmap(self:mcaPortIn, system:mcaPortIn);
if(PX_UT_IMPLEMENTED){
unmap(self:utPort, system:utPort);
}
unmap(self:acPort, system:acPort);
}
/**
* @desc Ports unmapping for Config 04
*/
function f_cf04Down() runs on CseSimu {
unmap(self:mccPort, system:mccPort);
unmap(self:mccPortIn, system:mccPortIn);
unmap(self:acPort, system:acPort);
}
}//end group configFunctions
group InfoPortCommunication {
/**
* @desc Connection of InfoPort of two components
* @param p_tester PTC where InfoPort is to be connected
*/
function f_connectInfoPort(in Tester p_tester) runs on Tester {
// Connect
connect(self:infoPort, p_tester:infoPort);
}
/**
* @desc Disconnection of InfoPort of two components
* @param p_tester PTC where InfoPort is to be connected
*/
function f_disconnectInfoPort(in Tester p_tester) runs on Tester {
// Disconnect
disconnect(self:infoPort, p_tester:infoPort);
}
/**
* @desc Getting last responsePrimitive saved in a component
* @param p_tester Given component
*/
function f_getResponsePrimitive(in Tester p_component) runs on Tester return ResponsePrimitive {
var ResponsePrimitive v_response;
f_connectInfoPort(p_component);
p_component.start(f_sendResponsePrimitive());
alt {
[]infoPort.receive(mw_responsePrimitiveforInfoPort) -> value v_response {
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_response;
}
/**
* @desc Getting last requestPrimitive saved in an AeSimu component
* @param p_tester Given component
*/
function f_getRequestPrimitive(in Tester p_component) runs on Tester return RequestPrimitive {
var RequestPrimitive v_request;
f_connectInfoPort(p_component);
p_component.start(f_sendRequestPrimitive());
alt {
[]infoPort.receive(mw_requestPrimitiveforInfoPort) -> value v_request {
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_request;
}
/**
* @desc Getting primitiveContent retrieved in an AeSimu component
* @param p_tester AeSimu component
*/
function f_getPrimitiveContentRetrievedResource(in AeSimu p_ae) runs on Tester return PrimitiveContent {
var PrimitiveContent v_primitiveContent;
f_connectInfoPort(p_ae);
p_ae.start(f_sendPrimitiveContentRetrievedResource());
alt {
[]infoPort.receive(mw_primitiveContent) -> value v_primitiveContent {
}
}
p_ae.done;
f_disconnectInfoPort(p_ae);
return v_primitiveContent;
}
/**
* @desc Getting remoteCSE resource from a CseSimu component
* @param p_tester CseSimu component
*/
function f_getRemoteCseResource(in CseSimu p_cse) runs on Tester return integer {
var MyResource v_resource;
var integer v_resourceIndex := -1;
f_connectInfoPort(p_cse);
p_cse.start(f_sendRemoteCseResource());
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
}
}
p_cse.done;
f_disconnectInfoPort(p_cse);
return v_resourceIndex;
}
/**
* @desc Getting a specific resource from an AeSimu component
* @param p_tester AeSimu component
* @param p_resourceIndex Index of resource to be retrieved
*/
function f_getResource(in Tester p_component, in integer p_resourceIndex := -1) runs on Tester return integer {
var MyResource v_resource;
var integer v_resourceIndex := -1;
f_connectInfoPort(p_component);
p_component.start(f_sendResource(p_resourceIndex));
alt {
[]infoPort.receive(mw_resource) -> value v_resource {
v_resourceIndex := f_setResource(v_resource.resource, v_resource.resourceType, v_resource.parentIndex, false);
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_resourceIndex;
}
/**
* @desc Sending of last responsePrimitive (vc_response) through InfoPort
*/
function f_sendResponsePrimitive() runs on Tester {
infoPort.send(vc_response.primitive.responsePrimitive);
}
/**
* @desc Sending of last requestPrimitive (vc_request) through InfoPort
*/
function f_sendRequestPrimitive() runs on Tester {
infoPort.send(vc_request.primitive.requestPrimitive);
}
/**
* @desc Sending of last primitiveContent retrieved (vc_primitiveContentRetrievedResource) through InfoPort
*/
function f_sendPrimitiveContentRetrievedResource() runs on AeSimu {
infoPort.send(vc_primitiveContentRetrievedResource);
}
/**
* @desc Sending of remoteCSE resource through InfoPort
*/
function f_sendRemoteCseResource() runs on CseSimu {
infoPort.send(vc_resourcesList[vc_remoteCseIndex]);
}
/**
* @desc Sending of Ae resource through InfoPort
*/
function f_sendAeResource() runs on AeSimu {
infoPort.send(vc_resourcesList[vc_aeAuxIndex]);
}
/**
* @desc Sending of a specific resource through InfoPort
* @param p_resourceIndex Index of resource to be sent
*/
function f_sendResource(in integer p_resourceIndex) runs on Tester {
if(p_resourceIndex == -1) {
infoPort.send(vc_resourcesList[vc_aeAuxIndex]); //TODO To send Ae or RemoteCSE depending on the component type
} else {
infoPort.send(vc_resourcesList[p_resourceIndex]);
}
}
}// end of gropu InfoPortCommunication
group CseFunctions {
group PreambleFunctions {
/**
* @desc Creation of auxiliar resources ACP for correct execution of the test case
* @param p_allowedOperations Allowed operations for the auxiliar AE resource
* @return Internal ACP resource index
* @verdict
*/
function f_cse_preamble_createAcpAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) AccessControlOperations p_allowedOperations := int63) runs on AeSimu return integer {//c_CRUDNDi
return f_cse_createAccessControlPolicyAux(p_acpName, -, p_allowedOperations);
}
/**
* @desc Creation of auxiliar resource AE for correct execution of the test case
* @param p_accessControlPolicyIDs AccessControlPolicyIDs for the auxiliar AE resource
* @param p_poaList Point of contact of the auxiliar AE resource
* @return Internal AE resource index
* @verdict
*/
function f_cse_preamble_registerAe(template (omit) AcpType p_accessControlPolicyIDs := omit, in template (omit) PoaList p_poaList := omit) runs on AeSimu return integer {//c_CRUDNDi
var RequestPrimitive v_request;
var MsgIn v_response;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
v_request := valueof(m_createAeAux(p_accessControlPolicyIDs, p_poaList));
v_request := f_getCreateRequestPrimitive(int2, v_request, -1);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
tc_ac.stop;
setverdict(pass,__SCOPE__&":INFO: Application registered successfuly");
if(ischosen(v_response.primitive.responsePrimitive.primitiveContent.aE)) {
f_checkAttributesToBeSaved(int2, v_request, v_response.primitive.responsePrimitive);
vc_aeAuxIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int2);
if(ispresent(v_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)){
f_sendAcPrimitive("AE-ID_changed", oct2char(unichar2oct(v_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)));
} else {
f_sendAcPrimitive("AE-ID_changed", "0");
}
}
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
stop;
}
[] mcaPort.receive {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
stop;
};
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
stop;
}
}
f_checkAeSimuStatus();
return vc_aeAuxIndex;
}
/**
* @desc Creation of auxiliar resources ACP and AE for correct execution of the test case
* @param p_allowedOperations Allowed operations for the auxiliar AE resource
* @param p_appId AppID of the AE resource to be created
* @return Internal AE resource index
* @verdict
*/
function f_cse_preamble_registerAeWithId(XSD.ID p_appId, in template (value) AccessControlOperations p_allowedOperations := int63) runs on AeSimu return integer {//c_CRUDNDi
var RequestPrimitive v_request;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
if(PICS_ACP_SUPPORT){
vc_acpAuxIndex := f_cse_createAccessControlPolicyAux(p_allowedOperations := p_allowedOperations);
}
if(vc_acpAuxIndex != -1) {
vc_resourcesIndexToBeDeleted := {vc_acpAuxIndex};
v_request := valueof(m_createAe(p_appId, {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)}, -));
//TODO Test, to be removed
v_request.to_ := f_getResourceAddress();
mcaPort.send(m_request(v_request));
//mcaPort.send(m_request(m_createAeAux(p_name, {PX_URI_CSE & PX_CSE_NAME & "/" & PX_ACPAUX_NAME})));
} else {
mcaPort.send(m_request(m_createAe(p_appId)));
}
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&": INFO: Application registered successfuly");
if(ischosen(vc_response.primitive.responsePrimitive.primitiveContent.aE)) {
vc_aeAuxIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, int2);
if(ispresent(vc_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)){
f_sendAcPrimitive("AE-ID_changed", oct2char(unichar2oct(vc_response.primitive.responsePrimitive.primitiveContent.aE.aE_ID)));
} else {
f_sendAcPrimitive("AE-ID_changed", "0");
}
}
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO))
{
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
stop;
}
[] mcaPort.receive {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
stop;
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
stop;
}
}
f_checkAeSimuStatus();
return vc_aeAuxIndex;
}
/**
* @desc Creation of ServiceSubscribedAppRule resource
* @param p_allowedAEs Allowed AEs
* @return Internal resource index
* @verdict
*/
function f_cse_preamble_createServiceSubscribedAppRule(in template ListOfM2MID p_allowedAEs := {""}) runs on AeSimu return integer {//c_CRUDNDi
var integer v_serviceSubscribedAppRuleIndex := -1;
v_serviceSubscribedAppRuleIndex := f_cse_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
return v_serviceSubscribedAppRuleIndex;
}
/**
* @desc Creation of SubscribedProfile resource
* @param p_allowedAEs Allowed AEs
* @return Internal resource index
* @verdict
*/
function f_cse_preamble_createServiceSubscribedProfile(in template ListOfM2MID p_allowedAEs := {""}) runs on AeSimu return integer {//c_CRUDNDi
var integer v_serviceSubscribedAppRuleIndex := -1;
var integer v_serviceSubscribedProfileIndex := -1;
var template RequestPrimitive m_request := m_createM2mServiceSubscriptionProfileBase;
//TODO Create/Update serviceSubscribedNode //m_request.primitiveContent.m2mServiceSubscriptionProfile.choice.choice_list[0].serviceSubscribedNode := m_contentServiceSubscribedNode;
v_serviceSubscribedAppRuleIndex := f_cse_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
m_request.primitiveContent.m2mServiceSubscriptionProfile.choice.choice_list[0].serviceSubscribedNode.ruleLinks := {f_getResourceAddress(v_serviceSubscribedAppRuleIndex)};
v_serviceSubscribedProfileIndex := f_cse_createResource(int11, m_request);
return v_serviceSubscribedProfileIndex;
}
/**
* @desc Registration of AE2 for handling of notifications and handling of subscription verification started if subscription resource is to be created
* @param p_ae2Index Internal AE2 resource index
* @param p_createRequestPrimitive CREATE Request for the resource to be created
* @param p_resourceType ResourceType of the resource to be created
* @param p_responseStatusCode Response Status Code to be sent in response to the subscription verification request
* @verdict
*/
function f_cse_preamble_subscriptionVerification(inout integer p_ae2Index, inout template RequestPrimitive p_createRequestPrimitive,in ResourceType p_resourceType, in ResponseStatusCode p_responseStatusCode := int2000) runs on AeSimu {
if(p_resourceType == int23){
vc_ae2.start(f_cse_createAccessControlPolicyAux("SubscriptionVerificationAcp",{"all"}, int63));
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
vc_ae2.start(f_cse_createResource_withAcpAux(int2, m_createAe(PX_APP_ID, -, PX_AE2_ID_STEM, c_defaultAE2Name, {f_getAnnouncementTargetPoA("HTTP", PX_AE2_ADDRESS, "")}), -1)); // AE2 is registred
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
p_ae2Index := f_getResource(vc_ae2);
if(ischosen(p_createRequestPrimitive.primitiveContent.subscription)){ //this condition is necessary for Subscription TCs where notification URI is set in m_createSubscriptionAdvanced
p_createRequestPrimitive.primitiveContent.subscription.notificationURI := {f_getResourceAddress(p_ae2Index)};
}
vc_ae2.start(f_cse_notifyProcedure_subscriptionVerificationHandler(p_responseStatusCode));
}
}
}//end group preambleFunctions
group PostambleFunctions {
/**
* @desc Deletion of all resources created during the test case execution. It deals also with AE2 created resources if any. IUT gets clean and ready for next execution
* @verdict
*/
function f_cse_postamble_deleteResources() runs on AeSimu {
var integer i;
var XSD.ID v_resourceAddress;
var RequestPrimitive v_request;
if (PX_RUN_POSTAMBLE) {
if(vc_config == e_cf02) {
if(vc_cse1.alive) {
f_cse_postamble_cse1();
}
}
if(vc_auxiliaryAe2Up) {
if (vc_ae2.alive) {
f_cse_postamble_aeSimu(vc_ae2);
}
}
for(i := lengthof(vc_resourcesIndexToBeDeleted) -1; i >=0; i := i - 1) {
v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i]);
v_request := valueof(m_delete(v_resourceAddress, f_getOriginator(vc_resourcesIndexToBeDeleted[i])));
v_request.from_ := f_getOriginator(vc_resourcesIndexToBeDeleted[i]);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
log(__SCOPE__&" INFO: Resource " & v_request.to_ & " deleted");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
log(__SCOPE__&" INFO: Error while deleting resource " & v_request.to_);
}
[] tc_ac.timeout {
log(__SCOPE__&" INFO: No answer while deleting resource " & v_request.to_);
}
}
}
}
}
/**
* @desc Calls to postamble for AeSimu components (i.e. AE2)
* @verdict
*/
function f_cse_postamble_aeSimu(in AeSimu p_ae) runs on AeSimu {
if(p_ae.running) {
p_ae.stop;
}
p_ae.start(f_cse_postamble_deleteResources());
p_ae.done;
}
/**
* @desc Calls to postamble for AeSimu component (i.e. AE1) on CseSimu
* @verdict
*/
function f_cse_postamble_ae1() runs on CseSimu {
if(vc_ae1.running) {
vc_ae1.stop;
}
vc_ae1.start(f_cse_postamble_deleteResources());
vc_ae1.done;
}
/**
* @desc Calls to postamble for CseSimu component (i.e. CSE1) on AeSimu
* @verdict
*/
function f_cse_postamble_cse1() runs on AeSimu {
if(vc_cse1.running) {
vc_cse1.stop;
}
vc_cse1.start(f_cse_postamble_deleteResourcesCSE());
vc_cse1.done;
}
/**
* @desc Deletion of all resources created during the test case execution. IUT gets clean and ready for next execution
* @verdict
*/
function f_cse_postamble_deleteResourcesCSE() runs on CseSimu {
var integer i;
var XSD.ID v_resourceAddress;
var RequestPrimitive v_request;
if (PX_RUN_POSTAMBLE) {
if(vc_config == e_cf02CseSimuMaster) {
if(vc_ae1.alive) {
f_cse_postamble_ae1();
}
};
for(i := lengthof(vc_resourcesIndexToBeDeleted) -1; i >=0; i := i - 1) {
if(ischosen(vc_resourcesList[vc_resourcesIndexToBeDeleted[i]].resource.remoteCSE) and PX_MN_CSE) {
v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i], e_nonHierarchical, e_spRelative);
} else {
v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i]);
}
v_request := valueof(m_delete(v_resourceAddress, f_getOriginator(vc_resourcesIndexToBeDeleted[i],false)));
mccPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
log(__SCOPE__&" INFO: Resource " & v_request.to_ & " deleted");
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
log(__SCOPE__&" INFO: Error while deleting resource " & v_request.to_);
}
[] tc_ac.timeout {
log(__SCOPE__&" INFO: No answer while deleting resource " & v_request.to_);
}
}
}
}
}
}//end group postambleFunctions
group AeSimuFunctions {
/**
* @desc Creation of a resource
* @param p_resourceType Resource type of the resource to be created
* @param p_requestPrimitive CREATE request primitive for the resource to be created
* @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
* @return Internal resource index of the created resource
* @verdict
*/
function f_cse_createResource(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on AeSimu return integer {
var RequestPrimitive v_request;
var integer v_resourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(enum2int(p_resourceType)) & " created successfuly");
f_checkAttributesToBeSaved(p_resourceType, v_request, vc_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_resourceType, p_parentIndex);
if(p_resourceType == int2) {
vc_aeAuxIndex := v_resourceIndex;
}
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(enum2int(p_resourceType)));
}
[] mcaPort.receive {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(enum2int(p_resourceType)));
}
}
f_checkAeSimuStatus();
return v_resourceIndex;
}
/**
* @desc Creation of a resource
* @param p_resourceType Resource type of the resource to be created
* @param p_requestPrimitive CREATE request primitive for the resource to be created
* @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
* @return Internal resource index of the created resource
* @verdict
*/
function f_cse_createResource_withAcpAux(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on AeSimu return integer {
var RequestPrimitive v_request;
var integer v_resourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
if(vc_acpAuxIndex != -1) {
p_requestPrimitive := f_setAcpId(p_requestPrimitive, {vc_resourcesList[vc_acpAuxIndex].resource.accessControlPolicy.resourceID});
}
v_resourceIndex := f_cse_createResource(p_resourceType, p_requestPrimitive, p_parentIndex);
return v_resourceIndex;
}
/**
* @desc Message exchange for the update of an announced resource
* @param p_requestPrimitive UPDATE request primitive to be used
* @verdict
*/
function f_cse_updateAnnouncedResource(in RequestPrimitive p_requestPrimitive) runs on CseSimu {
mccPort.send(m_request(p_requestPrimitive));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Attribute of announced resource updated successfuly");
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while updating announced resource");
}
[] mccPort.receive{
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while updating announced resource");
}
}
f_checkCseSimuStatus();
}// end f_cse_updateAnnouncedResource
/**
* @desc Creation of the auxiliar ACP resource
* @param p_acpName ACP name
* @param p_allowedOperations Allowed operations
* @return Internal resource index of the created auxiliar ACP resource
* @verdict
*/
function f_cse_createAccessControlPolicyAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) ListOfURIs p_acor := PX_ACOR, in template (value) AccessControlOperations p_allowedOperations := int63) runs on AeSimu return integer{ var RequestPrimitive v_request;
var integer v_acpAuxIndex := -1;
v_request := valueof(m_createAcpAux(p_acpName := p_acpName, p_acor := p_acor, p_allowedOperations := p_allowedOperations));
v_request := f_getCreateRequestPrimitive(int1, v_request, -1);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(1) & " created successfuly");
f_checkAttributesToBeSaved(int1, v_request, vc_response.primitive.responsePrimitive);
v_acpAuxIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, int1);
vc_acpAuxIndex := v_acpAuxIndex;
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(1));
}
[] mcaPort.receive {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(1));
}
}
f_checkAeSimuStatus();
return v_acpAuxIndex;
}
/**
* @desc Message exchange for the update of a resource
* @param p_requestPrimitive UPDATE request primitive to be used
* @verdict
*/
function f_cse_updateResource(in RequestPrimitive p_requestPrimitive) runs on AeSimu {
mcaPort.send(m_request(p_requestPrimitive));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Attribute of resource updated successfuly");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while updating resource");
}
[] mcaPort.receive{
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while updating resource");
}
}
f_checkAeSimuStatus();
}// end f_cse_updateResource
/**
* @desc Message exchange for the retrieval of a resource
* @param p_resourceIndex Resource index of the resource to be retrieved
* @return PrimitiveContent parameter of the RETRIEVE response
* @verdict
*/
function f_cse_retrieveResource(integer p_resourceIndex) runs on AeSimu return PrimitiveContent{
mcaPort.send(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while retrieving resource");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while retrieving resource");
}
}
f_checkAeSimuStatus();
return vc_response.primitive.responsePrimitive.primitiveContent;
}// end f_cse_retrieveResource
/**
* @desc Message exchange for the deletion of a resource
* @param p_index Resource index of the resource to be deleted
* @param p_requestPrimitive DELETE request to be used. If not present default DELETE request will be used
* @verdict
*/
function f_cse_deleteResource(in integer p_index, in template (omit) RequestPrimitive p_requestPrimitive := omit) runs on AeSimu {
var RequestPrimitive v_request;
if(not isvalue(p_requestPrimitive)) {
v_request := valueof(m_delete(f_getResourceAddress(p_index), f_getOriginator(p_index)));
} else {
v_request := valueof(p_requestPrimitive);
}
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
setverdict(pass, __SCOPE__&"INFO: Resource " & v_request.to_ & " deleted");
f_removeElementFromList(vc_resourcesIndexToBeDeleted, p_index);
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&"INFO: Error while deleting resource " & v_request.to_);
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&"INFO: No answer while deleting resource " & v_request.to_);
}
}
f_checkAeSimuStatus();
}// end f_cse_deleteResource
/**
* @desc Check that a resource is present in the IUT (resourceId is known) by using RETRIEVE operation
* @param p_resourceIndex Resource index of the resource to be checked
* @return boolean
*/
function f_isResourcePresent (integer p_resourceIndex) runs on AeSimu return boolean {
//Check to see if the resource is present or not
mcaPort.send(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int2000))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource present: " & f_getResourceAddress(p_resourceIndex));
return true;
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(int4004))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource: " & f_getResourceAddress(p_resourceIndex) & " not found");
return false;
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?, -))) {
tc_ac.stop;
setverdict(inconc, testcasename() & ": Wrong response status code in the response");
return false;
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while retrieving resource");
return false;
}
}
return false;
}
/**
* @desc Check that a resource is not present in the IUT (resourceId is NOT known)
* @param p_parentIndex Index of the parent resource of the resource to be checked
* @param p_resourceName Resource name (Hierarchical method is used) of the resource to be checked
* @return boolean
*/
function f_isResourceNotPresent (integer p_parentIndex, XSD.String p_resourceName) runs on AeSimu return boolean {
log(testcasename() & ":INFO: Hierarchical addressing method is required to check the non presence of the resource");
//Check to see if the resource has NOT been created
mcaPort.send(m_request(m_retrieve(f_getResourceAddress(p_parentIndex, e_hierarchical) & "/" & p_resourceName, f_getOriginator(p_parentIndex))));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitive(int4004))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource not present");
return true;
}
[] mcaPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(inconc, testcasename() & ": Wrong response status code in the response");
return false;
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while retrieving resource");
return false;
}
}
return false;
}
/**
* @desc Message exchange for the update of the auxiliar ACP resource
* @param p_allowedOperations New allowed operations
* @verdict
*/
function f_cse_updateAcpAuxResource (in template (value) AccessControlOperations p_allowedOperations) runs on AeSimu {
var RequestPrimitive v_request;
v_request := valueof(m_updateAcpBase);
v_request.requestIdentifier := valueof(v_request.requestIdentifier) & f_rnd(1, 1000000);
v_request.to_ := f_getResourceAddress(vc_acpAuxIndex);
v_request.from_ := f_getOriginator(vc_acpAuxIndex);
v_request.primitiveContent.accessControlPolicy.privileges.accessControlRule_list := {valueof(m_createAcr(PX_ACOR, p_allowedOperations))};
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: " & v_request.to_ & " resource updated successfuly");
//TODO To save new values
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while updating " & v_request.to_ & " resource");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while updating " & v_request.to_ & " resource" );
}
}
f_checkAeSimuStatus();
}
/**
* @desc Checking of returned important attributed (in response) in order to save properly internally
* @param p_resourceType ResourceType of the resource to be checked
* @param p_request Request primitive used for the CRU operation
* @param p_response Response primitive received
* @verdict
*/
//Note: This function will be continously extended with necessary attributes/resources
function f_checkAttributesToBeSaved (ResourceType p_resourceType, RequestPrimitive p_request, inout ResponsePrimitive p_response) {
select (p_resourceType) {
case (int1) {
if(isvalue(p_response.primitiveContent.accessControlPolicy) and
not(ispresent(p_response.primitiveContent.accessControlPolicy.resourceName))) {
p_response.primitiveContent.accessControlPolicy.resourceName := p_request.primitiveContent.accessControlPolicy.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.accessControlPolicy.resourceName)
}
}
case (int2) {
if(isvalue(p_response.primitiveContent.aE) and
not(ispresent(p_response.primitiveContent.aE.resourceName))) {
p_response.primitiveContent.aE.resourceName := p_request.primitiveContent.aE.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.aE.resourceName)
}
}
case (int3) {
if(isvalue(p_response.primitiveContent.container) and
not(ispresent(p_response.primitiveContent.container.resourceName))) {
p_response.primitiveContent.container.resourceName := p_request.primitiveContent.container.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.container.resourceName)
}
}
case (int4) {
if(isvalue(p_response.primitiveContent.contentInstance) and
not(ispresent(p_response.primitiveContent.contentInstance.resourceName))) {
p_response.primitiveContent.contentInstance.resourceName := p_request.primitiveContent.contentInstance.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.contentInstance.resourceName)
}
}
case (int15) {
if (isvalue(p_response.primitiveContent.pollingChannel) and
not(ispresent(p_response.primitiveContent.pollingChannel.resourceName))) {
p_response.primitiveContent.pollingChannel.resourceName := p_request.primitiveContent.pollingChannel.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.pollingChannel.resourceName)
}
}
case (int16) {
if (isvalue(p_response.primitiveContent.remoteCSE) and
not(ispresent(p_response.primitiveContent.remoteCSE.resourceName))) {
p_response.primitiveContent.remoteCSE.resourceName := p_request.primitiveContent.remoteCSE.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.remoteCSE.resourceName)
}
}
case (int18) {
if (isvalue(p_response.primitiveContent.schedule) and
not(ispresent(p_response.primitiveContent.schedule.resourceName))) {
p_response.primitiveContent.schedule.resourceName := p_request.primitiveContent.schedule.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.schedule.resourceName)
}
}
case (int23) {
if (isvalue(p_response.primitiveContent.subscription) and
not(ispresent(p_response.primitiveContent.subscription.resourceName))) {
p_response.primitiveContent.subscription.resourceName := p_request.primitiveContent.subscription.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.subscription.resourceName)
}
}
case (int9) {
if (isvalue(p_response.primitiveContent.group_) and
not(ispresent(p_response.primitiveContent.group_.resourceName))) {
p_response.primitiveContent.group_.resourceName := p_request.primitiveContent.group_.resourceName;
log(__SCOPE__ & ":INFO: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.group_.resourceName)
}
}
case else {
log(__SCOPE__&":WARNING: Resource Type "&int2str(enum2int(p_resourceType))&" not implemented");
}
}
// TODO test that if the resource name is returned is the same resource name as used in the create message
}
/**
* @desc Comparison of two URIs
* @param p_expectedURIIndex Resource index of the resource for which its URI is to be compared
* @param p_receivedURI URI to be compared
* @param p_response Response primitive received
* @verdict
*/
function f_compareURIs(in integer p_expectedURIIndex, in XSD.ID p_receivedURI) runs on Tester return boolean{
// Local variables
var boolean v_matchResult := false;
var AddressingMethod v_addressingMethod;
var PrimitiveScope v_primitiveScope;
if (f_isNonHierarchical(p_receivedURI)) {
v_addressingMethod := e_nonHierarchical;
} else if (f_isHierarchical(p_receivedURI)) {
v_addressingMethod := e_hierarchical;
}
if (f_isScopeCseRelative(p_receivedURI)) {
v_primitiveScope := e_cseRelative;
}
if (f_isScopeSpRelative(p_receivedURI)) {
v_primitiveScope := e_spRelative;
}
if (f_isScopeAbsolute(p_receivedURI)) {
v_primitiveScope := e_absolute;
}
if(match(f_getResourceAddress(p_expectedURIIndex, v_addressingMethod, v_primitiveScope), p_receivedURI)) {
v_matchResult := true;
} else {
v_matchResult := false;
}
return v_matchResult;
} //end f_compareURIs
/**
* @desc Sending a request primitive on mcaPort on AeSimu
* @param p_resourceType Resource type of the resource to be created
* @param p_requestPrimitive CREATE request primitive for the resource to be created
* @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
* @return Internal resource index of the created resource
* @verdict
*/
function f_cse_sendCreateRequestPrimitive(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on AeSimu{
var RequestPrimitive v_request;
var integer v_resourceIndex := -1;
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
mcaPort.send(m_request(v_request));
}
}//end group AeSimu
group CseSimuFunctions {
group NotificationFunctions {
/**
* @desc Handling message exchange for the subscription verification
* @param p_responseStatusCode Response Status Code to be used for the response to the verification request
* @verdict
*/
function f_cse_notifyProcedure_subscriptionVerificationHandler(in ResponseStatusCode p_responseStatusCode := int2000) runs on AeSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
var template Notification v_notificationRequest := mw_contentNotificationVerification;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
//Preparation of expected Notification verification
//TODO To add checks for creator and subscription reference
//v_notificationRequest.creator := p_creator; TODO To check what address format is to be expected
//Some participants use SP relative UNSTRUCTURED
//v_notificationRequest.subscriptionReference := "I Don't know which URI is expected"; // TODO mandatory parameter
//Preparation of Notification response to be sent
v_responsePrimitive := valueof(m_responseNotification(p_responseStatusCode, omit));
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyNotification(v_notificationRequest))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
}
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: Notification received but verificationRequest isn't set to TRUE");
}
[] mcaPortIn.receive{
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
stop;
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
stop;
}
}
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
if(getverdict == pass) {
mcaPortIn.send(m_httpResponse(v_responsePrimitive));
} else {
v_responsePrimitive.responseStatusCode := int4000;
mcaPortIn.send(m_httpResponse(v_responsePrimitive));
}
//mcaPort.send(m_response(v_responsePrimitive)); // TODO have to be deleted
} //end f_subscriptionVerificationHandler
/**
* @desc Default handling message exchange for the notification procedure
* @verdict
*/
function f_cse_notifyProcedure_defaultHandler() runs on AeSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
//Send response in any case
v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
mcaPortIn.send(m_response(v_responsePrimitive));
tc_ac.start;
repeat;
}
[] mcaPortIn.receive{
tc_ac.stop;
setverdict(inconc, __SCOPE__ & ":ERROR: unexpected message received");
tc_ac.start;
repeat;
}
}
} //end f_cse_notifyProcedure_defaultHandler
/**
* @desc Handling message exchange for the notification procedure
* @param p_primitiveContent Expected primitiveContent in the notification
* @verdict
*/
function f_cse_notifyProcedure_representationHandler(template PrimitiveContent p_primitiveContent) runs on AeSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
tc_ac.stop;
if(f_check_notificationContent(vc_request.primitive.requestPrimitive, p_primitiveContent)){
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
}
else{
setverdict(fail, __SCOPE__ & ":ERROR: Notification received but the content doesn't match");
}
//Send response in any case
v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
mcaPortIn.send(m_response(v_responsePrimitive));
}
[] mcaPortIn.receive{
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
}
}
} //end f_cse_notifyProcedure_representationHandler
/**
* @desc Handling message exchange for the notification procedure (aggregatedNotification)
* @param p_primitiveContent Expected primitiveContent in the notification
* @verdict
*/
function f_cse_notifyProcedure_aggregatedNoficationHandler(template PrimitiveContent p_primitiveContent,in integer p_numberOfAggregatedNotification) runs on AeSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
var integer v_notificationsReceived := 0;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyAggregatedNotification)) -> value vc_request {
tc_ac.stop;
if(p_numberOfAggregatedNotification == lengthof(vc_request.primitive.requestPrimitive.primitiveContent.aggregatedNotification.notification_list)){
if(f_check_notificationContent(vc_response.primitive.requestPrimitive, p_primitiveContent)){
setverdict(pass, __SCOPE__ & ": Notification received");
}
else{
setverdict(fail, __SCOPE__ & ": Notification received but the content doesn't match");
}
}
else {
setverdict(fail, __SCOPE__ & ": Number of Notification in Aggregatednotification isn't right");
}
//Send response in any case
v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
mcaPortIn.send(m_response(v_responsePrimitive));
}
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
tc_ac.stop;
if(f_check_notificationContent(vc_request.primitive.requestPrimitive, p_primitiveContent)){
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
}
else{
setverdict(fail, __SCOPE__ & ":ERROR: Notification received but the content doesn't match");
}
//Send response in any case
v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
mcaPortIn.send(m_response(v_responsePrimitive));
v_notificationsReceived := v_notificationsReceived + 1;
if(v_notificationsReceived < p_numberOfAggregatedNotification) {
tc_ac.start;
repeat;
}
}
[] mcaPortIn.receive{
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Error, unexpected message received");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ": No notification received");
}
}
} //end f_cse_notifyProcedure_aggregatedNotificationHandler
/**
* @desc Handling message exchange for the notification procedure (deletion of subscription resource)
* @param p_notification Expected notification
* @verdict
*/
function f_cse_notifyProcedure_subscriptionDeletionHandler( template Notification p_notification) runs on AeSimu {
var ResponsePrimitive v_responsePrimitive;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_notifyNotification(p_notification))) -> value vc_request {
tc_ac.stop;
v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
mcaPortIn.send(m_response(v_responsePrimitive));
if(not(match(vc_request.primitive.requestPrimitive.primitiveContent.notification.subscriptionDeletion, true))) {
setverdict(fail, __SCOPE__ & ":ERROR: subscriptionDeletion attribute have to be set to TRUE");
}
}
[] mcaPortIn.receive{
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
}
}
} //end f_cse_notifyProcedure_subscriptionDeletionHandler
/**
* @desc Handling message exchange for the notification procedure (no notification expected)
* @verdict
*/
function f_cse_notifyProcedure_noNotificationHandler() runs on AeSimu {
// Local variables
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
tc_ac.start(10.0);
alt {
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
tc_ac.stop;
setverdict(fail, __SCOPE__ & ": Error, Non expected notification received");
}
[] tc_ac.timeout {
setverdict(pass, __SCOPE__ & ": No notification received");
}
}
} //end f_cse_notifyProcedure_noNotification Handler
/**
* @desc Checking of notification primitiveContent
* @param p_requestPrimitive Received Notification request
* @param p_primitiveContent Expected primitiveContent in the notification
* @verdict
*/
function f_check_notificationContent(in RequestPrimitive p_requestPrimitive, template PrimitiveContent p_primitiveContent) runs on Tester return boolean{
// Local variables
var boolean v_matchResult := false;
var integer i;
var integer v_numberOfAggregatedNotification;
if (ischosen(p_primitiveContent.aE)){
log("Representation contains AE resource representation");
if(isvalue(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.aE)) {
v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.aE, p_primitiveContent.aE);
log("Expected primitiveContent");
}
else if(isvalue(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.aE)) {
v_matchResult :=match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.aE, p_primitiveContent.aE);
}
else if (isvalue(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list)) {
v_matchResult := true;
v_numberOfAggregatedNotification := lengthof(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list);
for(i := 0; i< v_numberOfAggregatedNotification; i := i + 1){
if(isvalue(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource.aE)) {
if(not (match(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource.aE, p_primitiveContent.aE))){
v_matchResult := false;
}
}
else if(isvalue(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.responsePrimitive.primitiveContent.aE)) {
if(not (match(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.responsePrimitive.primitiveContent.aE, p_primitiveContent.aE))){
v_matchResult := false;
}
}
}
if (i == 0){
v_matchResult := false;
}
}
}
if (ischosen(p_primitiveContent.container)){
if(isvalue(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.container)) {
v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.container, p_primitiveContent.container)
}
else if(isvalue(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.container)) {
v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.container, p_primitiveContent.container)
}
}
return v_matchResult;
} //end f_check_notificationContent
}// end of group NotificationFunctions
group AnnouncementFunctions {
/**
* @desc Handling of announcement of resources
* @param p_from Expected originator of the request primitive
* @param p_to Expected receiver of the request primitive
* @verdict
*/
//TODO To finalize this function
function f_cse_announcementProcedure_createHandler(template RequestPrimitive p_requestprimitive := ?) runs on CseSimu {
// Local variables
var MsgIn v_request;
var integer v_parentIndex := vc_localRemoteCseIndex;
var integer v_announcedResourceIndex;
var ResponsePrimitive v_responsePrimitive;
var PrimitiveContent v_announcedResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_requestprimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Announcement received");
//TODO Save resource and generate required attributes
v_announcedResource:= f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentIndex,v_request.primitive.requestPrimitive.resourceType);
v_announcedResourceIndex := f_setLocalResource(v_announcedResource, v_request.primitive.requestPrimitive.resourceType, v_parentIndex);
v_responsePrimitive := valueof(m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier));
v_responsePrimitive.from_ := PX_CSE1_ID;
v_responsePrimitive.to_ := v_request.primitive.requestPrimitive.from_;
v_responsePrimitive.primitiveContent := vc_localResourcesList[v_announcedResourceIndex].resource;
mccPortIn.send(m_response(v_responsePrimitive));
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No announcement received");
}
}
f_checkCseSimuStatus();
} //end f_cse_resourceAnnouncementHandler
/**
* @desc Message exchange for the announcement of resources
* @param p_resourceType ResourceType of the resource to be announced
* @param p_requestPrimitive CREATE request to be used for the announcement
* @verdict
*/
//TODO To finalize this function
function f_cse_announcementProcedure_announceResource(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create) runs on CseSimu return integer {
// Local variables
var RequestPrimitive v_request;
var ResponsePrimitive v_responsePrimitive;
var integer v_resourceIndex := -1;
v_request := f_getCreateRequestPrimitive(f_getAnnouncedResourceType(p_resourceType), p_requestPrimitive, vc_remoteCseIndex);
mccPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(enum2int(p_resourceType)) & " created successfuly");
f_checkAttributesToBeSaved(p_resourceType, v_request, vc_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, f_getAnnouncedResourceType(p_resourceType), vc_remoteCseIndex);
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(enum2int(p_resourceType)));
}
[] mccPort.receive {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(enum2int(p_resourceType)));
}
}
f_checkCseSimuStatus();
return v_resourceIndex;
} //end f_cse_announceResource
/**
* @desc Handling message exchange for the AE Annc update
* @verdict
*/
//TODO TO BE FINALIZED
function f_cse_announcementProcedure_updateHandler() runs on CseSimu {
// Local variables
var ResponsePrimitive v_responsePrimitive;
var template Notification v_notificationRequest := mw_contentNotification_any;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
//Preparation of Notification response to be sent
v_responsePrimitive := valueof(m_responseNotification(int2004, omit));
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(mw_notifyNotification(v_notificationRequest))) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__ & ":INFO: Notification received");
}
[] mccPortIn.receive{
tc_ac.stop;
setverdict(fail, __SCOPE__ & ":ERROR: unexpected message received");
stop;
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__ & ":ERROR: No notification received");
stop;
}
}
v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
if(getverdict == pass) {
mccPortIn.send(m_httpResponse(v_responsePrimitive));
} else {
v_responsePrimitive.responseStatusCode := int4000;
mccPortIn.send(m_httpResponse(v_responsePrimitive));
}
} //end f_cse_notifyProcedure_updateHandler
}//end of group AnnouncementFunctions
/**
* @desc Check that a resource is present in the IUT (resourceId is known)
* @param p_resourceIndex Resource index
* @return boolean
*/
function f_cse_isResourcePresent (integer p_resourceIndex) runs on CseSimu return boolean {
//Check to see if the resource is present or not
mccPort.send(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitive(int2000))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource present: " & f_getResourceAddress(p_resourceIndex));
return true;
}
[] mccPort.receive(mw_response(mw_responsePrimitive(int4004))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource: " & f_getResourceAddress(p_resourceIndex) & " not found");
return false;
}
[] mccPort.receive(mw_response(mw_responsePrimitive(?, -))) {
tc_ac.stop;
setverdict(inconc, testcasename() & ": Wrong response status code in the response");
return false;
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while retrieving resource");
return false;
}
}
return false;
}
/**
* @desc Check that a resource is not present in the IUT (resourceId is NOT known)
* @param p_parentIndex Index of the parent resource of the resource to be checked
* @param p_resourceName Resource name (Hierarchical method is used) of the resource to be checked
* @return boolean
*/
function f_cse_isResourceNotPresent (integer p_parentIndex, XSD.String p_resourceName) runs on CseSimu return boolean {
log(testcasename() & ":INFO: Hierarchical addressing method is required to check the non presence of the resource");
//Check to see if the resource has NOT been created
mccPort.send(m_request(m_retrieve(f_getResourceAddress(p_parentIndex, e_hierarchical) & "/" & p_resourceName, f_getOriginator(p_parentIndex))));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitive(int4004))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource not present");
return true;
}
[] mccPort.receive(mw_response(mw_responsePrimitive(int2000))) {
tc_ac.stop;
setverdict(pass, testcasename() & ": Resource " & p_resourceName & " present");
return false;
}
[] mccPort.receive(mw_response(mw_responsePrimitive(?))) {
tc_ac.stop;
setverdict(inconc, testcasename() & ": Wrong response status code in the response");
return false;
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while retrieving resource");
return false;
}
}
return false;
}
/**
* @desc Registration of Test System (simulating a CSE) to the CSE IUT (creation of remoteCSE)
* @param p_requestPrimitive Template request primitive
* @param p_primitiveContent Expected primitiveContent in the CREATE response primitive
* @return Internal resource index of the created resource
*/
function f_cse_registerRemoteCse(in template RequestPrimitive p_requestPrimitive, in template PrimitiveContent p_contentResponse := ?) runs on CseSimu return integer {
var MsgIn v_response;
var RequestPrimitive v_request;
var PrimitiveContent v_remoteCSEResource;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
v_request := f_getCreateRequestPrimitive(int16, p_requestPrimitive, -1);
mccPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK(p_contentResponse))) -> value v_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type remoteCSE created successfuly");
f_checkAttributesToBeSaved(int16, v_request, v_response.primitive.responsePrimitive);
vc_remoteCseIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int16, -1);
v_remoteCSEResource := f_cse_generateLocalResource(v_response.primitive.responsePrimitive.primitiveContent, vc_cSEBaseIndex, int16);
vc_localRemoteCseIndex := f_setLocalResource(v_remoteCSEResource, int16, vc_cSEBaseIndex);
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type remoteCSE");
}
[] mccPort.receive {
tc_ac.stop;
setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type remoteCSE");
}
}
f_checkCseSimuStatus();
return vc_remoteCseIndex;
}
/**
* @desc Registration of the CSE IUT to the Test System (simulating a CSE)
* @param p_requestPrimitive Template request primitive
* @return Internal resource index of the created resource
*/
function f_cse_registrationRemoteCse(in template RequestPrimitive p_requestPrimitive := ?) runs on CseSimu return integer {
var MsgIn v_request;
var ResponsePrimitive v_response;
var PrimitiveContent v_remoteCSEResource;
var integer v_resourceIndex := -1;
var template UtTriggerPrimitive v_utRequest := m_utCreateRemoteCSE;
var charstring v_action := "Please, send a CSE registration request";
var integer v_parentIndex := vc_localRemoteCseIndex;
var ResponsePrimitive v_responsePrimitive;
var PrimitiveContent v_announcedResource;
var boolean v_remoteCSERegistered:=false;
var integer v_ResourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
//send triggering primitive to SUT
f_sendUtPrimitive(v_utRequest,v_action);
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type remoteCSE created successfuly");
v_remoteCSEResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, vc_cSEBaseIndex, int16);//TODO Get index from v_request.primitive.requestPrimitive.to_
vc_localRemoteCseIndex := f_setLocalResource(v_remoteCSEResource, int16, vc_cSEBaseIndex);
v_response := valueof(m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier));
v_response.from_ := PX_CSE1_ID;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
v_response.primitiveContent.remoteCSE := vc_localResourcesList[vc_localRemoteCseIndex].resource.remoteCSE;
mccPortIn.send(m_response(v_response));
vc_remoteCseIndex := f_setResource(valueof(m_primitiveContentRemoteCSE(m_contentMyRemoteCSEResource)), int16, -1);
v_resourceIndex := vc_remoteCseIndex;
v_remoteCSERegistered:=true;
tc_ac.start;
repeat;
}
[] tc_ac.timeout {
if(not (v_remoteCSERegistered)){
setverdict(inconc, __SCOPE__&":INFO: No request received for creating resource type remoteCSE");
}
}
}
f_checkCseSimuStatus();
return v_resourceIndex;
}
/**
* @desc Receive a request from the CSE IUT to the Test System (simulating a CSE)
* @param p_requestPrimitive Expected CREATE request primitive
*/
function f_cse_receiveCreateRequest(in template RequestPrimitive p_requestPrimitive := ?) runs on CseSimu {
var ResponsePrimitive v_responsePrimitive;
//Activate defaults when running on a PTC
f_cse_activateDefaults_cse1();
tc_ac.start;
alt {
[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value vc_request {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: CREATE Request received successfuly");
v_responsePrimitive := f_getCreateResponsePrimitive(vc_request.primitive.requestPrimitive.resourceType, vc_request.primitive.requestPrimitive);
v_responsePrimitive.responseStatusCode := int2001;
mccPortIn.send(m_response(v_responsePrimitive));
}
[] mccPortIn.receive(mw_request(?)) {
tc_ac.stop;
setverdict(fail, __SCOPE__&":INFO: Unexpected CREATE Request received");
}
[] mccPortIn.receive {
tc_ac.stop;
setverdict(fail, __SCOPE__&":INFO: Unexpected message received");
}
[] tc_ac.timeout {
setverdict(fail, __SCOPE__&":INFO: No answer while creating resource type RemoteCSE");
}
}
f_checkCseSimuStatus();
}
/**
* @desc Creation of a local resource (Test System simulating a CSE)
* @param p_resource Resource to be created
* @param p_parentIndex Parent resource index of resource to be saved
* @param p_resourceType Type of the resource to be created
* @return Internal created resource
*/
function f_cse_generateLocalResource(in template(omit) PrimitiveContent p_resource := omit, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {
var integer v_resourceIndex := lengthof(vc_localResourcesList);
var PrimitiveContent v_myResource;
// TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
if(p_resourceType == int5) { //CSEBase
v_myResource.cSEBase.resourceName := PX_CSE1_NAME;
v_myResource.cSEBase.resourceType := p_resourceType;
v_myResource.cSEBase.resourceID := f_resourceIdCleaner(PX_CSE1_ID);
v_myResource.cSEBase.parentID := "";//Following TS-0001, it must be NULL. Set to a value for Codec to set it to null
v_myResource.cSEBase.creationTime := fx_generateTimestamp();
v_myResource.cSEBase.creationTime := "20171231T012345";
v_myResource.cSEBase.lastModifiedTime := v_myResource.cSEBase.creationTime;
v_myResource.cSEBase.cSE_ID := PX_CSE1_ID;
v_myResource.cSEBase.supportedResourceType := PX_CSE1_SRT;
v_myResource.cSEBase.pointOfAccess := {f_getAnnouncementTargetPoA(PX_PROTOCOL_BINDING, PX_CSE1_ADDRESS, "")};
if (PX_MN_CSE){
v_myResource.cSEBase.cseType := int1; //Tester is an IN-CSE
}else if (PX_IN_CSE){
v_myResource.cSEBase.cseType := int2; //Tester is a MN-CSE
}
}else if(p_resourceType == int16 and ispresent(p_resource)) { //RemoteCSE
if(ischosen(p_resource.remoteCSE)){
v_myResource.remoteCSE := valueof(p_resource.remoteCSE);
if(not(ispresent(p_resource.remoteCSE.resourceName))) {
v_myResource.remoteCSE.resourceName := "remoteCSE" & int2str(v_resourceIndex);
}
v_myResource.remoteCSE.resourceType := p_resourceType;
v_myResource.remoteCSE.resourceID := f_resourceIdCleaner(v_myResource.remoteCSE.cSE_ID);
//v_myResource.remoteCSE.resourceID := "remoteCSE-ID" & int2str(v_resourceIndex);
v_myResource.remoteCSE.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.remoteCSE.creationTime := fx_generateTimestamp();
v_myResource.remoteCSE.creationTime := "20171231T012345";
if(not(ispresent(p_resource.remoteCSE.expirationTime))) {
v_myResource.remoteCSE.expirationTime := "20301231T012345";
}
v_myResource.remoteCSE.lastModifiedTime := v_myResource.remoteCSE. creationTime;
v_myResource.remoteCSE.announceTo := omit;
v_myResource.remoteCSE.announcedAttribute := omit;
if(not(ispresent(p_resource.remoteCSE.pointOfAccess))) {
//TODO Create a pollingChannel resource
v_myResource.remoteCSE.pointOfAccess := omit;
}
/*if(vc_localResourcesList[v_resourceIndex].resourceType == int5) {
v_myResource.remoteCSE.m2M_Ext_ID := omit;
v_myResource.remoteCSE.trigger_Recipient_ID:= omit;
}*/
v_myResource.remoteCSE.nodeLink := omit;
}
} else if (p_resourceType == int10002 and ispresent (p_resource)) { //AE Annc
if(ischosen(p_resource.aEAnnc)) {
v_myResource.aEAnnc := valueof(p_resource.aEAnnc);
}
} else if (p_resourceType == int10001 and ispresent (p_resource)) { //Acp Annc
if(ischosen(p_resource.accessControlPolicyAnnc)) {
v_myResource.accessControlPolicyAnnc := valueof(p_resource.accessControlPolicyAnnc);
}
} else if (p_resourceType == int10003 and ispresent (p_resource)) { //Container Annc
if(ischosen(p_resource.containerAnnc)) {
v_myResource.containerAnnc := valueof(p_resource.containerAnnc);
}
} else if (p_resourceType == int10009 and ispresent (p_resource)) { //Group Annc
if(ischosen(p_resource.groupAnnc)) {
v_myResource.groupAnnc := valueof(p_resource.groupAnnc);
}
} else if (p_resourceType == int10014 and ispresent (p_resource)) { //ContentInstance Annc
if(ischosen(p_resource.contentInstanceAnnc)) {
v_myResource.contentInstanceAnnc := valueof(p_resource.contentInstanceAnnc);
}
} else if (p_resourceType == int1 and ispresent (p_resource)) { //Acp Resource
if(ischosen (p_resource.accessControlPolicy)){
v_myResource.accessControlPolicy := valueof(p_resource.accessControlPolicy);
if(not(ispresent(p_resource.accessControlPolicy.resourceName))) {
v_myResource.accessControlPolicy.resourceName := "accessControlPolicy" & int2str(v_resourceIndex);
}
v_myResource.accessControlPolicy.resourceType := p_resourceType;
v_myResource.accessControlPolicy.resourceID := "accessControlPolicy" & int2str(v_resourceIndex);
v_myResource.accessControlPolicy.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.accessControlPolicy.creationTime := fx_generateTimestamp();
if(not(ispresent(p_resource.accessControlPolicy.expirationTime))) {
v_myResource.accessControlPolicy.expirationTime := "20301231T012345";
}
v_myResource.accessControlPolicy.lastModifiedTime := v_myResource.accessControlPolicy.creationTime;
v_myResource.accessControlPolicy.announceTo := omit;
v_myResource.accessControlPolicy.announcedAttribute := omit;
}
}
return v_myResource;
}//End of function
/**
* @desc Update of a local resource (Test System simulating a CSE)
* @param p_localResourceIndex Resource index of resource to be updated
* @param p_resource Resource update
*/
function f_cse_updateLocalResource(in integer p_localResourceIndex, in PrimitiveContent p_resource) runs on CseSimu {
// TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.remoteCSE) and ischosen(p_resource.remoteCSE)) {//RemoteCSE
if(ispresent(p_resource.remoteCSE.accessControlPolicyIDs)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.accessControlPolicyIDs := p_resource.remoteCSE.accessControlPolicyIDs;
}
if(ispresent(p_resource.remoteCSE.expirationTime)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.expirationTime := p_resource.remoteCSE.expirationTime;
}
if(ispresent(p_resource.remoteCSE.labels)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.labels := p_resource.remoteCSE.labels;
}
if(ispresent(p_resource.remoteCSE.announceTo)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.announceTo := p_resource.remoteCSE.announceTo;
}
if(ispresent(p_resource.remoteCSE.announcedAttribute)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.announcedAttribute := p_resource.remoteCSE.announcedAttribute;
}
if(ispresent(p_resource.remoteCSE.pointOfAccess)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.pointOfAccess := p_resource.remoteCSE.pointOfAccess;
}
if(ispresent(p_resource.remoteCSE.m2M_Ext_ID)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.m2M_Ext_ID := p_resource.remoteCSE.m2M_Ext_ID;
}
if(ispresent(p_resource.remoteCSE.trigger_Recipient_ID)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.trigger_Recipient_ID := p_resource.remoteCSE.trigger_Recipient_ID;
}
if(ispresent(p_resource.remoteCSE.requestReachability)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.requestReachability := p_resource.remoteCSE.requestReachability;
}
if(ispresent(p_resource.remoteCSE.nodeLink)) {
vc_localResourcesList[p_localResourceIndex].resource.remoteCSE.nodeLink := p_resource.remoteCSE.nodeLink;
}
} else if(ischosen(vc_localResourcesList[p_localResourceIndex].resource.container) and (ischosen(p_resource.container))) {//Container
}
}//End of function
/**
* @desc Send response to the IUT (Test System simulating a CSE)
* @param p_requestPrimtive Received request primitive
*/
function f_cse_sendResponse(in MsgIn p_requestPrimitive) runs on CseSimu {
var integer v_parentResourceIndex := -1;
var integer v_localResourceIndex := -1;
var ResponsePrimitive v_response;
var PrimitiveContent v_localResource;
v_parentResourceIndex := f_getResourceIndex(p_requestPrimitive.primitive.requestPrimitive.to_);
if(v_parentResourceIndex == -1) {
log(__SCOPE__&": ERROR: Target resource not found");
v_response := valueof(m_responsePrimitive(int4004,p_requestPrimitive.primitive.requestPrimitive.requestIdentifier));
} else {
v_localResource := f_cse_generateLocalResource(p_requestPrimitive.primitive.requestPrimitive.primitiveContent, v_parentResourceIndex, p_requestPrimitive.primitive.requestPrimitive.resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, p_requestPrimitive.primitive.requestPrimitive.resourceType, v_parentResourceIndex);
v_response := valueof(m_responsePrimitive(int2001,p_requestPrimitive.primitive.requestPrimitive.requestIdentifier));
v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
}
v_response.from_ := PX_CSE1_ID;
v_response.to_ := p_requestPrimitive.primitive.requestPrimitive.from_;
mccPortIn.send(m_response(v_response));
}
/**
* @desc Receive response from the IUT
* @param p_requestPrimtive Received request primitive
*/
function f_cse_receiveResponse() runs on AeSimu {
var integer v_localResourceIndex := -1;
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Response received with positive response status code");
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Response received with negative response status code");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No response received");
}
}
}
}//end group CseSimuFunctions
group CseAltstepFunctions {
/**
* @desc Cse altstep for config 01
*/
altstep a_cse_cf01() runs on AeSimu {
var MsgIn v_request;
var ResponsePrimitive v_responsePrimitive;
[] mcaPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value v_request {
//Send response
v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
v_responsePrimitive.requestIdentifier := v_request.primitive.requestPrimitive.requestIdentifier;
mcaPortIn.send(m_response(v_responsePrimitive));
log(__SCOPE__&": WARNING: Unexpected Notification message received");
repeat;
}
}
/**
* @desc Cse altstep for config 02 on CSE1 (AE1 as master)
*/
altstep a_cse_cf02_cse1() runs on CseSimu {
var PrimitiveContent v_localResource;
var integer v_localResourceIndex := -1;
var integer v_parentResourceIndex := -1;
var MsgIn v_request;
var ResponsePrimitive v_response;
[] mccPortIn.receive(mw_request(mw_create())) -> value v_request {
log(__SCOPE__&": WARNING: Unexpected CREATE message received");
tc_ac.stop;
v_parentResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
if(v_parentResourceIndex == -1) {
log(__SCOPE__&": ERROR: Target resource not found");
v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier));
} else {
v_localResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, v_parentResourceIndex, v_request.primitive.requestPrimitive.resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, v_request.primitive.requestPrimitive.resourceType, v_parentResourceIndex);
v_response := valueof(m_responsePrimitive(int2001,v_request.primitive.requestPrimitive.requestIdentifier));
v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
}
v_response.from_ := PX_CSE1_ID;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
mccPortIn.send(m_response(v_response));
tc_ac.start(10.0);
repeat;
}
[] mccPortIn.receive(mw_request(mw_retrieve(?))) -> value v_request {
tc_ac.stop;
log(__SCOPE__&": WARNING: Unexpected RETRIEVE message received");
v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
if(v_localResourceIndex == -1)
{
log(__SCOPE__&": ERROR: Resource Index not valid");
v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier));
v_response.from_ := PX_CSE1_ID;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
mccPortIn.send(m_response(v_response));
} else {
v_response := valueof(m_responsePrimitive(int2000,v_request.primitive.requestPrimitive.requestIdentifier));
v_response.from_ := PX_CSE1_ID;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
if(ischosen(vc_localResourcesList[v_localResourceIndex].resource.cSEBase)) {
mccPortIn.send(m_response(v_response, {{"parentID", omit}}));
} else {
mccPortIn.send(m_response(v_response));
}
}
tc_ac.start(10.0);
repeat;
}
[] mccPortIn.receive(mw_request(mw_update())) -> value v_request {
tc_ac.stop;
log(__SCOPE__&": WARNING: Unexpected UPDATE message received");
v_localResourceIndex := f_getResourceIndex(v_request.primitive.requestPrimitive.to_);
if(v_localResourceIndex == -1)
{
log(__SCOPE__&": ERROR: Resource Index not valid");
v_response := valueof(m_responsePrimitive(int4004,v_request.primitive.requestPrimitive.requestIdentifier));
v_response.from_ := PX_CSE1_ID;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
mccPortIn.send(m_response(v_response));
} else {
v_response := valueof(m_responsePrimitive(int2004,v_request.primitive.requestPrimitive.requestIdentifier));
v_response.from_ := PX_CSE1_ID;
v_response.to_ := v_request.primitive.requestPrimitive.from_;
f_cse_updateLocalResource(v_localResourceIndex, v_request.primitive.requestPrimitive.primitiveContent);
v_response.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
mccPortIn.send(m_response(v_response));
}
tc_ac.start(10.0);
repeat;
}
[] mccPortIn.receive (mw_request(?)){
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
[] mccPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
}
/**
* @desc Cse altstep for config 02 on AE1 (CSE1 as master)
*/
altstep a_cse_cf02_ae1() runs on AeSimu
{
[] mcaPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
}
/**
* @desc Cse altstep for config 04
*/
altstep a_cse_cf04() runs on CseSimu {
[] mccPort.receive {
log(__SCOPE__&": WARNING: Unexpected message received");
repeat;
}
}
}//end group altstepFunctions
function f_cse_activateDefaults_cse1() runs on CseSimu {
if(not(self == mtc)) {
activate(a_default());
if(vc_config == e_cf02) {
activate(a_cse_cf02_cse1());
log(__SCOPE__&": INFO: Default cf02_cse1 activated");
} else if(vc_config == e_cf04) {
activate(a_cse_cf04());
log(__SCOPE__&": INFO: Default cf04 activated");
}
}
}
function f_cse_activateDefaults_ae() runs on AeSimu {
if(not(self == mtc)) {
activate(a_default());
if(vc_config == e_cf01) {
activate(a_cse_cf01());
log(__SCOPE__&": INFO: Default cf01 and cf01_ae2 activated");
} else if(vc_config == e_cf02CseSimuMaster) {
activate(a_cse_cf02_ae1());
log(__SCOPE__&": INFO: Default cf02_ae1 activated");
}
}
}
}//end cseFunctions
group AeFunctions {
group preambleFunctions {
/**
* @desc Waits for AE registration request and process it
* @param p_utRequest UpperTester request primitive to be sent to the IUT
* @return Internal resource index of AE or -1 in case of failure
* @verdict inconc if no AE registration request is received
*/
function f_ae_preamble_registerAe(template UtTriggerPrimitive p_utRequest := m_utCreateAe) runs on CseSimu return integer {
var MsgIn v_request;
var integer v_localResourceIndex, v_parentIndex;
var charstring v_action := "Please, register the AE on the Tester";
p_utRequest.requestPrimitive.to_ := f_getLocalResourceAddress(-,-,-);
if(not(ispresent(p_utRequest.requestPrimitive.primitiveContent))) {
p_utRequest.requestPrimitive.primitiveContent.aE := m_contentCreateAe(omit, omit, omit, omit);
}
f_sendUtPrimitive(p_utRequest, v_action);
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_createAe)) -> value v_request {
tc_ac.stop;
v_localResourceIndex := f_processCreateRequestPrimitive(v_request.primitive.requestPrimitive);
mcaPortIn.send(m_response(vc_response.primitive.responsePrimitive));
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: AE registration request not received");
stop;
}
}
f_checkCseSimuStatus();
return v_localResourceIndex;
}//end function f_ae_preamble_register
/**
* @desc Waits for Container create request and process it
* @param p_utRequest UpperTester request primitive to be sent to the IUT
* @return Internal resource index of Container or -1 in case of failure
* @verdict inconc if no Container create request is received
*/
function f_ae_preamble_createContainer(template UtTriggerPrimitive p_utRequest := m_utCreateAe) runs on CseSimu return integer {
var MsgIn v_request;
var PrimitiveContent v_modifiedResource;
var integer v_resourceIndex, v_parentIndex;
var RequestPrimitive v_rp;
var charstring v_action := "Please, create a Container resource on the Tester";
if(not(ispresent(p_utRequest.requestPrimitive.primitiveContent))) {
p_utRequest.requestPrimitive.primitiveContent.container := m_contentCreateContainer;
}
f_sendUtPrimitive(p_utRequest, v_action);
tc_ac.start;
alt {
[] mcaPortIn.receive(mw_request(mw_createContainer(?,?))) -> value v_request {
tc_ac.stop;
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getResourceIndex(v_rp.to_);
v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, int2, v_parentIndex);
if(v_resourceIndex != -1) {
mcaPortIn.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
setverdict(pass, __SCOPE__&":INFO: Container created successfuly");
}
else {
mcaPortIn.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
setverdict(inconc, __SCOPE__&":INFO: Container creation failed");
}
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: Container create request not received");
stop;
}
}
f_checkCseSimuStatus();
return v_resourceIndex;
} //end function f_ae_preamble_createContainer
} // end preambleFunctions
group helpingFunctions {
/**
* @desc Creates specified resource
* @param p_resource Resource to be created
* @param p_parentIndex Parent index of resource to be saved
* @param p_resourceType Type of the resource to be created
* @param p_modifiedResource Assigned and/or modified fields
* @return Internal resource index of the saved resource or -1
*/
function f_ae_generateLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {
var integer v_resourceIndex;
var PrimitiveContent v_primitiveContent;
// AE TODO To review the code (use of indexes, generation of value for certain attributes, etc..)
if(p_resourceType == int2 and ispresent(p_resource)) {
if(ischosen(p_resource.aE)){
var AE_optional v_content := p_resource.aE;
v_resourceIndex := lengthof(vc_localResourcesList) - 1;
v_content.resourceType := p_resourceType;
v_content.parentID := PX_CSE1_ID;
v_content.creationTime := fx_generateTimestamp();
v_content.lastModifiedTime := v_content.creationTime;
v_content.resourceID := "ae" & int2str(v_resourceIndex);
v_content.aE_ID := "Cae" & int2str(v_resourceIndex);
v_content.resourceName := "ae" & int2str(v_resourceIndex);
v_primitiveContent := {aE := v_content};
return v_primitiveContent;
}
}
if(p_resourceType == int3 and ispresent(p_resource)) {
if(ischosen(p_resource.container)){
var Container_optional v_content := p_resource.container;
v_resourceIndex := lengthof(vc_localResourcesList) - 1;
v_content.resourceType := p_resourceType;
v_content.parentID := PX_CSE1_ID;
v_content.creationTime := fx_generateTimestamp();
v_content.lastModifiedTime := v_content.creationTime;
v_content.resourceID := "cnt" & int2str(v_resourceIndex);
v_content.resourceName := "cnt" & int2str(v_resourceIndex);
v_primitiveContent := {container := v_content};
return v_primitiveContent;
}
}
// TODO: implement other resource types
// Error
return p_resource;
}
} // end helpingFunctions
group altstepFunctions {
/**
* @desc Ae altstep
*/
altstep a_ae_default() runs on CseSimu {
var MsgIn v_request;
[] mcaPort.receive(mw_request(?)) -> value v_request {
log(__SCOPE__ & ":WARNING: Unexpected request received");
mcaPort.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
repeat;
}
[] mcaPort.receive {
log(__SCOPE__ & ":WARNING: Unexpected message received");
repeat;
}
}
/**
* @desc Waits for CREATE request, stores resource and replies to request
* @remark This altstep includes a_ae_default
* @see a_ae_default
*/
altstep a_ae_cf03() runs on CseSimu {
var MsgIn v_request;
var PrimitiveContent v_modifiedResource;
var integer v_resourceIndex, v_parentIndex;
var RequestPrimitive v_rp;
[] mcaPortIn.receive(mw_request(mw_create)) -> value v_request {
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getResourceIndex(v_rp.to_);
v_modifiedResource := f_ae_generateLocalResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType);
v_resourceIndex := f_setLocalResource(v_modifiedResource, v_rp.resourceType, v_parentIndex);
if(v_resourceIndex != -1) {
mcaPortIn.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, v_modifiedResource)));
}
else {
mcaPortIn.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
}
repeat;
}
[] a_ae_default();
}
}//end group altstepFunctions
function f_ae_activateDefaults() runs on CseSimu {
if(not(self == mtc)) {
activate(a_default());
if(vc_config == e_cf03) {
activate(a_ae_cf03());
log(__SCOPE__&": INFO: Default cf03 activated");
}
}
}
}//end of aeFunctions
group GetSetFunctions {
/**
* @desc Creation of a CREATE request primitive from a template request primitive
* @param p_resourceType Type of resource to be created
* @param p_request Template request primitive
* @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
* @return Created CREATE request primitive
* @verdict
*/
function f_getCreateRequestPrimitive(in ResourceType p_resourceType, template RequestPrimitive p_request := m_create, integer p_parentIndex) runs on Tester return RequestPrimitive {
var template ListOfURIs v_defaultListOfURIs := {"NotInitialized"};
var template AcpType v_defaultAcpIDs := {"NotInitialized"};
p_request.requestIdentifier := valueof(p_request.requestIdentifier) & f_rnd(1, 1000000);
if((p_resourceType != int2) and (p_resourceType != int10002)) {
if(p_resourceType == int16) {
p_request.from_ := PX_CSE1_ID;
} else {
if(vc_testSystemRole == e_ae) {
p_request.from_ := f_getOriginator(p_parentIndex);
} else {//vc_testSystemRole == e_cse
p_request.from_ := f_getOriginator(p_parentIndex, false);
}
}
}
p_request.to_ := f_getResourceAddress(p_parentIndex);
if (p_resourceType == int1) {//AccessControlPolicy
}
if (p_resourceType == int9) {//group
if(match(valueof(p_request.primitiveContent.group_.memberIDs), v_defaultListOfURIs )){
if ((p_parentIndex == -1) and (isbound(vc_aeAuxIndex))){
p_request.primitiveContent.group_.memberIDs := {f_getResourceId(vc_resourcesList[vc_aeAuxIndex].resource)};
}else{
p_request.primitiveContent.group_.memberIDs := {f_getResourceId(vc_resourcesList[p_parentIndex].resource)};
}
}
}
if(p_resourceType == int3){//container
//when a container is created by hosting cse for storing location information, the container is seen as a location container
if(PX_IS_LOC_CONTAINER){
p_request.primitiveContent.container.locationID := f_getResourceId(vc_resourcesList[p_parentIndex].resource);//resourceID of the locationPolicy
}
if(ispresent(p_request.primitiveContent.container.accessControlPolicyIDs)) {
if((match(valueof(p_request.primitiveContent.container.accessControlPolicyIDs), v_defaultAcpIDs )) and (isbound(vc_acpAuxIndex))){
p_request.primitiveContent.container.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)};
}
}
}
if (p_resourceType == int15) {//pollingChannel
if(ischosen(vc_resourcesList[p_parentIndex].resource.aE)) {
p_request.from_ := vc_resourcesList[p_parentIndex].resource.aE.aE_ID;
}
}
if (p_resourceType == int18) {//schedule
}
if (p_resourceType == int23) {//subscription
//notificationURI
if(match(valueof(p_request.primitiveContent.subscription.notificationURI), v_defaultListOfURIs )){
p_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(p_parentIndex)};
}
//subscriberURI
if(ispresent(p_request.primitiveContent.subscription.subscriberURI)) {
if(match(valueof(p_request.primitiveContent.subscription.subscriberURI), "NotInitialized" )){
p_request.primitiveContent.subscription.subscriberURI := f_getResourceAddress(vc_aeAuxIndex);
}
}
//accessControlPolicyIds
if(ispresent(p_request.primitiveContent.subscription.accessControlPolicyIDs)) {
if(match(valueof(p_request.primitiveContent.subscription.accessControlPolicyIDs), v_defaultAcpIDs )){
p_request.primitiveContent.subscription.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[vc_acpAuxIndex].resource)};
}
}
}
if (p_resourceType == int4) {//contentInstance
//creator attribute
if(ispresent(p_request.primitiveContent.contentInstance.creator)) {
p_request.primitiveContent.contentInstance.creator := f_getCreator(p_parentIndex);
}
}
return valueof(p_request);
}
/**
* @desc Creation of a CREATE response primitive from a template request primitive
* @param p_resourceType Type of resource to be created
* @param p_request Template request primitive
* @return Created CREATE response primitive
* @verdict
*/
//TODO To be completed
function f_getCreateResponsePrimitive(in ResourceType p_resourceType, template RequestPrimitive p_request := m_create) runs on Tester return ResponsePrimitive {
var template ResponsePrimitive v_responsePrimitive;
if(p_resourceType != int2) {
v_responsePrimitive.from_ := p_request.to_;
}
p_request.to_ := p_request.from_;
if (p_resourceType == int1) {//AccessControlPolicy
}
if (p_resourceType == int9) {//group
}
if(p_resourceType == int3){//container
}
if (p_resourceType == int15) {//pollingChannel
}
if (p_resourceType == int18) {//schedule
}
if (p_resourceType == int23) {//subscription
}
return valueof(v_responsePrimitive);
}
/**
* @desc Creation of an UPDATE request primitive from a template request primitive
* @param p_resourceType Type of resource to be created
* @param p_resourceIndex Internal resource index which indicates the resource to be updated
* @param p_request Template request primitive
* @return Created UPDATE request primitive
* @verdict
*/
function f_getUpdateRequestPrimitive(in ResourceType p_resourceType, integer p_resourceIndex, template RequestPrimitive p_request) runs on Tester return RequestPrimitive {
p_request.requestIdentifier := valueof(p_request.requestIdentifier) & f_rnd(1, 1000000);
if(p_resourceType != int10002) {
p_request.from_ := f_getOriginator(p_resourceIndex);
p_request.to_ := f_getResourceAddress(p_resourceIndex);
} else {
p_request.from_ := PX_CSE1_ID & "/" & f_getResourceId(vc_resourcesList[p_resourceIndex].resource);
p_request.to_ := f_getResourceAddress(p_resourceIndex, -, e_spRelative);
}
if (p_resourceType == int3) {//Container
//TODO
}
if (p_resourceType == int9) {//group
//TODO
}
if (p_resourceType == int18) {//schedule
//TODO
}
if (p_resourceType == int15) {//pollingChannel
//TODO
}
if (p_resourceType == int23) {//subscription
//TODO
}
return valueof(p_request);
}
/**
* @desc Extraction from a primitiveContent field the resourceID attribute
* @param p_contentResource primitiveContent field
* @return resourceID attribute
* @verdict
*/
function f_getResourceId(PrimitiveContent p_contentResource) return XSD.ID {
if(ischosen(p_contentResource.accessControlPolicy)) {
return f_resourceIdCleaner(p_contentResource.accessControlPolicy.resourceID);
}
if(ischosen(p_contentResource.container)) {
return f_resourceIdCleaner(p_contentResource.container.resourceID);
}
if(ischosen(p_contentResource.contentInstance)) {
return f_resourceIdCleaner(p_contentResource.contentInstance.resourceID);
}
if(ischosen(p_contentResource.schedule)) {
return f_resourceIdCleaner(p_contentResource.schedule.resourceID);
}
if(ischosen(p_contentResource.pollingChannel)) {
return f_resourceIdCleaner(p_contentResource.pollingChannel.resourceID);
}
if(ischosen(p_contentResource.subscription)) {
return f_resourceIdCleaner(p_contentResource.subscription.resourceID);
}
if(ischosen(p_contentResource.group_)) {
return f_resourceIdCleaner(p_contentResource.group_.resourceID);
}
if(ischosen(p_contentResource.aE)) {
return f_resourceIdCleaner(p_contentResource.aE.resourceID);
}
if(ischosen(p_contentResource.aEAnnc)) {
return f_resourceIdCleaner(p_contentResource.aEAnnc.resourceID);
}
if(ischosen(p_contentResource.serviceSubscribedAppRule)) {
return f_resourceIdCleaner(p_contentResource.serviceSubscribedAppRule.resourceID);
}
if(ischosen(p_contentResource.remoteCSE)) {
return f_resourceIdCleaner(p_contentResource.remoteCSE.resourceID);
}
if(ischosen(p_contentResource.cSEBase)) {
return f_resourceIdCleaner(p_contentResource.cSEBase.resourceID);
}
if(ischosen(p_contentResource.m2mServiceSubscriptionProfile)) {
return f_resourceIdCleaner(p_contentResource.m2mServiceSubscriptionProfile.resourceID);
}
if(ischosen(p_contentResource.node)) {
return f_resourceIdCleaner(p_contentResource.node.resourceID);
}
if(ischosen(p_contentResource.statsConfig)) {
return f_resourceIdCleaner(p_contentResource.statsConfig.resourceID);
}
if(ischosen(p_contentResource.statsCollect)) {
return f_resourceIdCleaner(p_contentResource.statsCollect.resourceID);
}
log(__SCOPE__&":WARNING: Primitive Content Kind not implemented");
return "resourceIDNotFound";
}
/**
* @desc Extraction from a primitiveContent field the resourceName attribute
* @param p_contentResource primitiveContent field
* @return resourceName attribute
* @verdict
*/
function f_getResourceName(PrimitiveContent p_contentResource) return XSD.ID {
if(ischosen(p_contentResource.accessControlPolicy)) {
return p_contentResource.accessControlPolicy.resourceName;
}
if(ischosen(p_contentResource.container)) {
return p_contentResource.container.resourceName;
}
if(ischosen(p_contentResource.contentInstance)) {
return p_contentResource.contentInstance.resourceName;
}
if(ischosen(p_contentResource.schedule)) {
return p_contentResource.schedule.resourceName;
}
if(ischosen(p_contentResource.pollingChannel)) {
return p_contentResource.pollingChannel.resourceName;
}
if(ischosen(p_contentResource.subscription)) {
return p_contentResource.subscription.resourceName;
}
if(ischosen(p_contentResource.group_)) {
return p_contentResource.group_.resourceName;
}
if(ischosen(p_contentResource.aE)) {
return p_contentResource.aE.resourceName;
}
if(ischosen(p_contentResource.aEAnnc)) {
return p_contentResource.aEAnnc.resourceName;
}
if(ischosen(p_contentResource.serviceSubscribedAppRule)) {
return p_contentResource.serviceSubscribedAppRule.resourceName;
}
if(ischosen(p_contentResource.remoteCSE)) {
return p_contentResource.remoteCSE.resourceName;
}
if(ischosen(p_contentResource.cSEBase)) {
return p_contentResource.cSEBase.resourceName;
}
if(ischosen(p_contentResource.m2mServiceSubscriptionProfile)) {
return p_contentResource.m2mServiceSubscriptionProfile.resourceName;
}
if(ischosen(p_contentResource.node)) {
return p_contentResource.node.resourceName;
}
if(ischosen(p_contentResource.statsConfig)) {
return p_contentResource.statsConfig.resourceName;
}
if(ischosen(p_contentResource.statsCollect)) {
return p_contentResource.statsCollect.resourceName;
}
log(__SCOPE__&":WARNING: Primitive Content Kind not implemented");
return "resourceNameNotFound";
}
/**
* @desc Resolution of the originator field (from) for a given resource
* @param p_targetResourceIndex Internal resource index of the given resource
* @param p_testSystemRole True if TS acting as an AE, False if TS acting as a CSE
* @return Originator for a given resource
* @verdict
*/
function f_getOriginator(integer p_targetResourceIndex := -1, boolean p_testSystemRole := true) runs on Tester return XSD.AnyURI {
if(p_targetResourceIndex == -1) {
if(p_testSystemRole) {
return PX_SUPER_AE_ID;
} else {
return PX_SUPER_CSE_ID;
}
}
if(vc_resourcesList[p_targetResourceIndex].parentIndex == -1) {
if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.aE)) {
return vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID;
} else if (ischosen(vc_resourcesList[p_targetResourceIndex].resource.remoteCSE)) {
return vc_resourcesList[p_targetResourceIndex].resource.remoteCSE.cSE_ID;
} else {
return f_getOriginator(vc_resourcesList[p_targetResourceIndex].parentIndex);
}
} else {
return f_getOriginator(vc_resourcesList[p_targetResourceIndex].parentIndex);
}
}
/**
* @desc Resolution of the creator attribute for a given resource
* @param p_targetResourceIndex Internal resource index of the given resource
* @return AE-ID or CSE-ID of the entity creating the given resource
* @verdict
*/
function f_getCreator(integer p_targetResourceIndex := -1) runs on Tester return XSD.ID {
if(p_targetResourceIndex == -1) {
return PX_CSE_ID;
}
if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.aE)) {
return vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID;
} else {
return f_getCreator(vc_resourcesList[p_targetResourceIndex].parentIndex);
}
}
/**
* @desc Return of a index of a specific attribute from an attributeList by attributeName
* @param p_attributeList Target attributeList
* @param p_attributeName attributeName to be searched
* @return Index of the attribute in the attributeList
* @verdict
*/
function f_getAttribute(in AttributeList p_attributeList, in XSD.NCName p_attributeName) return integer {
var integer i;
for (i:=0; i < lengthof(p_attributeList); i := i + 1){
if(p_attributeList[i] == p_attributeName){
return i;
}
}
return -1;
}
/**
* @desc Resolution of the announcement target CSE PoA
* @param p_protocolBinding Protocol Binding
* @param p_announcementTargetAddress Announcement Target Address
* @param p_announcementTargetResource Announcement Target Resource
* @return p_annoucementTargetPoA Announcemenet Target PoA
*/
function f_getAnnouncementTargetPoA(in charstring p_protocolBinding := PX_PROTOCOL_BINDING, in charstring p_announcementTargetAddress := PX_CSE1_ADDRESS, charstring p_announcementTargetResource := "" ) return charstring {
if(p_protocolBinding == "HTTP") {
return "http://" & p_announcementTargetAddress & "/" & p_announcementTargetResource;
} else if (p_protocolBinding == "COAP") {
return "coap://" & p_announcementTargetAddress & "/" & p_announcementTargetResource;
} else if (p_protocolBinding == "MQTT") {
return "mqtt://" & PX_SUT_ADDRESS & "/" & p_announcementTargetResource;//TODO
} else {
return "ws://" & p_announcementTargetAddress & "/" & p_announcementTargetResource;
}
}
/**
* @desc Resolution of the resource index for a given resource address (URI)
* @param p_address Resource URI (can be structured/unstructured cseRelative/spRelative/absolute)
* @return Internal resource index of the given resource or -1 in case of error
*/
function f_getResourceIndex(in XSD.ID p_receivedURI) runs on CseSimu return integer {
var integer v_resourceIndex := -1;
var integer i;
var XSD.ID v_cleanedURI;
v_cleanedURI := f_resourceIdCleaner(p_receivedURI);
if (f_isHierarchical(p_receivedURI)) {
log("Hierarchical method: " & v_cleanedURI);
for(i:=0; i < lengthof(vc_localResourcesList); i := i+1){
if(v_cleanedURI == f_getResourceName(vc_localResourcesList[i].resource)){
v_resourceIndex := i;
break;
}
}
} else {
log("Non Hierarchical method: " & v_cleanedURI);
for(i:=0; i < lengthof(vc_localResourcesList); i := i+1){
if(v_cleanedURI == f_getResourceId(vc_localResourcesList[i].resource)){
v_resourceIndex := i;
break;
}
}
}
log("Resource index found: " & int2str(v_resourceIndex));
//Try CSEBase
if(v_resourceIndex == -1) {
if(v_cleanedURI == f_getResourceName(vc_localResourcesList[vc_cSEBaseIndex].resource)) {
v_resourceIndex := vc_cSEBaseIndex;
}
}
log("Resource index found: " & int2str(v_resourceIndex));
return v_resourceIndex;
}
/**
* @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format
* @param p_targetResourceIndex Internal resource index of the given resource
* @return Resource address for the given resource
* @verdict
*/
function f_getResourceAddress(integer p_targetResourceIndex := -1, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on Tester return XSD.ID {
var XSD.ID v_resourceAddress;
if(p_primitiveScope == e_cseRelative) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == -1) {
return PX_CSE_RESOURCE_ID;
} else {
return f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
}
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE_NAME;
} else {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else if (p_primitiveScope == e_spRelative) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == -1) {
return PX_CSE_ID & "/" & PX_CSE_RESOURCE_ID;
} else {
v_resourceAddress := PX_CSE_ID & "/" & f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE_ID & "/" & PX_CSE_NAME;
} else {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else if (p_primitiveScope == e_absolute) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == -1) {
return PX_SP_ID & PX_CSE_ID;
} else {
v_resourceAddress := f_getResourceAddress(-, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == -1) {
return PX_SP_ID & PX_CSE_ID & "/" & PX_CSE_NAME;
} else {
v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else {
return "";
}
}
/**
* @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format
* @param p_targetResourceIndex Internal resource index of the given resource
* @return Resource address for the given resource
* @verdict
*/
function f_getLocalResourceAddress(integer p_targetResourceIndex := 0, AddressingMethod p_addressingMethod := PX_ADDRESSING_METHOD, PrimitiveScope p_primitiveScope := PX_PRIMITIVE_SCOPE) runs on CseSimu return XSD.ID {
var XSD.ID v_resourceAddress;
if(p_primitiveScope == e_cseRelative) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == 0) {
return PX_CSE1_RESOURCE_ID;
} else {
return f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
}
} else {
if(p_targetResourceIndex == 0) {
return PX_CSE1_NAME;
} else {
v_resourceAddress := f_getLocalResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else if (p_primitiveScope == e_spRelative) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == 0) {
return PX_CSE1_ID & "/" & PX_CSE1_RESOURCE_ID;
} else {
v_resourceAddress := PX_CSE1_ID & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == 0) {
return PX_CSE1_ID & "/" & PX_CSE1_NAME;
} else {
v_resourceAddress := f_getLocalResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else if (p_primitiveScope == e_absolute) {
if(p_addressingMethod == e_nonHierarchical) {
if(p_targetResourceIndex == 0) {
return PX_SP1_ID & PX_CSE1_ID;
} else {
v_resourceAddress := f_getLocalResourceAddress(-, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == 0) {
return PX_SP1_ID & PX_CSE1_ID & "/" & PX_CSE1_NAME;
} else {
v_resourceAddress := f_getLocalResourceAddress(vc_localResourcesList[p_targetResourceIndex].parentIndex, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceName(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
}
} else {
return "";
}
}
/**
* @desc Saving of a resource and its parent index in the internal resource list
* @param p_resource Resource to be saved
* @param p_parentIndex Parent index of resource to be saved
* @return Internal resource index of the saved resource
* @verdict
*/
function f_setResource(PrimitiveContent p_resource, ResourceType p_resourceType, integer p_parentIndex := -1, in boolean p_resourceToBeDeleted := true) runs on Tester return integer {
var integer v_newIndex := -1;
if(isbound(vc_resourcesList)) {
vc_resourcesList[lengthof(vc_resourcesList)] := {p_parentIndex, p_resourceType, p_resource};
} else {
vc_resourcesList[0] := {p_parentIndex, p_resourceType, p_resource};
}
v_newIndex := lengthof(vc_resourcesList)-1;
if(p_resourceToBeDeleted) {
if(match(int2, p_resourceType) or match(-1, p_parentIndex)) {//If created resource is an AE or created under CSEBase, it needs to be added to the resourceToBeDeleted list
vc_resourcesIndexToBeDeleted := vc_resourcesIndexToBeDeleted & {v_newIndex};
}
}
return v_newIndex;
}
/**
* @desc Saving of a local resource and its parent index in the internal resource list
* @param p_resource Resource to be saved
* @param p_parentIndex Parent index of resource to be saved
* @return Internal resource index of the saved resource
* @verdict
*/
function f_setLocalResource(PrimitiveContent p_resource, ResourceType p_resourceType, integer p_parentIndex := vc_cSEBaseIndex) runs on CseSimu return integer {
var integer v_newIndex := -1;
if(isbound(vc_localResourcesList)) {
vc_localResourcesList[lengthof(vc_localResourcesList)] := {p_parentIndex, p_resourceType, p_resource};
} else {
vc_localResourcesList[0] := {p_parentIndex, p_resourceType, p_resource};
}
v_newIndex := lengthof(vc_localResourcesList)-1;
return v_newIndex;
}
/**
* @desc Set Acpid into the requestPrimitive
* @param p_requestPrimitive RequestPrimitive to be modified
* @param p_accessControlPolicyIDs AcpId to be set
* @return
* @verdict
*/
function f_setAcpId(template RequestPrimitive p_requestPrimitive, template AcpType p_accessControlPolicyIDs) runs on Tester return RequestPrimitive{
if (ischosen(p_requestPrimitive.primitiveContent.aE)){
p_requestPrimitive.primitiveContent.aE.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.container)){
p_requestPrimitive.primitiveContent.container.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.group_)){
p_requestPrimitive.primitiveContent.group_.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.serviceSubscribedAppRule)){
p_requestPrimitive.primitiveContent.serviceSubscribedAppRule.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.subscription)){
p_requestPrimitive.primitiveContent.subscription.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.locationPolicy)){
p_requestPrimitive.primitiveContent.locationPolicy.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.delivery)){
p_requestPrimitive.primitiveContent.delivery.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.mgmtCmd)){
p_requestPrimitive.primitiveContent.mgmtCmd.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.node)){
p_requestPrimitive.primitiveContent.node.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.remoteCSE)){
p_requestPrimitive.primitiveContent.remoteCSE.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.request)){
p_requestPrimitive.primitiveContent.request.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.statsCollect)){
p_requestPrimitive.primitiveContent.statsCollect.accessControlPolicyIDs := p_accessControlPolicyIDs;
}
else if (ischosen(p_requestPrimitive.primitiveContent.statsConfig)){
p_requestPrimitive.primitiveContent.statsConfig.accessControlPolicyIDs := p_accessControlPolicyIDs;
} else {
log( __SCOPE__, ":INFO: Resource not having acpi attribute. Not possible to set acpi")
}
return valueof(p_requestPrimitive);
}
/**
* @desc Retrieve AE_ID for a given AE resource
* @param p_targetResourceIndex Internal resource index of the given resource
* @return AE_ID of the given resource
*/
function f_getAeId(integer p_targetResourceIndex := -1) runs on Tester return XSD.ID {
if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.aE)) {
return vc_resourcesList[p_targetResourceIndex].resource.aE.aE_ID;
}
log(__SCOPE__ & ":WARNING: p_targetResourceIndex does not refer to AE resource");
return "";
} // end f_getAeId
/**
* @desc Retrieve Announced Resource Type from the given resource type
* @param p_targetResourceIndex Internal resource index of the given resource
* @return AE_ID of the given resource
*/
function f_getAnnouncedResourceType(in ResourceType p_resourceType) runs on Tester return ResourceType {
if(p_resourceType == int2) {
return int10002;
}
return p_resourceType;
} // end f_getAnnouncedResourceType
/**
* @desc Proccessing of the request primitive
* @param p_request Request primitive to be processed
* @return p_response Response primitive to be sent back
*/
function f_processCreateRequestPrimitive(in RequestPrimitive p_request) runs on CseSimu return integer {
var integer v_parentIndex := -1;
var integer v_localResourceIndex := -1;
var PrimitiveContent v_localResource;
v_parentIndex := f_getResourceIndex(p_request.to_);
if(v_parentIndex == -1) {
setverdict(inconc,__SCOPE__&": ERROR: Target resource not found");
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int4004,p_request.requestIdentifier));
} else {
setverdict(pass, __SCOPE__&":INFO: Resource created successfuly");
v_localResource := f_ae_generateLocalResource(p_request.primitiveContent, v_parentIndex, p_request.resourceType);
v_localResourceIndex := f_setLocalResource(v_localResource, p_request.resourceType, v_parentIndex);
vc_response.primitive.responsePrimitive := valueof(m_responsePrimitive(int2001,p_request.requestIdentifier));
vc_response.primitive.responsePrimitive.primitiveContent := vc_localResourcesList[v_localResourceIndex].resource;
}
vc_response.primitive.responsePrimitive.from_ := PX_CSE1_ID;
vc_response.primitive.responsePrimitive.to_ := p_request.from_;
return v_localResourceIndex;
}
}//end group getSetFunctions
group CheckingFunctions {
/**
* @desc It determines whether the addressing method of the given address is non-hierarchical. Not valid for CSE-Base as target
* @param p_resourceAddress
* @return boolean
*/
function f_isNonHierarchical(XSD.ID p_resourceAddress) runs on Tester return boolean {
var integer i;
var integer v_nbOfSlashes:= 0;
for (i := 0; i < lengthof(p_resourceAddress); i:= i+1){
if(p_resourceAddress[i] == "/"){
v_nbOfSlashes:= v_nbOfSlashes+1;
}
}
if(f_isScopeCseRelative(p_resourceAddress)) {
if(v_nbOfSlashes == 0 ) {
return true;
} else {
return false;
}
} else if (f_isScopeSpRelative(p_resourceAddress)){
if(v_nbOfSlashes == 2 ) {
return true;
} else {
return false;
}
} else if (f_isScopeAbsolute(p_resourceAddress)){
if(v_nbOfSlashes == 4 ) {
return true;
} else {
return false;
}
} else {
return false;
}
}
/**
* @desc It determines whether the addressing method of the given address is hierarchical. Not valid for CSE-Base as target
* @param p_resourceAddress
* @return boolean
*/
function f_isHierarchical(XSD.ID p_resourceAddress) runs on Tester return boolean {
if(f_isNonHierarchical(p_resourceAddress)) {
return false;
} else {
return true;
}
}
/**
* @desc It determines whether the primitive scope of the given address is CSE-Relative
* @param p_resourceAddress
* @return boolean
*/
function f_isScopeCseRelative(XSD.ID p_resourceAddress) runs on Tester return boolean {
if (p_resourceAddress[0] != "/") {
return true;
} else {
return false;
}
}
/**
* @desc It determines whether the primitive scope of the given address is SP-Relative
* @param p_resourceAddress
* @return boolean
*/
function f_isScopeSpRelative(XSD.ID p_resourceAddress) runs on Tester return boolean {
if ((p_resourceAddress[0] == "/") and (p_resourceAddress[1] != "/")){
return true;
} else {
return false;
}
}
/**
* @desc It determines whether the primitive scope of the given address is Absolute
* @param p_resourceAddress
* @return boolean
*/
function f_isScopeAbsolute(XSD.ID p_resourceAddress) runs on Tester return boolean {
if ((p_resourceAddress[0] == "/") and (p_resourceAddress[1] == "/")) {
return true;
} else {
return false;
}
}
}//end group CheckingFunctions
group CommonFunctions {
/**
* @desc Boolean to charstring
* @param p_bool
* @verdict
*/
function f_checkAeSimuStatus() runs on AeSimu {
if (getverdict != pass) {
f_cse_postamble_deleteResources();
// Tear down
if(vc_config == e_cf01) {
f_cf01Down();
} else if (vc_config ==e_cf02) {
f_cf02Down();
}
kill;
}
}
/**
* @desc Sending of an Adapter Control primitive
* @param event Action to be performed by TA
* @param data Corresponding information for the correct execution of the given action
* @verdict
*/
function f_aeSimu_checkComponentDoneAndGetVerdict(AeSimu p_ae) runs on AeSimu {
var verdicttype v_verdict := none;
tc_ac.start(15.0);
alt {
[] p_ae.done -> value v_verdict {
tc_ac.stop;
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__ & "INFO: Component did not finish");
}
}
if(v_verdict == pass) { // Component was successfully completed and got stopped state
setverdict(pass);
} else {
setverdict(inconc); // Component was not completed successfully
}
f_checkAeSimuStatus();
}
/**
* @desc Sending of an Adapter Control primitive
* @param event Action to be performed by TA
* @param data Corresponding information for the correct execution of the given action
* @verdict
*/
function f_cseSimu_checkComponentDoneAndGetVerdict(AeSimu p_ae) runs on CseSimu {
var verdicttype v_verdict := none;
tc_ac.start(15.0);
alt {
[] p_ae.done -> value v_verdict {
tc_ac.stop;
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__ & "INFO: Component did not finish");
}
}
if(v_verdict == pass) { // Component was successfully completed and got stopped state
setverdict(pass);
} else {
setverdict(inconc); // Component was not completed successfully
}
f_checkCseSimuStatus();
}
/**
* @desc Sending of an Adapter Control primitive
* @param event Action to be performed by TA
* @param data Corresponding information for the correct execution of the given action
* @verdict
*/
function f_checkCseSimuStatus() runs on CseSimu {
if (getverdict != pass) {
//f_ae_postamble_deleteResources();
// Tear down
//f_cfAeTesterDown();
f_cse_postamble_deleteResourcesCSE();
//Tear down
if(vc_config == e_cf03) {
f_cf03Down();
} else if (vc_config ==e_cf04) {
f_cf04Down();
} else if (vc_config == e_cf02CseSimuMaster) {
f_cf02DownCseSimuMaster();
}
kill;
}
}
/**
* @desc Sending of an Adapter Control primitive
* @param event Action to be performed by TA
* @param data Corresponding information for the correct execution of the given action
* @verdict
*/
function f_sendAcPrimitive(in charstring p_event, in charstring p_data) runs on Tester {
var charstring v_data := "" & p_data; // clear encoding rules (ttwb issue ?)
acPort.send(AcRequestPrimitive:{p_event, {charstring := v_data}});
}
function f_sendUtPrimitive(template UtTriggerPrimitive p_utRequest, in universal charstring p_action) runs on Tester {
if (PX_UT_IMPLEMENTED){
p_utRequest.requestPrimitive.requestIdentifier := "m_uttriggerPrimitive" & f_rnd(1, 1000000);
deactivate;
utPort.send(valueof(p_utRequest));
tc_wait.start;
alt{
[] utPort.receive(mw_utResponseOK) {
tc_wait.stop;
setverdict(pass, __SCOPE__, " : Triggering message is successfully received!");
}
[] utPort.receive(mw_utResponseKO) {
tc_wait.stop;
setverdict(inconc, __SCOPE__, " : Error while receiving Triggering message!");
}
[] tc_wait.timeout{
setverdict(inconc, __SCOPE__, " : Timeout due to no response received from requested SUT!");
}
}
activate(a_default());
if(vc_config == e_cf01) {
vc_a_cse := activate(a_cse_cf01());
} else if ((vc_config == e_cf02) or (vc_config == e_cf02CseSimuMaster)) {
if(vc_testSystemRole == e_ae) {
vc_a_cse := activate(a_cse_cf02_ae1());
} else if (vc_testSystemRole == e_cse) {
vc_a_cse := activate(a_cse_cf02_cse1());
}
} else if (vc_config == e_cf03) {
vc_a_ae := activate(a_ae_cf03());
} else if (vc_config == e_cf04) {
vc_a_cse := activate(a_cse_cf04());
}
}else{
action(p_action);
}
}
group AltstepFunctions {
/**
* @desc Default altstep
*/
altstep a_default() runs on Tester {
[] tc_wait.timeout {
setverdict(inconc, __SCOPE__&":INFO: Timeout while awaiting reaction of the IUT prior to Upper Tester action");
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: Timeout while awaiting the reception of a message");
}
}
}//end group altstepFunctions
/**
* @desc Get the Resource Identifier with Unstructured-CSE-relative -Resource-ID format
* @return Cleaned-up resourceID
*/
function f_resourceIdCleaner(in XSD.ID p_resourceID) return XSD.ID {
var integer v_length := lengthof(p_resourceID);
var integer i;
var XSD.ID result := "";
//log("p_resourceID: " & p_resourceID);
for (i := v_length - 1; i>=0; i := i-1){
if(p_resourceID[i]=="/"){
//log("result: " & result);
return result;
}
else{
result := p_resourceID[i] & result;
}
}
//log("result: " & result);
return result;
}
/**
* @desc It removes the poa from a given url
* @param p_url URL
* @return Resource Identifier
* NOT USED FOR THE TIME BEING
*/
function f_removePoa(in XSD.ID p_url) return XSD.ID {
var integer v_length := lengthof(p_url);
var integer i;
var integer v_numberOfColons := 0;
var boolean v_lookForSlash := false;
var boolean v_getURI := false;
var XSD.ID v_uri := "";
//TODO Process when FQDN is used in the URL
for (i := 0; i<v_length; i := i + 1){
if(v_getURI) {
v_uri := v_uri & p_url[i];
} else {
if(p_url[i]==":"){
v_numberOfColons := v_numberOfColons + 1;
}
if(v_numberOfColons >= 2) {
v_lookForSlash := true;
}
if(v_lookForSlash) {
if(p_url[i]=="/") {
v_getURI := true;
}
}
}
}
if(v_uri == "") {
return p_url;
} else {
return v_uri;
}
}
/**
* @desc Removal of an element from a given integer list
* @param p_list Given integer list
* @param p_valueToBeDeleted Element value to be removed
* @verdict
*/
function f_removeElementFromList (inout IntegerList p_list, in integer p_valueToBeDeleted) {
var IntegerList result := {};
var integer i;
for(i := 0; i < lengthof(p_list); i := i+1){
if(p_list[i] != p_valueToBeDeleted){
result := result & {p_list[i]};
}
}
p_list := result;
}
/**
* @desc Build a reception template from the primitiveContent sent in previous request primitive
* @param p_primitiveContent PrimitiveContent from previous request primitive
* @return Built reception template
* @verdict
*/
function f_getTemplateFromPrimitiveContent (in template PrimitiveContent p_primitiveContent) return template PrimitiveContent{
var template PrimitiveContent v_primitiveContent := omit;
if(ischosen(p_primitiveContent.container)){ // Container
v_primitiveContent := {container := mw_contentContainerBase};
if(ispresent(p_primitiveContent.container.labels)){
v_primitiveContent.container.labels := ?;
}
if(ispresent(p_primitiveContent.container.accessControlPolicyIDs)){
v_primitiveContent.container.accessControlPolicyIDs := ?;
}
if(ispresent(p_primitiveContent.container.announceTo)){
v_primitiveContent.container.announceTo := ?;
}
if(ispresent(p_primitiveContent.container.announcedAttribute)){
v_primitiveContent.container.announcedAttribute := ?;
}
if(ispresent(p_primitiveContent.container.creator)){
v_primitiveContent.container.creator := ?;
}
if(ispresent(p_primitiveContent.container.maxNrOfInstances)){
v_primitiveContent.container.maxNrOfInstances := ?;
}
if(ispresent(p_primitiveContent.container.maxByteSize)){
v_primitiveContent.container.maxByteSize := ?;
}
if(ispresent(p_primitiveContent.container.maxInstanceAge)){
v_primitiveContent.container.maxInstanceAge := ?;
}
if(ispresent(p_primitiveContent.container.locationID)){
v_primitiveContent.container.locationID := ?;
}
if(ispresent(p_primitiveContent.container.ontologyRef)){
v_primitiveContent.container.ontologyRef := ?;
}
}
else if(ischosen(p_primitiveContent.aE)){ // AE
v_primitiveContent := {aE := mw_contentAeBase};
if(ispresent(p_primitiveContent.aE.labels)){
v_primitiveContent.aE.labels := ?;
}
if(ispresent(p_primitiveContent.aE.accessControlPolicyIDs)){
v_primitiveContent.aE.accessControlPolicyIDs := ?;
}
if(ispresent(p_primitiveContent.aE.announceTo)){
v_primitiveContent.aE.announceTo := ?;
}
if(ispresent(p_primitiveContent.aE.announcedAttribute)){
v_primitiveContent.aE.announcedAttribute := ?;
}
if(ispresent(p_primitiveContent.aE.appName)){
v_primitiveContent.aE.appName := ?;
}
if(ispresent(p_primitiveContent.aE.pointOfAccess)){
v_primitiveContent.aE.pointOfAccess := ?;
}
if(ispresent(p_primitiveContent.aE.ontologyRef)){
v_primitiveContent.aE.ontologyRef := ?;
}
if(ispresent(p_primitiveContent.aE.nodeLink)){
v_primitiveContent.aE.nodeLink := ?;
}
if(ispresent(p_primitiveContent.aE.contentSerialization)){
v_primitiveContent.aE.contentSerialization := ?;
}
}
else if(ischosen(p_primitiveContent.accessControlPolicy)){ // ACP
v_primitiveContent := {accessControlPolicy := mw_contentAcpBase};
if(ispresent(p_primitiveContent.accessControlPolicy.labels)){
v_primitiveContent.accessControlPolicy.labels := ?;
}
if(ispresent(p_primitiveContent.accessControlPolicy.announceTo)){
v_primitiveContent.accessControlPolicy.announceTo := ?;
}
}
else if(ischosen(p_primitiveContent.contentInstance)){ // ContentInstance
v_primitiveContent := {contentInstance := mw_contentContentInstanceBase};
if(ispresent(p_primitiveContent.contentInstance.labels)){
v_primitiveContent.contentInstance.labels := ?;
}
if(ispresent(p_primitiveContent.contentInstance.announceTo)){
v_primitiveContent.contentInstance.announceTo := ?;
}
if(ispresent(p_primitiveContent.contentInstance.announcedAttribute)){
v_primitiveContent.contentInstance.announcedAttribute := ?;
}
if(ispresent(p_primitiveContent.contentInstance.creator)){
v_primitiveContent.contentInstance.creator := ?;
}
if(ispresent(p_primitiveContent.contentInstance.contentInfo)){
v_primitiveContent.contentInstance.contentInfo := ?;
}
if(ispresent(p_primitiveContent.contentInstance.ontologyRef)){
v_primitiveContent.contentInstance.ontologyRef := ?;
}
}
else if(ischosen(p_primitiveContent.group_)){ // Group
v_primitiveContent := {group_ := mw_contentGroupBase};
if(ispresent(p_primitiveContent.group_.labels)){
v_primitiveContent.group_.labels := ?;
}
if(ispresent(p_primitiveContent.group_.accessControlPolicyIDs)){
v_primitiveContent.group_.accessControlPolicyIDs := ?;
}
if(ispresent(p_primitiveContent.group_.announceTo)){
v_primitiveContent.group_.announceTo := ?;
}
if(ispresent(p_primitiveContent.group_.announcedAttribute)){
v_primitiveContent.group_.announcedAttribute := ?;
}
if(ispresent(p_primitiveContent.group_.creator)){
v_primitiveContent.group_.creator := ?;
}
if(ispresent(p_primitiveContent.group_.membersAccessControlPolicyIDs)){
v_primitiveContent.group_.membersAccessControlPolicyIDs := ?;
}
if(ispresent(p_primitiveContent.group_.memberTypeValidated)){
v_primitiveContent.group_.memberTypeValidated := ?;
}
if(ispresent(p_primitiveContent.group_.consistencyStrategy)){
v_primitiveContent.group_.consistencyStrategy := ?;
}
if(ispresent(p_primitiveContent.group_.groupName)){
v_primitiveContent.group_.groupName := ?;
}
}
else if(ischosen(p_primitiveContent.pollingChannel)){ // PollingChannel
v_primitiveContent := {pollingChannel := mw_contentPollingChannelBase};
if(ispresent(p_primitiveContent.pollingChannel.labels)){
v_primitiveContent.pollingChannel.labels := ?;
}
}
else if(ischosen(p_primitiveContent.schedule)){ // Schedule
v_primitiveContent := {schedule := mw_contentScheduleBase};
if(ispresent(p_primitiveContent.schedule.labels)){
v_primitiveContent.schedule.labels := ?;
}
if(ispresent(p_primitiveContent.schedule.announceTo)){
v_primitiveContent.schedule.announceTo := ?;
}
if(ispresent(p_primitiveContent.schedule.announcedAttribute)){
v_primitiveContent.schedule.announcedAttribute := ?;
}
}
else if(ischosen(p_primitiveContent.subscription)){ // Subscription
v_primitiveContent := {subscription := mw_contentSubscriptionBase};
if(ispresent(p_primitiveContent.subscription.labels)){
v_primitiveContent.subscription.labels := ?;
}
if(ispresent(p_primitiveContent.subscription.accessControlPolicyIDs)){
v_primitiveContent.subscription.accessControlPolicyIDs := ?;
}
if(ispresent(p_primitiveContent.subscription.creator)){
v_primitiveContent.subscription.creator := ?;
}
if(ispresent(p_primitiveContent.subscription.eventNotificationCriteria)){
v_primitiveContent.subscription.eventNotificationCriteria := ?;
}
if(ispresent(p_primitiveContent.subscription.expirationCounter)){
v_primitiveContent.subscription.expirationCounter := ?;
}
if(ispresent(p_primitiveContent.subscription.groupID)){
v_primitiveContent.subscription.groupID := ?;
}
if(ispresent(p_primitiveContent.subscription.notificationForwardingURI)){
v_primitiveContent.subscription.notificationForwardingURI := ?;
}
if(ispresent(p_primitiveContent.subscription.batchNotify)){
v_primitiveContent.subscription.batchNotify := ?;
}
if(ispresent(p_primitiveContent.subscription.rateLimit)){
v_primitiveContent.subscription.rateLimit := ?;
}
if(ispresent(p_primitiveContent.subscription.preSubscriptionNotify)){
v_primitiveContent.subscription.preSubscriptionNotify := ?;
}
if(ispresent(p_primitiveContent.subscription.pendingNotification)){
v_primitiveContent.subscription.pendingNotification := ?;
}
if(ispresent(p_primitiveContent.subscription.notificationStoragePriority)){
v_primitiveContent.subscription.notificationStoragePriority := ?;
}
if(ispresent(p_primitiveContent.subscription.latestNotify)){
v_primitiveContent.subscription.latestNotify := ?;
}
if(ispresent(p_primitiveContent.subscription.notificationContentType)){
v_primitiveContent.subscription.notificationContentType := ?;
}
if(ispresent(p_primitiveContent.subscription.notificationEventCat)){
v_primitiveContent.subscription.notificationEventCat := ?;
}
if(ispresent(p_primitiveContent.subscription.subscriberURI)){
v_primitiveContent.subscription.subscriberURI := ?;
}
}
else if(ischosen(p_primitiveContent.remoteCSE)){ //remoteCSE
v_primitiveContent := {remoteCSE := mw_contentRemoteCSEBase};
if(ispresent(p_primitiveContent.remoteCSE.labels)){
v_primitiveContent.remoteCSE.labels := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.accessControlPolicyIDs)){
v_primitiveContent.remoteCSE.accessControlPolicyIDs := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.announceTo)){
v_primitiveContent.remoteCSE.announceTo := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.announcedAttribute)){
v_primitiveContent.remoteCSE.announcedAttribute := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.cseType)){
v_primitiveContent.remoteCSE.cseType := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.pointOfAccess)){
v_primitiveContent.remoteCSE.pointOfAccess := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.m2M_Ext_ID)){
v_primitiveContent.remoteCSE.m2M_Ext_ID := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.trigger_Recipient_ID)){
v_primitiveContent.remoteCSE.trigger_Recipient_ID := ?;
}
if(ispresent(p_primitiveContent.remoteCSE.nodeLink)){
v_primitiveContent.remoteCSE.nodeLink := ?;
}
}
return v_primitiveContent;
}
/**
* @desc Comparison of two primitiveContent parameters
* @param p_responsePrimitiveContent Received primitiveContent
* @param p_requestPrimitiveContent Sent primitiveContent
* @verdict
*/
function f_match2PrimitiveContent (in PrimitiveContent p_responsePrimitiveContent, in template PrimitiveContent p_requestPrimitiveContent) runs on Tester {
var template PrimitiveContent v_primitiveContent;
var PrimitiveContent v_response;
v_response := p_responsePrimitiveContent;
v_primitiveContent := f_getTemplateFromPrimitiveContent(p_requestPrimitiveContent);
if(not(match(v_response, v_primitiveContent))){
setverdict(inconc, __SCOPE__&":INFO: Resource incomplete, some attribute missing ");
}
}
/**
* @desc Retrieve Year from a given timestamp
* @param p_timestamp Given timestamp
* @return Year
*/
function f_getYear(charstring p_timestamp) runs on Tester return charstring {
var charstring v_year := "";
var integer i;
for(i := 0; i <= 3; i := i+1){
v_year := v_year & p_timestamp[i];
}
return v_year;
} // end f_getYear
/**
* @desc Retrieve Month from a given timestamp
* @param p_timestamp Given timestamp
* @return Year
*/
function f_getMonth(charstring p_timestamp) runs on Tester return charstring {
var charstring v_month := "";
var integer i;
for(i := 4; i <= 5; i := i+1){
if(p_timestamp[i] != "0") {
v_month := v_month & p_timestamp[i];
}
}
return v_month;
} // end f_getYear
/**
* @desc Retrieve IP address from a given address which includes port information separated by :
* @param p_addressPort Given address
* @return IPv4 Address
*/
function f_getIpv4Address(charstring p_addressPort) runs on Tester return charstring {
var charstring v_ipv4Address := "";
var integer i:= 0;
while ((i < lengthof(p_addressPort)-1) and (p_addressPort[i] != ":")){
v_ipv4Address := v_ipv4Address & p_addressPort[i];
i := i + 1;
}
return v_ipv4Address;
} // end f_getIpv4Address
}//end of commonFunctions
group externalFunctions {
/**
* @desc Generates a oneM2M timestamp based on current time.
* Format shall be YYYYMMDDTHHMMSS
*/
external function fx_generateTimestamp() return charstring;
} // end externalFunctions
} // end of module