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

Merge branch 'REG'

parents 0da5d59f 03dab114
......@@ -29,18 +29,34 @@ module OneM2M_Functions {
*/
function f_cf01Up() runs on M2M {
// Variables
// Variables
// Map
map(self:mcaPort, system:mcaPort);
map(self:acPort, system:acPort);
activate(a_default());
// Map
map(self:mcaPort, system:mcaPort);
map(self:acPort, system:acPort);
activate(a_default());
// Connect
// Connect
//Initialze the IUT
//Initialze the IUT
} // end f_cf01Up
} // end f_cf01Up
function f_cf02Up() runs on M2M {
// Variables
// Map
map(self:mcaPort, system:mcaPort);
map(self:mccPort, system:mccPort);
map(self:acPort, system:acPort);
activate(a_default());
// Connect
//Initialze the IUT
} // end f_cf02Up
}//end group configFunctions
......@@ -71,7 +87,7 @@ module OneM2M_Functions {
//TODO Test, to be removed
v_request.to_ := f_addPrefix(f_getResourceAddress());
mcaPort.send(m_request(v_request));
mcaPort.send(m_request(v_request));
//mcaPort.send(m_request(m_createAeAux(p_name, {PX_URI_CSE & PX_CSE_NAME & "/" & c_acpAuxName})));
} else {
mcaPort.send(m_request(m_createAeAux()));
......@@ -113,6 +129,19 @@ module OneM2M_Functions {
return v_aeAuxIndex;
}
//Added by @Naum
function f_preamble_prepareCSE(in template ListOfM2MID p_allowedAEs, in template (value) AccessControlOperations p_allowedOperations := int63) runs on M2M return integer{//c_CRUDNDi
var M2MResponsePrimitive v_response;
var integer v_serviceSubscribedAppRuleIndex := -1;
var RequestPrimitive v_request;
v_serviceSubscribedAppRuleIndex := f_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
return v_serviceSubscribedAppRuleIndex;
}
}//end group preambleFunctions
......@@ -171,7 +200,15 @@ module OneM2M_Functions {
*/
function f_postamble_default() runs on M2M {
unmap(self:mcaPort, system:mcaPort);
unmap(self:mcaPort, system:mcaPort);
unmap(self:acPort, system:acPort);
//stop;
}
function f_postamble_CF02() runs on M2M {
unmap(self:mcaPort, system:mcaPort);
unmap(self:mccPort, system:mccPort);
unmap(self:acPort, system:acPort);
//stop;
}
......@@ -210,11 +247,11 @@ module OneM2M_Functions {
*/
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);
p_request.from_ := f_getOriginator(p_parentIndex);
p_request.to_ := f_addPrefix(f_getResourceAddress(p_parentIndex));
p_request.to_ := f_addPrefix(f_getResourceAddress(p_parentIndex));
//p_request.name := p_name;
//p_request.name := p_name;
if (p_resourceType == int1) {//AccessControlPolicy
......@@ -602,12 +639,12 @@ module OneM2M_Functions {
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"}
accessControlOperations := valueof(p_allowedOperations),
accessControlContexts_list := omit
}
};
{
accessControlOriginators := PX_ACOR, //{"admin:admin"}
accessControlOperations := valueof(p_allowedOperations),
accessControlContexts_list := omit
}
};
mcaPort.send(m_request(v_request));
tc_ac.start;
......
......@@ -47,7 +47,15 @@ module OneM2M_Templates {
protocolBinding := PX_PROTOCOL_BINDING,
serialization := PX_SERIALIZATION,
nullFields := p_nullFields
};
//Added by @Naum
template M2MRequestPrimitive mw_request(in template RequestPrimitive p_requestPrimitive, in template (omit) AttributeList_1 p_nullFields := omit ) := {
requestPrimitive_ := p_requestPrimitive,
host := omit,
xmlNamespace := omit,
protocolBinding := omit,
serialization := omit,
nullFields := omit
};
group RequestPrimitives {
......@@ -339,6 +347,57 @@ module OneM2M_Templates {
/**
* @desc Base CREATE request primitive for AE resource (AUX)
*/
//Added by @Naum
template RequestPrimitive mw_createAEannc(template (omit) AcpType p_accessControlPolicyIDs := omit,template (omit) XSD.ID p_from := omit, XSD.ID p_appId) := {
operation := int1,
to_ := ?,
from_ := p_from,//PX_AE_ID_STEM,//TODO We should use omit, "s", or "c"
requestIdentifier := ?,
resourceType := int10002,
primitiveContent := {
any_1 := {{AEAnnc_optional := mw_contentCreateAEannc(c_aeAuxName, p_accessControlPolicyIDs, p_appId)}}
},
role := *,
originatingTimestamp := *,
requestExpirationTimestamp := *,
resultExpirationTimestamp := *,
operationExecutionTime := *,
responseType := *,
resultPersistence := *,
resultContent := *,
eventCategory := *,
deliveryAggregation := *,
groupRequestIdentifier := *,
filterCriteria := *,
discoveryResultType := *
};
//Added by @Naum
template (value) RequestPrimitive m_createAe(XSD.ID p_appId, template (omit) AcpType p_accessControlPolicyIDs := omit,template (omit) XSD.ID p_from := omit) := {
operation := int1,
to_ := "Not Initialized",
from_ := p_from,//PX_AE_ID_STEM,//TODO We should use omit, "s", or "c"
requestIdentifier := "m_createAe" & f_rnd(1, 1000000),
resourceType := int2,
primitiveContent := {
any_1 := {{AE_optional := m_contentCreateAe(c_aeAuxName, p_accessControlPolicyIDs, p_appId)}}
},
role := omit,
originatingTimestamp := omit,
requestExpirationTimestamp := omit,
resultExpirationTimestamp := omit,
operationExecutionTime := omit,
responseType := omit,
resultPersistence := omit,
resultContent := omit,
eventCategory := omit,
deliveryAggregation := omit,
groupRequestIdentifier := omit,
filterCriteria := omit,
discoveryResultType := omit
};
template (value) RequestPrimitive m_createAeAux(template (omit) AcpType p_accessControlPolicyIDs := omit ) := {
operation := int1,
to_ := "Not Initialized",
......@@ -446,6 +505,32 @@ module OneM2M_Templates {
};
//Added by @Naum
template (value) RequestPrimitive m_createCSEBase (in ServiceSubscribedAppRule p_serviceSubscribedAppRule) := {
operation := int1,
to_ := "NotInitialized",
from_ := PX_AE_ID_STEM,
requestIdentifier := "m_createCSE" & f_rnd(1, 1000000),
resourceType := int1,
primitiveContent := {
any_1 := {{CSEBase_optional := m_contentCreateCSEBase (p_serviceSubscribedAppRule)}}
},
role := omit,
originatingTimestamp := omit,
requestExpirationTimestamp := omit,
resultExpirationTimestamp := omit,
operationExecutionTime := omit,
responseType := omit,
resultPersistence := omit,
resultContent := omit,
eventCategory := omit,
deliveryAggregation := omit,
groupRequestIdentifier := omit,
filterCriteria := omit,
discoveryResultType := omit
};
/**
* @desc Base CREATE request primitive for Container resource
......@@ -687,6 +772,32 @@ module OneM2M_Templates {
};
//Added by @Naum
template (value) RequestPrimitive m_createServiceSubscribedAppRule (in ListOfM2MID p_applicableCredIDs, in ListOfM2MID p_allowedApp_IDs, in ListOfM2MID p_allowedAEs) := {
operation := int1,
to_ := "NotInitialized",
from_ := PX_AE_ID_STEM,
requestIdentifier := "m_createCSE" & f_rnd(1, 1000000),
resourceType := int1,
primitiveContent := {
any_1 := {{ServiceSubscribedAppRule_optional := m_contentCreateServiceSubscribedAppRule (p_applicableCredIDs, p_allowedApp_IDs, p_allowedAEs)}}
},
role := omit,
originatingTimestamp := omit,
requestExpirationTimestamp := omit,
resultExpirationTimestamp := omit,
operationExecutionTime := omit,
responseType := omit,
resultPersistence := omit,
resultContent := omit,
eventCategory := omit,
deliveryAggregation := omit,
groupRequestIdentifier := omit,
filterCriteria := omit,
discoveryResultType := omit
};
/**
* @desc Base CREATE request primitive for Subscription resource
......@@ -795,12 +906,8 @@ module OneM2M_Templates {
group ContentCreate {
/**
* @desc Base primitiveContent for CREATE operation for AE resource
* @param p_name Resource name
* @param p_accessControlPolicyIDs ACP IDs for the AE
*/
template (value) AE_optional m_contentCreateAe (in template (omit) AcpType p_accessControlPolicyIDs, in template (omit) XSD.String p_name := c_defaultResourceName) := {
template (value) AEAnnc_optional mw_contentCreateAEannc (in template (omit) XSD.String p_name, in template (omit) AcpType p_accessControlPolicyIDs, XSD.ID p_appId := PX_APP_ID) := {
resourceName := p_name,//O
resourceType := omit,//NP
resourceID := omit,//NP
......@@ -810,10 +917,38 @@ module OneM2M_Templates {
labels := omit,//O
accessControlPolicyIDs := p_accessControlPolicyIDs,//O
expirationTime := omit,//O
link := omit,//O
appName := omit,//O
app_ID := p_appId,//M
aE_ID := omit,//NP
pointOfAccess := omit, //{"http://127.0.0.1:1400/monitor"},//O //{"http://192.168.1.92:18080/notifications/AE"}, // TODO: Check this => AE PoA
ontologyRef := omit,//O
nodeLink := omit,//NP
requestReachability := true,//M
contentSerialization := omit,//O
choice := omit//NP
};
/**
* @desc Base primitiveContent for CREATE operation for AE resource
* @param p_name Resource name
* @param p_accessControlPolicyIDs ACP IDs for the AE
*/
template (value) AE_optional m_contentCreateAe (in template (omit) AcpType p_accessControlPolicyIDs, in template (omit) XSD.String p_name := c_defaultResourceName) := {
resourceName := p_name,//O
resourceType := omit,//NP
resourceID := omit,//NP
parentID := omit,//NP
creationTime := omit,//NP
lastModifiedTime := omit,//NP
labels := omit,//O
accessControlPolicyIDs := p_accessControlPolicyIDs,//O
expirationTime := omit,//O
announceTo := omit,//O
announcedAttribute := omit,//O
appName := omit,//O
app_ID := PX_APP_ID,//M
app_ID := p_appId,//M
aE_ID := omit,//NP
pointOfAccess := omit, //O {"http://127.0.0.1:1400/monitor"},//{"http://192.168.1.92:18080/notifications/AE"}, // TODO: Check this => AE PoA
ontologyRef := omit,//O
......@@ -861,6 +996,29 @@ module OneM2M_Templates {
choice := omit //NP
};
//added by @Naum
template (value) CSEBase_optional m_contentCreateCSEBase (in ServiceSubscribedAppRule p_serviceSubscribedAppRule) := {
resourceName := omit,
resourceType := omit,
resourceID := omit,
parentID := omit,
creationTime := omit,
lastModifiedTime := omit,
labels := omit,
accessControlPolicyIDs := omit,
cseType := omit,
cSE_ID := omit,
supportedResourceType := omit,
pointOfAccess := omit,
nodeLink := omit,
choice := {
choice_list := {{
serviceSubscribedAppRule := p_serviceSubscribedAppRule
}}
}
}
/**
* @desc Base primitiveContent for CREATE operation for Group resource
* @param p_maxNrOfMembers Max number of members
......@@ -936,6 +1094,23 @@ module OneM2M_Templates {
choice := omit//NP
};
template (value) ServiceSubscribedAppRule_optional m_contentCreateServiceSubscribedAppRule (in ListOfM2MID p_applicableCredIDs, in ListOfM2MID p_allowedApp_IDs, in ListOfM2MID p_allowedAEs) := {
resourceName := omit,
resourceType := omit,
resourceID := omit,
parentID := omit,
creationTime := omit,
lastModifiedTime := omit,
labels := omit,
accessControlPolicyIDs := omit,
expirationTime := omit,
applicableCredIDs := p_applicableCredIDs,
allowedApp_IDs := p_allowedApp_IDs,
allowedAEs := p_allowedAEs,
choice := omit
}
/**
* @desc Base primitiveContent for CREATE operation for Subscription resource
* @param p_notificationURI Notification URI
......@@ -1861,6 +2036,19 @@ module OneM2M_Templates {
}
};
template M2MResponsePrimitive mw_responseInverse(ResponseStatusCode p_statusCode) := {
responsePrimitive_ := {
responseStatusCode := complement(p_statusCode),
requestIdentifier := ?,
primitiveContent := *,
to_ := *,
from_ := *,
originatingTimestamp := *,
resultExpirationTimestamp := *,
eventCategory := *
}
};
template M2MResponsePrimitive mw_responseOK(in template PrimitiveContent p_content := *) := {
responsePrimitive_ := {
responseStatusCode := (int2000, int2001, int2002, int2004),
......
......@@ -42,7 +42,7 @@ module OneM2M_TestSystem {
/* Components */
type component M2M {
port OneM2MPort mcaPort;
//port OneM2MPort mccPort;
port OneM2MPort mccPort;
port AdapterControlPort acPort;
//timers
timer tc_ac := PX_TAC;
......@@ -57,7 +57,7 @@ module OneM2M_TestSystem {
type component M2MSystem {
port OneM2MPort mcaPort;
//port OneM2MPort mccPort;
port OneM2MPort mccPort;
port AdapterControlPort acPort;
}
......@@ -73,8 +73,8 @@ module OneM2M_TestSystem {
*/
type record M2MRequestPrimitive {
RequestPrimitive requestPrimitive_,
charstring host,
charstring xmlNamespace,
charstring host optional,
charstring xmlNamespace optional,
charstring protocolBinding optional,
charstring serialization optional,
AttributeList_1 nullFields optional
......@@ -84,6 +84,18 @@ module OneM2M_TestSystem {
ResponsePrimitive responsePrimitive_
}
type record M2MPrimitive {
union {
RequestPrimitive requestPrimitive_,
ResponsePrimitive responsePrimitive_
} primitive,
charstring host optional,
charstring xmlNamespace optional,
charstring protocolBinding optional,
charstring serialization optional,
AttributeList_1 nullFields optional
}
type record AcRequestPrimitive {
charstring event,
anytype data
......@@ -101,3 +113,7 @@ module OneM2M_TestSystem {
}
}// end of module
with {
extension "anytype charstring"
}
......@@ -106,6 +106,208 @@ module OneM2M_Testcases {
group CSE {
group Registration {
testcase TC_CSE_REG_BV_001() runs on M2M system M2MSystem {
var M2MResponsePrimitive v_response;
var RequestPrimitive v_request;
var integer v_cseBaseIndex := -1;
var integer v_resourceIndex := -1;
var ResourceType v_resourceType := int2;
// Test component configuration
f_cf01Up();
//Preambule
v_cseBaseIndex := f_preamble_prepareCSE({"C-AE-ID-STEM"});//c_CRUDNDi);
//Test Body
v_request := valueof(m_createAe(PX_APP_ID, omit, omit));
v_request := f_getCreateRequestPrimitive(v_resourceType, omit, v_request, v_cseBaseIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(int2001)) {
tc_ac.stop;
setverdict(pass, testcasename() & ": AE successfuly created.");
}
[] mcaPort.receive(mw_responseInverse(int2001)) -> value v_response{
tc_ac.stop;
setverdict(fail, testcasename() & ": Error while creating AE with status code " & int2str(enum2int(v_response.responsePrimitive_.responseStatusCode)));
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while creating AE");
}
}
// Postamble
f_postamble_deleteResources();
}
testcase TC_CSE_REG_BV_002() runs on M2M system M2MSystem {
var M2MResponsePrimitive v_response;
var RequestPrimitive v_request;
var integer v_cseBaseIndex := -1;
var ResourceType v_resourceType := int2;
// Test component configuration
f_cf01Up();
//Preambule
v_cseBaseIndex := f_preamble_prepareCSE({"C-AE-ID-STEM"});//c_CRUDNDi);
//Test Body
v_request := valueof(m_createAe(PX_APP_ID, omit, "C-AE-ID-STEM"));
v_request := f_getCreateRequestPrimitive(v_resourceType, omit, v_request, v_cseBaseIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(int2001)) {
tc_ac.stop;
setverdict(pass, testcasename() & ": AE successfuly created.");
}
[] mcaPort.receive(mw_responseInverse(int2001)) -> value v_response{
tc_ac.stop;
setverdict(fail, testcasename() & ": Error while creating AE with status code " & int2str(enum2int(v_response.responsePrimitive_.responseStatusCode)));
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while creating AE");
}
}
// Postamble
f_postamble_deleteResources();
}
testcase TC_CSE_REG_BV_003() runs on M2M system M2MSystem {
var M2MResponsePrimitive v_response;
var RequestPrimitive v_request;
var integer v_cseBaseIndex := -1;
var ResourceType v_resourceType := int2;
// Test component configuration
f_cf01Up();
//Preambule
v_cseBaseIndex := f_preamble_prepareCSE(omit);//c_CRUDNDi);
// Test Body
v_request := valueof(m_createAe(PX_APP_ID, omit, omit));
v_request := f_getCreateRequestPrimitive(v_resourceType, omit, v_request, v_cseBaseIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(int4005)) {
tc_ac.stop;
setverdict(pass, testcasename() & ": AE creation rejected.");
}
[] mcaPort.receive(mw_responseInverse(int4005)) -> value v_response{
tc_ac.stop;
setverdict(fail, testcasename() & ": Error while creating AE with status code " & int2str(enum2int(v_response.responsePrimitive_.responseStatusCode)));
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while creating AE");
}
}
// Postamble
f_postamble_deleteResources();
}
testcase TC_CSE_REG_BV_004() runs on M2M system M2MSystem {
var M2MResponsePrimitive v_response;
var RequestPrimitive v_request;
var integer v_cseBaseIndex := -1;
var ResourceType v_resourceType := int2;
// Test component configuration
f_cf01Up();
//Preambule
v_cseBaseIndex := f_preamble_prepareCSE(omit);//c_CRUDNDi);
//Test Body
v_request := valueof(m_createAe(PX_APP_ID, omit, "C-AE-ID-STEM"));
v_request := f_getCreateRequestPrimitive(v_resourceType, omit, v_request, v_cseBaseIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;
alt {
[] mcaPort.receive(mw_response(int4005)) {
tc_ac.stop;
setverdict(pass, testcasename() & ": AE creation rejected.");
}
[] mcaPort.receive(mw_responseInverse(int4005)) -> value v_response{
tc_ac.stop;
setverdict(fail, testcasename() & ": Error while creating AE with status code " & int2str(enum2int(v_response.responsePrimitive_.responseStatusCode)));
}
[] tc_ac.timeout {
setverdict(inconc, testcasename() & ": No answer while creating AE");
}
}
// Postamble
f_postamble_deleteResources();
}
testcase TC_CSE_REG_BV_005() runs on M2M system M2MSystem {
var M2MResponsePrimitive v_response;
var RequestPrimitive v_request;
var integer v_cseBaseIndex := -1;
var ResourceType v_resourceType := int2;
// Test component configuration
f_cf02Up();
//Preambule
v_cseBaseIndex := f_preamble_prepareCSE({"S"});//c_CRUDNDi);
//Test Body
v_request := valueof(m_createAe(PX_APP_ID, omit, "C-AE-ID-STEM"));
v_request := f_getCreateRequestPrimitive(v_resourceType, omit, v_request, v_cseBaseIndex);
mcaPort.send(m_request(v_request));
tc_ac.start;