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

Contributions from ETSI STF510 (SmartAppliances). New functions and templates...


Contributions from ETSI STF510 (SmartAppliances). New functions and templates for AE testing and Semantic testing
Signed-off-by: Miguel Angel Reina Ortega's avatarMiguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
parent 242d84ac
......@@ -7,7 +7,7 @@
*
* @author ETSI
* @version $URL: https://forge.etsi.org/svn/oneM2M/trunk/ttcn/LibOneM2M/OneM2M_Functions.ttcn $
* $Id: OneM2M_Functions.ttcn 199 2016-12-04 21:49:51Z reinaortega $
* $Id: OneM2M_Functions.ttcn 201 2016-12-14 13:47:17Z berge $
* @desc Module containing functions for oneM2M
*
*/
......@@ -61,7 +61,10 @@ module OneM2M_Functions {
} // end f_cf02Up
function f_cf03Up() runs on CseTester {
/**
* @desc Ports mapping and default behaviour activation for Config 03
*/
function f_cf03Up() runs on AeTester {
// Variables
......@@ -69,14 +72,23 @@ module OneM2M_Functions {
map(self:mcaPort, system:mcaPort);
map(self:acPort, system:acPort);
activate(a_default());
activate(a_cse_cf01());
activate(a_ae_cf03());
// Connect
//Initialze the IUT
} // end f_cf03Up
/**
* @desc Ports unmapping for Config 03
*/
function f_cf03Down() runs on AeTester {
unmap(self:mcaPort, system:mcaPort);
unmap(self:acPort, system:acPort);
}
/**
* @desc Ports unmapping
* @verdict
......@@ -745,18 +757,146 @@ module OneM2M_Functions {
group aeFunctions {
group preambleFunctions {
/**
* @desc Waits for AE registration request and process it
* @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() runs on AeTester return integer {
var MsgIn v_request;
var Contents[-] v_modifiedResource;
var integer v_resourceIndex, v_parentIndex;
var RequestPrimitive v_rp;
tc_ac.start;
alt {
[] mcaPort.receive(mw_request(mw_createAe)) -> value v_request {
tc_ac.stop;
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getResourceIndex(v_rp.to_);
v_resourceIndex := f_ae_createResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType, v_modifiedResource);
if(v_resourceIndex != -1) {
mcaPort.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, {any_1 := {v_modifiedResource}})));
log("Preamble: Application registered successfuly");
}
else {
mcaPort.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
setverdict(inconc, testcasename() & ": AE registration failed");
}
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": AE registration request not received");
stop;
}
}
return v_resourceIndex;
}
} // 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_createResource(in PrimitiveContent p_resource, in integer p_parentIndex, in ResourceType p_resourceType, out Contents[-] p_modifiedResource) runs on AeTester return integer {
var integer v_resourceIndex;
// AE
if(p_resourceType == int2 and ischosen(p_resource.any_1[0].AE_optional)) {
var AE_optional v_ae := p_resource.any_1[0].AE_optional;
var AE_optional v_aeModified;
v_resourceIndex := lengthof(vc_resourcesList) - 1;
v_ae.resourceType := p_resourceType;
v_ae.parentID := int2str(p_parentIndex);
v_ae.creationTime := fx_generateTimestamp();
v_ae.lastModifiedTime := v_ae.creationTime;
v_ae.resourceID := "ae" & int2char(v_resourceIndex);
v_ae.aE_ID := "ae" & int2char(v_resourceIndex);
v_ae.resourceName := "ae" & int2char(v_resourceIndex);
v_aeModified.parentID := v_ae.parentID;
v_aeModified.creationTime := v_ae.creationTime;
v_aeModified.lastModifiedTime := v_ae.lastModifiedTime;
v_aeModified.resourceID := v_ae.resourceID;
v_aeModified.aE_ID := v_ae.aE_ID;
v_aeModified.resourceName := v_ae.resourceName;
p_resource.any_1[0].AE_optional := v_ae;
p_modifiedResource.AE_optional := v_aeModified;
return f_setResource(p_resource, p_parentIndex);
}
// TODO: implement other resource types
// Error
return -1;
}
} // end helpingFunctions
group altstepFunctions {
/**
* @desc Ae altstep
*/
altstep a_ae_default() runs on AeTester {
var MsgIn v_request;
[] mcaPort.receive(mw_request(?)) -> value v_request {
log("a_default: WARNING: Unexpected request received");
mcaPort.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
repeat;
}
[] mcaPort.receive {
log("a_default: 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 AeTester {
var MsgIn v_request;
var Contents[-] v_modifiedResource;
var integer v_resourceIndex, v_parentIndex;
var RequestPrimitive v_rp;
[] mcaPort.receive(mw_request(mw_create)) -> value v_request {
v_rp := v_request.primitive.requestPrimitive;
v_parentIndex := f_getResourceIndex(v_rp.to_);
v_resourceIndex := f_ae_createResource(v_rp.primitiveContent, v_parentIndex, v_rp.resourceType, v_modifiedResource);
if(v_resourceIndex != -1) {
mcaPort.send(m_response(m_responsePrimitive_content(int2001, v_rp.requestIdentifier, {any_1 := {v_modifiedResource}})));
}
else {
mcaPort.send(m_response(m_responsePrimitive(int5000, v_request.primitive.requestPrimitive.requestIdentifier)));
}
repeat;
}
[] a_ae_default();
}
}//end group altstepFunctions
......@@ -992,13 +1132,23 @@ module OneM2M_Functions {
}
/**
* @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.AnyURI p_address) return integer {
return -1; //TODO
}
/**
* @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 CseTester return XSD.ID {
function f_getResourceAddress(integer p_targetResourceIndex := -1) runs on Tester return XSD.ID {
var XSD.ID v_resourceAddress;
if(PX_ADDRESSING_FORMAT == e_cseRelative) {
......@@ -1103,6 +1253,22 @@ module OneM2M_Functions {
}
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 AeTester return XSD.ID {
if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.any_1[0].AE_optional)) {
return vc_resourcesList[p_targetResourceIndex].resource.any_1[0].AE_optional.aE_ID;
}
log("f_getAeId: WARNING: p_targetResourceIndex does not refer to AE resource");
return "";
} // end f_getAeId
}//end group getSetFunctions
......@@ -1140,4 +1306,14 @@ module OneM2M_Functions {
}//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
......@@ -7,7 +7,7 @@
*
* @author ETSI
* @version $URL: https://forge.etsi.org/svn/oneM2M/trunk/ttcn/LibOneM2M/OneM2M_Templates.ttcn $
* $Id: OneM2M_Templates.ttcn 188 2016-11-29 05:33:13Z berge $
* $Id: OneM2M_Templates.ttcn 200 2016-12-14 10:33:01Z berge $
* @desc Module containing templates for oneM2M
*
*/
......@@ -362,6 +362,37 @@ module OneM2M_Templates {
};
/**
* @desc Base Reception template for create operation
*/
template RequestPrimitive mw_create(template XSD.ID p_from := *, template XSD.ID p_to := ?) := {
operation := int1,
to_ := ?,
from_ := p_from,
requestIdentifier := ?,
resourceType := ?,
primitiveContent := {
any_1 := ?
},
roleIDs := *,
originatingTimestamp := *,
requestExpirationTimestamp := *,
resultExpirationTimestamp := *,
operationExecutionTime := *,
responseType := *,
resultPersistence := *,
resultContent := *,
eventCategory := *,
deliveryAggregation := *,
groupRequestIdentifier := *,
filterCriteria := *,
discoveryResultType := *,
tokens := *,
tokenIDs := *,
localTokenIDs := *,
tokenRequestIndicator := *
}
/**
* @desc Base CREATE request primitive for AE resource (AUX)
*/
......@@ -404,6 +435,16 @@ module OneM2M_Templates {
}
};
/**
* @desc Reception template for AE registration
*/
template RequestPrimitive mw_createAe(template XSD.ID p_from := *, template XSD.ID p_to := ?) modifies mw_create := {
resourceType := int2,
primitiveContent := {
any_1 := {{AE_optional := ?}}
}
};
template (value) RequestPrimitive m_createAeAux(template (omit) AcpType p_accessControlPolicyIDs := omit, in template (omit) PoaList p_poaList) modifies m_create := {
from_ := PX_AE_ID_STEM,//TODO We should use omit, "s", or "c"//@Martin
requestIdentifier := testcasename() & "-m_createAe" & f_rnd(1, 1000000),
......@@ -480,6 +521,36 @@ module OneM2M_Templates {
}
};
/**
* @desc Reception template for CREATE Container
*/
template RequestPrimitive mw_createContainer(template XSD.ID p_from := *, template XSD.ID p_to := ?) modifies mw_create := {
resourceType := int3,
primitiveContent := {
any_1 := {{Container_optional := ?}}
}
};
/**
* @desc Reception template for CREATE FlexContainer
*/
template RequestPrimitive mw_createFlexContainer(template XSD.ID p_from := *, template XSD.ID p_to := ?) modifies mw_create := {
resourceType := int28,
primitiveContent := {
any_1 := {{FlexContainer_optional := ?}}
}
};
/**
* @desc Reception template for CREATE GenericInterworkingOperationInstance
*/
template RequestPrimitive mw_createGenericIwkOpInstance(template XSD.ID p_from := *, template XSD.ID p_to := ?) modifies mw_create := {
resourceType := int28, // FIXME: not found in TS004
primitiveContent := {
any_1 := {{GenericInterworkingOperationInstance_optional := ?}}
}
};
template (value) RequestPrimitive m_createContentInstance(XSD.ID p_parentResourceAddress, XSD.String p_primitiveContent) modifies m_create := {
to_ := p_parentResourceAddress,
from_ := "admin:admin",
......@@ -624,7 +695,16 @@ module OneM2M_Templates {
};
/**
* @desc Reception template for SemanticDescriptor creation
*/
template RequestPrimitive mw_createSemanticDescriptor(template XSD.ID p_from := *, template XSD.ID p_to := ?, template SemanticDescriptor_optional p_semanticDescriptor := mw_contentCreateSemanticDescriptor) modifies mw_create := {
resourceType := int24,
primitiveContent := {
any_1 := {{SemanticDescriptor_optional := p_semanticDescriptor}}
}
};
}//end group Create
group Delete {
......@@ -1150,7 +1230,40 @@ module OneM2M_Templates {
notificationForwardingURI := p_notifForwardingURI,
iPEDiscoveryRequest := omit
};
/**
* @desc Base primitiveContent for CREATE operation for SemanticDescriptor resource
*/
template SemanticDescriptor_optional mw_contentCreateSemanticDescriptor := {
resourceName := *, //O
resourceType := omit, //NP
resourceID := omit, //NP
parentID := omit, //NP
creationTime := omit, //NP
lastModifiedTime := omit, //NP
labels := *, //O
accessControlPolicyIDs := *, //O
expirationTime := *, //O
dynamicAuthorizationConsultationIDs := *, //?
announceTo := *, //O
announcedAttribute := *, //O
creator := *, //O
descriptorRepresentation := ?, //M
semanticOpExec := omit, //NP
descriptor := ?, //M
ontologyRef := *, //O
relatedSemantics := *, //O
choice := * //?
}
/**
* @desc primitiveContent for CREATE operation for SemanticDescriptor resource, with specific OntologyRef
* @param p_ontologyRef Expected OntologyRef value
*/
template SemanticDescriptor_optional mw_contentCreateSemanticDescriptor_ontologyRef(template XSD.AnyURI p_ontologyRef) modifies mw_contentCreateSemanticDescriptor := {
ontologyRef := p_ontologyRef
}
}//end group ContentCreate
group ContentUpdate {
......@@ -2029,6 +2142,36 @@ module OneM2M_Templates {
}//end group SpecialContents
group ResponsePrimitives {
/**
* @desc Base template for sending ResponsePrimitive
* @param p_statusCode Status code
* @param p_requestId Request ID of the corresponding request
*/
template (value) ResponsePrimitive m_responsePrimitive(in ResponseStatusCode p_statusCode, in RequestID p_requestId) := {
responseStatusCode := p_statusCode,
requestIdentifier := p_requestId,
primitiveContent := omit,
to_ := omit,
from_ := omit,
originatingTimestamp := omit,
resultExpirationTimestamp := omit,
eventCategory := omit,
contentStatus := omit,
contentOffset := omit,
assignedTokenIdentifiers := omit,
tokenRequestInformation := omit
};
/**
* @desc Base template for sending ResponsePrimitive
* @param p_statusCode Status code
* @param p_requestId Request ID of the corresponding request
*/
template (value) ResponsePrimitive m_responsePrimitive_content(in ResponseStatusCode p_statusCode, in RequestID p_requestId, in PrimitiveContent p_content) modifies m_responsePrimitive := {
primitiveContent := p_content
}
template ResponsePrimitive mw_responsePrimitive(ResponseStatusCode p_statusCode) := {
responseStatusCode := p_statusCode,
requestIdentifier := ?,
......
......@@ -7,7 +7,7 @@
*
* @author ETSI
* @version $URL: https://forge.etsi.org/svn/oneM2M/trunk/ttcn/LibOneM2M/OneM2M_Types.ttcn $
* $Id: OneM2M_Types.ttcn 170 2016-11-21 15:53:54Z reinaortega $
* $Id: OneM2M_Types.ttcn 201 2016-12-14 13:47:17Z berge $
* @desc Test System module for oneM2M
*
*/
......@@ -6685,6 +6685,29 @@ group optionalResourceTypes {
variant (choice.choice_list[-]) "untagged";
};
type record FlexContainer_optional
{
ResourceName resourceName optional,
ResourceType resourceType optional,
XSD.ID resourceID optional,
NhURI parentID optional,
Timestamp creationTime optional,
Timestamp lastModifiedTime optional,
Labels labels optional,
AcpType accessControlPolicyIDs optional,
Timestamp expirationTime optional,
ListOfURIs dynamicAuthorizationConsultationIDs optional,
ListOfURIs announceTo optional,
ListOfNCNames announcedAttribute optional,
XSD.NonNegativeInteger stateTag optional,
XSD.ID creator optional,
XSD.AnyURI containerDefinition optional,
XSD.AnyURI ontologyRef optional
}
with {
variant "name as uncapitalized";
variant (resourceName) "attribute";
};
//added by @Naum
type record CSEBase_optional
......@@ -6958,6 +6981,85 @@ group optionalResourceTypes {
variant (choice.choice_list[-]) "untagged";
};
type record SemanticDescriptor_optional {
XSD.NCName resourceName optional,
ResourceType resourceType optional,
XSD.ID resourceID optional,
NhURI parentID optional,
Timestamp creationTime optional,
Timestamp lastModifiedTime optional,
Labels labels optional,
AcpType accessControlPolicyIDs optional,
Timestamp expirationTime optional,
ListOfURIs dynamicAuthorizationConsultationIDs optional,
ListOfURIs announceTo optional,
record length(1 .. infinity) of XSD.NCName announcedAttribute optional,
XSD.ID creator optional,
DescriptorRepresentation descriptorRepresentation optional,
Sparql semanticOpExec optional,
XSD.Base64Binary descriptor optional,
XSD.AnyURI ontologyRef optional,
ListOfURIs relatedSemantics optional,
union {
record length(1 .. infinity) of ChildResourceRef childResource_list,
record length(1 .. infinity) of Subscription subscription_list
} choice optional
}
with {
variant "name as uncapitalized";
variant "element";
variant (resourceName) "attribute";
variant (announcedAttribute) "list";
variant (choice) "untagged";
variant (choice.childResource_list) "untagged";
variant (choice.childResource_list[-]) "name as 'childResource'";
variant (choice.subscription_list) "untagged";
variant (choice.subscription_list[-]) "name as 'subscription'";
};
type record GenericInterworkingOperationInstance_optional
{
ResourceName resourceName optional,
ResourceType resourceType optional,
XSD.ID resourceID optional,
NhURI parentID optional,
Timestamp creationTime optional,
Timestamp lastModifiedTime optional,
Labels labels optional,
AcpType accessControlPolicyIDs optional,
Timestamp expirationTime optional,
ListOfURIs dynamicAuthorizationConsultationIDs optional,
ListOfURIs announceTo optional,
ListOfNCNames announcedAttribute optional,
XSD.NonNegativeInteger stateTag optional,
XSD.ID creator optional,
XSD.AnyURI containerDefinition optional,
XSD.AnyURI ontologyRef optional,
XSD.String operationName optional,
XSD.String operationState optional,
ListOfDataLinks inputDataPointLinks optional,
ListOfDataLinks outputDataPointLinks optional,
ListOfDataLinks inputLinks optional,
ListOfDataLinks outputLinks optional,
union {
record length(1 .. infinity) of ChildResourceRef childResource_list,
record length(1 .. infinity) of union {
SemanticDescriptor semanticDescriptor,
Subscription subscription
} choice_list
} choice optional
}
with {
variant "name as uncapitalized";
variant "element";
variant (resourceName) "attribute";
variant (choice) "untagged";
variant (choice.childResource_list) "untagged";
variant (choice.childResource_list[-]) "name as 'childResource'";
variant (choice.choice_list) "untagged";
variant (choice.choice_list[-]) "untagged";
};
}//end group
......@@ -7108,5 +7210,5 @@ with {
encode "XML";
variant "namespace as 'http://www.onem2m.org/xml/protocols' prefix 'm2m'";
variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
extension "anytype Notification, AggregatedNotification, AggregatedResponse, ServiceSubscribedAppRule_optional, charstring, AnyURI, AttributeList, AE, AccessControlPolicy, AccessControlPolicy_optional, ACP_update_invalid, AE_optional, AE_update_invalid,AEAnnc_optional, Container_optional, CSEBase_optional, Container_update_invalid, ContentInstance_optional, Group_optional, Group_update_invalid, Schedule_optional, Schedule_update_invalid, Subscription_optional, Subscription_update_invalid, PollingChannel_optional, PollingChannel_update_invalid, LocationPolicy_optional, LocationPolicy_update_invalid"
extension "anytype Notification, AggregatedNotification, AggregatedResponse, ServiceSubscribedAppRule_optional, charstring, AnyURI, AttributeList, AE, AccessControlPolicy, AccessControlPolicy_optional, ACP_update_invalid, AE_optional, AE_update_invalid,AEAnnc_optional, Container_optional, CSEBase_optional, Container_update_invalid, ContentInstance_optional, Group_optional, Group_update_invalid, Schedule_optional, Schedule_update_invalid, Subscription_optional, Subscription_update_invalid, PollingChannel_optional, PollingChannel_update_invalid, LocationPolicy_optional, LocationPolicy_update_invalid, SemanticDescriptor_optional, FlexContainer_optional, GenericInterworkingOperationInstance_optional"
}
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