Commit 0778c746 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Overall cleanup and reordering


Signed-off-by: Miguel Angel Reina Ortega's avatarreinaortega <miguelangel.reinaortega@etsi.org>
parent f105adea
......@@ -321,181 +321,187 @@ module OneM2M_Functions {
// 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;
group getFunctions {
/**
* @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);
/**
* @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.start(f_sendResponsePrimitive());
alt {
[]infoPort.receive(mw_responsePrimitiveforInfoPort) -> value v_response {
}
}
p_component.done;
f_disconnectInfoPort(p_component);
return v_response;
}
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);
/**
* @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_ae.start(f_sendPrimitiveContentRetrievedResource());
alt {
[]infoPort.receive(mw_primitiveContent) -> value v_primitiveContent {
p_component.start(f_sendRequestPrimitive());
alt {
[]infoPort.receive(mw_requestPrimitiveforInfoPort) -> value v_request {
}
}
}
p_ae.done;
f_disconnectInfoPort(p_ae);
return v_primitiveContent;
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);
/**
* @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_ae.start(f_sendPrimitiveContentRetrievedResource());
alt {
[]infoPort.receive(mw_primitiveContent) -> value v_primitiveContent {
}
}
p_ae.done;
f_disconnectInfoPort(p_ae);
return v_primitiveContent;
}
p_cse.done;
f_disconnectInfoPort(p_cse);
return v_resourceIndex;
/**
* @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;
}
/**
* @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_cse);
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_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;
}
p_component.done;
f_disconnectInfoPort(p_component);
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;
}
/**
* @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);
f_connectInfoPort(p_component);
}
/**
* @desc Sending of last primitiveContent retrieved (vc_primitiveContentRetrievedResource) through InfoPort
*/
function f_sendPrimitiveContentRetrievedResource() runs on AeSimu {
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);
}
}
infoPort.send(vc_primitiveContentRetrievedResource);
p_component.done;
f_disconnectInfoPort(p_component);
}
/**
* @desc Sending of remoteCSE resource through InfoPort
*/
function f_sendRemoteCseResource() runs on CseSimu {
infoPort.send(vc_resourcesList[vc_remoteCseIndex]);
return v_resourceIndex;
}
}
}//end of group getFunctions
/**
* @desc Sending of Ae resource through InfoPort
*/
function f_sendAeResource() runs on AeSimu {
group sendFunctions {
infoPort.send(vc_resourcesList[vc_aeAuxIndex]);
}
/**
* @desc Sending of last responsePrimitive (vc_response) through InfoPort
*/
function f_sendResponsePrimitive() runs on Tester {
/**
* @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]);
}
}
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 group sendFunctions
}// end of gropu InfoPortCommunication
group CseFunctions {
......@@ -693,7 +699,7 @@ module OneM2M_Functions {
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
vc_ae2.start(f_cse_createResource_withAcpAux(int2, m_createAe(PX_APP_ID, -, PX_AE2_ID_STEM, c_defaultAE2Name, {f_getCompletePoA("HTTP", PX_AE2_ADDRESS, "")}), -1)); // AE2 is registred
f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae2);
p_ae2Index := f_getResource(vc_ae2);
......@@ -855,7 +861,7 @@ module OneM2M_Functions {
if(not(v_deregistrationPerformed)) {
if(vc_localRemoteCseIndex != -1) {
//1) Deregistration by Registrar (Test System)
v_childResourceRefs := f_cse_retrieveChildResourceRefs({int16}, -, f_getOriginator(vc_remoteCseIndex));
v_childResourceRefs := f_cse_retrieveChildResourceRefs_cseSimu({int16}, -, f_getOriginator(vc_remoteCseIndex));
if(v_childResourceRefs != {}) {
//v_request := valueof(m_delete(v_childResourceRefs[0], f_getOriginator(vc_remoteCseIndex)));
......@@ -1168,7 +1174,7 @@ module OneM2M_Functions {
* @param p_resourceIndex Resource index of the resource to be checked
* @return boolean
*/
function f_isResourcePresent (integer p_resourceIndex) runs on AeSimu return boolean {
function f_cse_isResourcePresent (integer p_resourceIndex) runs on AeSimu return boolean {
//Check to see if the resource is present or not
mcaPort.send(f_getMsgOutPrimitive(m_request(m_retrieve(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex)))));
......@@ -1203,7 +1209,7 @@ module OneM2M_Functions {
* @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 {
function f_cse_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");
......@@ -1264,183 +1270,93 @@ module OneM2M_Functions {
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
* @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
*/
//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)
}
function f_cse_sendCreateRequestPrimitive(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on AeSimu{
var integer v_resourceIndex := -1;
vc_request.primitive.requestPrimitive := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
mcaPort.send(f_getMsgOutPrimitive(m_request(vc_request.primitive.requestPrimitive)));
}
/**
* @desc Receive response from the IUT
* @param p_requestPrimtive Received request primitive
*/
function f_cse_receiveResponse(in RequestPrimitive p_request) runs on AeSimu {
var integer v_resourceIndex := -1;
//Activate defaults when running on a PTC
f_cse_activateDefaults_ae();
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");
f_checkAttributesToBeSaved(p_request.resourceType, p_request, vc_response.primitive.responsePrimitive);
v_resourceIndex := f_setResource(vc_response.primitive.responsePrimitive.primitiveContent, p_request.resourceType);
}
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)
}
[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value vc_response {
tc_ac.stop;
setverdict(pass, __SCOPE__&":INFO: Response received with negative response status code");
}
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)
}
[] tc_ac.timeout {
setverdict(inconc, __SCOPE__&":INFO: No response received");
}
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)
}
}
}//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");
}
}
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 integer v_resourceIndex := -1;
vc_request.primitive.requestPrimitive := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
mcaPort.send(f_getMsgOutPrimitive(m_request(vc_request.primitive.requestPrimitive)));
}
}//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();