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

Code documentation (part 1)


Signed-off-by: Miguel Angel Reina Ortega's avatarMiguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
parent c51b21e4
......@@ -25,7 +25,7 @@ module OneM2M_Functions {
group configFunctions {
/**
@desc
@desc Ports mapping and default behaviour activation for Config 1
*/
function f_cf01Up() runs on M2M {
......@@ -46,6 +46,12 @@ module OneM2M_Functions {
group preambleFunctions {
/**
* @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
* @return Internal AE resource index
* @verdict
*/
function f_preamble_registerAe(in template (value) AccessControlOperations p_allowedOperations := int63) runs on M2M return integer{//c_CRUDNDi
var RequestPrimitive v_request;
......@@ -55,11 +61,12 @@ module OneM2M_Functions {
if(PX_ACP_SUPPORT){
v_acpAuxIndex := f_createAccessControlPolicyAux(p_allowedOperations := p_allowedOperations);
vc_acpAuxIndex := v_acpAuxIndex;
}
if(v_acpAuxIndex != -1) {
vc_resourcesIndexToBeDeleted := {v_acpAuxIndex};
v_request := valueof(m_createAeAux({f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)}));
v_request := valueof(m_createAeAux(p_accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)}));
//TODO Test, to be removed
v_request.to_ := f_addPrefix(f_getResourceAddress());
......@@ -111,6 +118,10 @@ module OneM2M_Functions {
group postambleFunctions {
/**
* @desc Deletion of all resources created during the test case execution. IUT gets clean and ready for next execution
* @verdict
*/
function f_postamble_deleteResources() runs on M2M {
var integer i;
var XSD.ID v_resourceAddress;
......@@ -154,6 +165,10 @@ module OneM2M_Functions {
f_postamble_default();
}
/**
* @desc Ports unmapping
* @verdict
*/
function f_postamble_default() runs on M2M {
unmap(self:mcaPort, system:mcaPort);
......@@ -185,7 +200,15 @@ module OneM2M_Functions {
group getSetFunctions {
function f_getCreateRequestPrimitive(in ResourceType p_resourceType, in template (omit) AccessControlOperations p_allowedOperations, template RequestPrimitive p_request, integer p_parentIndex) runs on M2M return RequestPrimitive {
/**
* @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, integer p_parentIndex) runs on M2M return RequestPrimitive {
p_request.from_ := f_getOriginator(p_parentIndex);
......@@ -221,6 +244,14 @@ module OneM2M_Functions {
return valueof(p_request);
}
/**
* @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 M2M return RequestPrimitive {
p_request.from_ := f_getOriginator(p_resourceIndex);
......@@ -255,6 +286,12 @@ module OneM2M_Functions {
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.any_1[0].AccessControlPolicy_optional)) {
......@@ -282,6 +319,12 @@ module OneM2M_Functions {
}
/**
* @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.any_1[0].AccessControlPolicy_optional)) {
......@@ -310,6 +353,12 @@ module OneM2M_Functions {
}
/**
* @desc Resolution of the originator field (from) for a given resource
* @param p_targetResourceIndex Internal resource index of the given resource
* @return Originator for a given resource
* @verdict
*/
function f_getOriginator(integer p_targetResourceIndex := -1) runs on M2M return XSD.AnyURI {
if(p_targetResourceIndex == -1) {
......@@ -327,6 +376,13 @@ module OneM2M_Functions {
}
}
/**
* @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;
var Attribute v_attribute := {-, -};
......@@ -341,6 +397,12 @@ 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_getResourceAddress(integer p_targetResourceIndex := -1) runs on M2M return XSD.ID {
var XSD.ID v_resourceAddress;
......@@ -396,6 +458,13 @@ module OneM2M_Functions {
}
}
/**
* @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, integer p_parentIndex := -1) runs on M2M return integer {
if(isbound(vc_resourcesList)) {
......@@ -411,6 +480,14 @@ module OneM2M_Functions {
group helpingFunctions {
/**
* @desc Creation of a resource
* @param p_resourceType Resource type of the resource to be created
* @param p_requestPrimitive Template request primitive
* @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_createResource(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive, integer p_parentIndex := -1) runs on M2M return integer {
var M2MResponsePrimitive v_response;
......@@ -418,7 +495,7 @@ module OneM2M_Functions {
var XSD.ID v_resourceId;
var integer v_resourceIndex := -1;
v_request := f_getCreateRequestPrimitive(p_resourceType, omit, p_requestPrimitive, p_parentIndex);
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
......@@ -445,7 +522,14 @@ module OneM2M_Functions {
}
function f_createAccessControlPolicyAux(in template (value) XSD.String p_acpName := "MyAcp", in template (value) AccessControlOperations p_allowedOperations := int63) runs on M2M return integer{
/**
* @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_createAccessControlPolicyAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) AccessControlOperations p_allowedOperations := int63) runs on M2M return integer{
var RequestPrimitive v_request;
var M2MResponsePrimitive v_response;
var integer v_acpAuxIndex := -1;
......@@ -481,7 +565,13 @@ module OneM2M_Functions {
}
function f_createContainerResourceAux (XSD.ID p_parentResourceAddress, integer p_parentIndex := -1) runs on M2M return integer {
/**
* @desc Creation of the auxiliar Container resource
* @param p_parentIndex Internal resource index which indicates the parent of the Container resource to be created
* @return Internal resource index of the created Container resource
* @verdict
*/
function f_createContainerResourceAux (integer p_parentIndex := -1) runs on M2M return integer {
var M2MResponsePrimitive v_response;
var RequestPrimitive v_request;
......@@ -500,12 +590,17 @@ module OneM2M_Functions {
}
function f_updateAcpAuxResource (XSD.ID p_acpAddress, in template (value) AccessControlOperations p_allowedOperations) runs on M2M {
/**
* @desc Update of the auxiliar ACP resource
* @param p_allowedOperations New allowed operations
* @verdict
*/
function f_updateAcpAuxResource (in template (value) AccessControlOperations p_allowedOperations) runs on M2M {
var RequestPrimitive v_request;
v_request := valueof(m_updateAcpBase);
v_request.to_ := f_addPrefix(p_acpAddress);
v_request.to_ := f_addPrefix(f_getResourceAddress(vc_acpAuxIndex));
v_request.primitiveContent.any_1[0].AccessControlPolicy_optional.privileges.accessControlRule_list := {
{
accessControlOriginators := PX_ACOR, //{"admin:admin"}
......@@ -519,18 +614,24 @@ module OneM2M_Functions {
alt {
[] mcaPort.receive(mw_responseOK) {
tc_ac.stop;
setverdict(pass, "f_updateAcpAuxResource: " & p_acpAddress & " resource updated successfuly");
setverdict(pass, "f_updateAcpAuxResource: " & v_request.to_ & " resource updated successfuly");
}
[] mcaPort.receive(mw_responseKO) {
tc_ac.stop;
setverdict(fail, "f_updateAcpAuxResource: Error while updating " & p_acpAddress & " resource");
setverdict(fail, "f_updateAcpAuxResource: Error while updating " & v_request.to_ & " resource");
}
[] tc_ac.timeout {
setverdict(inconc, "f_updateAcpAuxResource: No answer while updating " & p_acpAddress & " resource" );
setverdict(inconc, "f_updateAcpAuxResource: No answer while updating " & v_request.to_ & " resource" );
}
}
}
/**
* @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 event, in charstring data) runs on M2M {
var charstring v_data := "" & data; // clear encoding rules (ttwb issue ?)
......
This diff is collapsed.
......@@ -19,6 +19,9 @@ module OneM2M_TestSystem {
import from XSD all;
/* Ports */
/**
* @desc Port to transport oneM2M primitives
*/
type port OneM2MPort message {
in
M2MRequestPrimitive, M2MResponsePrimitive;
......@@ -26,6 +29,9 @@ module OneM2M_TestSystem {
M2MRequestPrimitive, M2MResponsePrimitive;
}
/**
* @desc Port to transport Adaptor Control primitives
*/
type port AdapterControlPort message {
in
AcResponsePrimitive;
......@@ -44,6 +50,7 @@ module OneM2M_TestSystem {
//global variables
var AE_optional vc_aeAux;//TODO To be removed
var AccessControlPolicy_optional vc_acpAux;
var integer vc_acpAuxIndex := -1;
var MyResourcesList vc_resourcesList;
var IntegerList vc_resourcesIndexToBeDeleted;
}
......@@ -55,6 +62,15 @@ module OneM2M_TestSystem {
}
/* Primitives */
/**
* @desc Type for the oneM2M primitives exchange
* @member requestPrimitive_ oneM2M primitive
* @member host IP Address of the destination
* @member xmlNamespace XML Namespace to be used
* @member protocolBinding Protocol binding to be used
* @member serialization Serialization to be used
* @member nullFields Fields that are to be included in the oneM2M primitive but empty, i.e. <labels></labels>
*/
type record M2MRequestPrimitive {
RequestPrimitive requestPrimitive_,
charstring host,
......
......@@ -960,7 +960,7 @@ module OneM2M_Testcases {
// Test Body
v_request := f_getCreateRequestPrimitive(p_resourceType, omit, p_requestPrimitive, v_aeIndex);
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
......@@ -1110,7 +1110,7 @@ module OneM2M_Testcases {
v_aeIndex := f_preamble_registerAe();//c_CRUDNDi);
// Test Body
v_request := f_getCreateRequestPrimitive(p_resourceType, omit, p_requestPrimitive, v_aeIndex);
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
......@@ -1197,7 +1197,7 @@ module OneM2M_Testcases {
v_resourceIndex := f_createResource(p_resourceType, p_requestPrimitive, v_aeIndex);
v_request := f_getCreateRequestPrimitive(p_resourceType, omit, p_requestPrimitive, v_aeIndex);
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
// Test Body
v_request.requestIdentifier := "Existing resource";
......@@ -1293,7 +1293,7 @@ module OneM2M_Testcases {
if(p_resourceType == int15) {
v_request := valueof(m_createPollingChannel(f_getResourceAddress(v_aeIndex), PX_AE_ID_STEM, omit));
} else {
v_request := f_getCreateRequestPrimitive(p_resourceType, omit, p_requestPrimitive, v_aeIndex);
v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, v_aeIndex);
}
mcaPort.send(m_request(v_request));
......@@ -1569,7 +1569,7 @@ module OneM2M_Testcases {
v_resourceIndex := f_createResource(p_resourceType, p_requestPrimitive, v_aeIndex);
f_updateAcpAuxResource(f_getResourceAddress(0), int61); //c_CUDNDi
f_updateAcpAuxResource(int61); //c_CUDNDi
// Test Body
mcaPort.send(m_request(m_retrieveResource(f_getResourceAddress(v_resourceIndex))));
......@@ -2543,8 +2543,10 @@ module OneM2M_Testcases {
//Check attribute 1
if(ispresent(v_responsePrimitive.primitiveContent)) {
if(ischosen(v_responsePrimitive.primitiveContent.any_1[0].Container_optional)) {
if(ispresent(v_responsePrimitive.primitiveContent.any_1[0].Container_optional.labels)){ // FIXME: CHECK: labels set to empty
setverdict(fail, testcasename() & ": Error: Labels attribute not deleted correctly")
if(ispresent(v_responsePrimitive.primitiveContent.any_1[0].Container_optional.labels)){
if(v_responsePrimitive.primitiveContent.any_1[0].Container_optional.labels != {""}) {
setverdict(fail, testcasename() & ": Error: Labels attribute not deleted correctly");
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment