Skip to content
Snippets Groups Projects

STF531 REG TCs

Closed Miguel Angel Reina Ortega requested to merge STF531-REG-TCs into Release1
+ 188
31
Compare changes
  • Side-by-side
  • Inline
Files
@@ -1424,29 +1424,62 @@ module OneM2M_Functions {
} //end f_check_notificationContent
}// end of group NotificationFunctions
}// end of group NotificationFunctions
/**
* @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_retrieveResource(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(?, -))) {
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
* @return Internal resource index of the created resource
*/
function f_cse_registerRemoteCse(in template RequestPrimitive p_requestPrimitive) runs on CseSimu return integer {
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 integer v_resourceIndex := -1;
var integer v_localResourceIndex := -1;
var PrimitiveContent v_remoteCSEResource;
v_request := f_getCreateRequestPrimitive(int16, p_requestPrimitive, -1);
mccPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
[] 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);
v_resourceIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int16, -1);
v_remoteCSEResource := f_cse_generateLocalResource(v_response.primitive.responsePrimitive.primitiveContent, 1, int16);
v_localResourceIndex := f_setLocalResource(v_remoteCSEResource, int16, -1);
}
[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) {
tc_ac.stop;
@@ -1477,6 +1510,7 @@ module OneM2M_Functions {
var MsgIn v_request;
var ResponsePrimitive v_response;
var PrimitiveContent v_remoteCSEResource;
var integer v_localResourceIndex := -1;
var integer v_resourceIndex := -1;
tc_ac.start;
@@ -1484,7 +1518,18 @@ module OneM2M_Functions {
[] mccPortIn.receive(mw_request(p_requestPrimitive)) -> value v_request {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Resource type RemoteCSE created successfuly");
v_resourceIndex := f_cse_createLocalResource(v_request.primitive.requestPrimitive.primitiveContent, 1, int16, v_remoteCSEResource);//TODO Get index from v_request.primitive.requestPrimitive.to_
v_remoteCSEResource := f_cse_generateLocalResource(v_request.primitive.requestPrimitive.primitiveContent, 1, int16);//TODO Get index from v_request.primitive.requestPrimitive.to_
v_localResourceIndex := f_setLocalResource(v_remoteCSEResource, int16, -1);
v_response := 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[v_localResourceIndex].resource.remoteCSE;
mccPort.send(m_response(v_response));
v_resourceIndex := f_setResource(v_request.primitive.responsePrimitive.primitiveContent, int16, -1);
}
[] mccPortIn.receive {
tc_ac.stop;
@@ -1555,44 +1600,43 @@ module OneM2M_Functions {
* @param p_modifiedResource Assigned and/or modified fields
* @return Internal resource index of the saved resource or -1
*/
function f_cse_createLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType, out PrimitiveContent p_myResource) runs on CseSimu return integer {
function f_cse_generateLocalResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType) runs on CseSimu return PrimitiveContent {
var integer v_resourceIndex := lengthof(vc_resourcesList);
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 == int16 and ispresent(p_resource)) {
if(ischosen(p_resource.remoteCSE)){
p_myResource.remoteCSE := p_resource.remoteCSE;
v_myResource.remoteCSE := p_resource.remoteCSE;
if(not(ispresent(p_resource.remoteCSE.resourceName))) {
p_myResource.remoteCSE.resourceName := "remoteCSE" & int2char(v_resourceIndex);
v_myResource.remoteCSE.resourceName := "remoteCSE" & int2char(v_resourceIndex);
}
p_myResource.remoteCSE.resourceType := p_resourceType;
p_myResource.remoteCSE.resourceID := "remoteCSE" & int2char(v_resourceIndex);
p_myResource.remoteCSE.parentID := f_getResourceId(vc_resourcesList[p_parentIndex].resource);
p_myResource.remoteCSE.creationTime := fx_generateTimestamp();
v_myResource.remoteCSE.resourceType := p_resourceType;
v_myResource.remoteCSE.resourceID := "remoteCSE" & int2char(v_resourceIndex);
v_myResource.remoteCSE.parentID := f_getResourceId(vc_localResourcesList[p_parentIndex].resource);
v_myResource.remoteCSE.creationTime := fx_generateTimestamp();
if(not(ispresent(p_resource.remoteCSE.expirationTime))) {
p_myResource.remoteCSE.expirationTime := "20301231T012345";
v_myResource.remoteCSE.expirationTime := "20301231T012345";
}
p_myResource.remoteCSE.lastModifiedTime := p_myResource.remoteCSE. creationTime;
p_myResource.remoteCSE.announceTo := omit;
p_myResource.remoteCSE.announcedAttribute := omit;
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
p_myResource.remoteCSE.pointOfAccess := omit;
v_myResource.remoteCSE.pointOfAccess := omit;
}
if(vc_resourcesList[v_resourceIndex].resourceType == int5) {
p_myResource.remoteCSE.m2M_Ext_ID := omit;
p_myResource.remoteCSE.trigger_Recipient_ID:= omit;
if(vc_localResourcesList[v_resourceIndex].resourceType == int5) {
v_myResource.remoteCSE.m2M_Ext_ID := omit;
v_myResource.remoteCSE.trigger_Recipient_ID:= omit;
}
p_myResource.remoteCSE.nodeLink := omit;
return f_setResource(p_myResource, p_resourceType, p_parentIndex, false);
v_myResource.remoteCSE.nodeLink := omit;
}
}
return v_resourceIndex;
return v_myResource;
}//End of function
@@ -2309,6 +2353,71 @@ module OneM2M_Functions {
}
}
/**
* @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 := -1, 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 == -1) {
return PX_CSE1_RESOURCE_ID;
} else {
return f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
}
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE1_NAME;
} else {
v_resourceAddress := f_getResourceAddress(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 == -1) {
return PX_CSE1_ID & "/" & PX_CSE1_RESOURCE_ID;
} else {
v_resourceAddress := PX_CSE_ID & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == -1) {
return PX_CSE1_ID & "/" & PX_CSE1_NAME;
} else {
v_resourceAddress := f_getResourceAddress(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 == -1) {
return PX_SP1_ID & PX_CSE1_ID;
} else {
v_resourceAddress := f_getResourceAddress(-, p_addressingMethod, p_primitiveScope) & "/" & f_getResourceId(vc_localResourcesList[p_targetResourceIndex].resource);
return v_resourceAddress;
}
} else {
if(p_targetResourceIndex == -1) {
return PX_SP1_ID & PX_CSE1_ID & "/" & PX_CSE1_NAME;
} else {
v_resourceAddress := f_getResourceAddress(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
@@ -2336,6 +2445,27 @@ module OneM2M_Functions {
}
/**
* @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 := -1) 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
Loading