diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn index 9af3402db911a23fae30ce75c85ed1d10d028452..c147ed8a1be6cfd35f176c6bc33de26827a2eac2 100644 --- a/LibOneM2M/OneM2M_Functions.ttcn +++ b/LibOneM2M/OneM2M_Functions.ttcn @@ -7,7 +7,7 @@ * * @author ETSI * @version $URL: https://forge.etsi.org/svn/oneM2M/trunk/ttcn/LibOneM2M/OneM2M_Functions.ttcn $ - * $Id: OneM2M_Functions.ttcn 202 2016-12-15 15:08:33Z reinaortega $ + * $Id: OneM2M_Functions.ttcn 208 2017-01-17 09:17:22Z reinaortega $ * @desc Module containing functions for oneM2M * */ @@ -301,22 +301,9 @@ module OneM2M_Functions { v_request.from_ := vc_resourcesList[vc_resourcesIndexToBeDeleted[i]].resource.any_1[0].AE_optional.aE_ID; } } - mcaPort.send(m_request(v_request)); - tc_ac.start; - alt { - [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) { - tc_ac.stop; - log(__SCOPE__&"INFO: Resource" & v_resourceAddress & " deleted"); - } - [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) { - tc_ac.stop; - log(__SCOPE__&"INFO: Error while deleting resource " & v_resourceAddress); - } - [] tc_ac.timeout { - log(__SCOPE__&"INFO: No answer while deleting resource " & v_resourceAddress); - } - } + f_cse_deleteResource(v_request); + } } @@ -491,6 +478,33 @@ module OneM2M_Functions { } }// end f_cse_updateResource + /** + * @desc + * @param p_requestPrimitive + * @verdict + */ + function f_cse_deleteResource(in RequestPrimitive p_requestPrimitive) runs on CseTester { + var MsgIn v_response; + + mcaPort.send(m_request(p_requestPrimitive)); + + tc_ac.start; + alt { + [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) { + tc_ac.stop; + log(__SCOPE__&"INFO: Resource" & p_requestPrimitive.to_ & " deleted"); + } + [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) { + tc_ac.stop; + log(__SCOPE__&"INFO: Error while deleting resource " & p_requestPrimitive.to_); + } + [] tc_ac.timeout { + log(__SCOPE__&"INFO: No answer while deleting resource " & p_requestPrimitive.to_); + } + } + + }// end f_cse_deleteResource + /** * @desc Update of the auxiliar ACP resource * @param p_allowedOperations New allowed operations diff --git a/OneM2M_Testcases.ttcn b/OneM2M_Testcases.ttcn index 226672ae385916cdf6a84f1533808cdce5fc4fd5..21bf447ee99f73e02fc30edd6fa0528daaa4aabe 100644 --- a/OneM2M_Testcases.ttcn +++ b/OneM2M_Testcases.ttcn @@ -7,7 +7,7 @@ * * @author ETSI * @version $URL: https://forge.etsi.org/svn/oneM2M/trunk/ttcn/OneM2M_Testcases.ttcn $ - * $Id: OneM2M_Testcases.ttcn 206 2017-01-17 07:50:24Z reinaortega $ + * $Id: OneM2M_Testcases.ttcn 208 2017-01-17 09:17:22Z reinaortega $ * @desc Module containing test cases for oneM2M * */ @@ -3361,7 +3361,7 @@ module OneM2M_Testcases { var SetOfAcrs v_privileges_2 := { // accessControlRule_list := { { - accessControlOriginators := {"admin:admin"}, + accessControlOriginators := {PX_SUPER_USER}, accessControlOperations := int61, accessControlContexts_list := {}, accessControlAuthenticationFlag := omit, @@ -3387,7 +3387,7 @@ module OneM2M_Testcases { if(ispresent(v_responsePrimitive.primitiveContent)) { if(ischosen(v_responsePrimitive.primitiveContent.any_1[0].AccessControlPolicy_optional)) { //Check attribute 1 - if(not match(v_responsePrimitive.primitiveContent.any_1[0].AccessControlPolicy_optional.privileges, valueof(v_updateRequest.primitiveContent.any_1[0].AccessControlPolicy_optional.privileges))){ + if(not match(v_responsePrimitive.primitiveContent.any_1[0].AccessControlPolicy_optional.privileges.accessControlRule_list[0].accessControlOperations, v_privileges_2.accessControlRule_list[0].accessControlOperations)){ setverdict(fail, testcasename() & ": Error: Privileges attribute not updated correctly") } //Check attribute 2 @@ -4320,41 +4320,45 @@ module OneM2M_Testcases { // Preamble v_acpAuxIndex := f_cse_preamble_createAcpAux(-,-);//c_CRDNDi); v_aeIndex := f_cse_preamble_registerAe({f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)}, -);//c_CRUNDi); - v_accessControlRule_2 := valueof(m_createAcr({f_getOriginator(v_aeIndex)}, int55)); f_cse_preamble_subscriptionVerification(v_notifyHandler, v_aeIndex, v_ae2Index, p_createRequestPrimitive, p_resourceType); - if (p_resourceType == int1){ + //Update ACP Aux to remove DELETE operation rights to AE, keeping rights of SUPER USER to run postamble + v_accessControlRule_2 := valueof(m_createAcr({f_getOriginator(v_aeIndex)}, int55)); + + v_setOfArcs.accessControlRule_list := {v_accessControlRule_1, v_accessControlRule_2}; + v_updateRequest := valueof(m_updateAcpPrivileges(v_setOfArcs, -)); + v_updateRequest := f_getUpdateRequestPrimitive(int1, vc_acpAuxIndex, v_updateRequest); + + mcaPort.send(m_request(v_updateRequest)); + tc_ac.start; + alt { + [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response { + tc_ac.stop; + setverdict(pass, testcasename() & ": Attribute of resource type int1 (Acp) updated successfuly"); + } + [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response { + tc_ac.stop; + setverdict(fail, testcasename() & ": Error while updating resource type int1 (Acp)"); + } + [] tc_ac.timeout { + setverdict(inconc, testcasename() & ": No answer while updating resource type int1 (Acp)"); + } + } + + //Adjustments for ACP resource type + if(p_resourceType == int1) { p_createRequestPrimitive.primitiveContent.any_1[0].AccessControlPolicy_optional.selfPrivileges.accessControlRule_list := {v_accessControlRule_1,v_accessControlRule_2}; - } - else{ + } else { f_setAcpId(p_createRequestPrimitive, {f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)}); - v_setOfArcs.accessControlRule_list := {v_accessControlRule_1, v_accessControlRule_2}; - v_updateRequest := valueof(m_updateAcpPrivileges(v_setOfArcs, -)); - v_updateRequest := f_getUpdateRequestPrimitive(int1, vc_acpAuxIndex, v_updateRequest); - - mcaPort.send(m_request(v_updateRequest)); - tc_ac.start; - alt { - [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response { - tc_ac.stop; - setverdict(pass, testcasename() & ": Attribute of resource type int1 (Acp) updated successfuly"); - } - [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response { - tc_ac.stop; - setverdict(fail, testcasename() & ": Error while updating resource type int1 (Acp)"); - } - [] tc_ac.timeout { - setverdict(inconc, testcasename() & ": No answer while updating resource type int1 (Acp)"); - } - } } + //Creation of resource v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive, v_aeIndex); // Test Body v_request := valueof(m_deleteRequest(f_getResourceAddress(v_resourceIndex))); - v_request.from_ := f_getResourceAddress(v_aeIndex); + v_request.from_ := f_getOriginator(v_aeIndex); mcaPort.send(m_request(v_request)); tc_ac.start; @@ -4377,23 +4381,10 @@ module OneM2M_Testcases { } // Postamble - mcaPort.send(m_request(valueof(m_deleteRequest(f_getResourceAddress(v_aeIndex))))); // We are forced to delete the Ae because the delete request in the postamble_deleteResources is sent by Ae itself, witch doesn't have privileges - tc_ac.start; - alt { - [] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) { - tc_ac.stop; - log("Postamble: AE Resource deleted"); - } - [] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) { - tc_ac.stop; - log("Postamble: Error while deleting resource"); - } - [] tc_ac.timeout { - log("Postamble: No answer while deleting resource"); - } - } - f_cse_postamble_deleteResources(); + f_cse_deleteResource(valueof(m_deleteRequest(f_getResourceAddress(v_aeIndex)))); + //TODO Update vc_resourcesIndexToBeDeleted + f_cse_postamble_deleteResources(); // Tear down f_cf01Down();