From 5f540a60087c5b77fdb06feaf098ef9d23debe18 Mon Sep 17 00:00:00 2001
From: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
Date: Sat, 9 Dec 2017 04:20:29 +0100
Subject: [PATCH] TC_CSE_SEC_ACP_CRE_003 and TC_CSE_SEC_ACP_CRE_004 implemented

Signed-off-by: Miguel Angel Reina Ortega <miguelangel.reinaortega@etsi.org>
---
 OneM2M_Testcases_CSE.ttcn | 136 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 136 insertions(+)

diff --git a/OneM2M_Testcases_CSE.ttcn b/OneM2M_Testcases_CSE.ttcn
index 5b2c393..b7371b8 100644
--- a/OneM2M_Testcases_CSE.ttcn
+++ b/OneM2M_Testcases_CSE.ttcn
@@ -21239,6 +21239,142 @@ module OneM2M_Testcases_CSE {
 						f_cf01Down();
 
 					}//end TC_CSE_SEC_ACP_CRE_002
+
+					/**
+					 * @desc Check that the IUT accepts the creation of a accessControlPolicy resource with privileges attribute having empty rules
+					 * 
+					 */
+					testcase TC_CSE_SEC_ACP_CRE_003() runs on AeSimu system CseSystem {
+						// Local variables
+						var MsgIn v_response;
+						var integer v_acpIndex := -1;
+						var template PrimitiveContent v_contentResponse;
+						var RequestPrimitive v_createRequest := valueof(m_createAcpBase);
+						const ResourceType c_accessControlPolicyType := int1;
+
+						// Test control
+
+						// Test component configuration
+						f_cf01Up();
+
+						// Test adapter configuration
+
+						// Preamble
+						v_createRequest.primitiveContent.accessControlPolicy.privileges.accessControlRule_list := {};
+						
+						v_contentResponse.accessControlPolicy := mw_contentAcp_rc1;
+						v_contentResponse.accessControlPolicy.privileges.accessControlRule_list := {};
+						
+						// Test Body
+						v_createRequest := f_getCreateRequestPrimitive(c_accessControlPolicyType, v_createRequest, -1);
+						
+						mcaPort.send(m_request(v_createRequest));
+						tc_ac.start;
+						alt {
+							[] mcaPort.receive(mw_response(mw_responsePrimitive(int2001, v_contentResponse))) -> value v_response {
+								tc_ac.stop;
+								setverdict(pass, __SCOPE__ & ": Resource type " & int2str(enum2int(c_accessControlPolicyType)) & " created successfully");
+								f_checkAttributesToBeSaved(c_accessControlPolicyType, v_createRequest, v_response.primitive.responsePrimitive);
+								v_acpIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int1, -, -);
+							}
+							[] mcaPort.receive(mw_response(mw_responsePrimitive(int2001))) -> value v_response {
+								tc_ac.stop;
+								setverdict(fail, __SCOPE__ & ": Resource type " & int2str(enum2int(c_accessControlPolicyType)) & " created successfully, but wrong ACP representation");
+								f_checkAttributesToBeSaved(c_accessControlPolicyType, v_createRequest, v_response.primitive.responsePrimitive);
+								v_acpIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int1, -, -);
+							}
+							[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
+								tc_ac.stop;
+								setverdict(fail, __SCOPE__ & ": Wrong response status code");
+							}							
+							[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
+								tc_ac.stop;
+								setverdict(fail, __SCOPE__ & ": Error while creating resource type " & int2str(enum2int(c_accessControlPolicyType)));
+							}
+							[] tc_ac.timeout {
+								setverdict(fail, __SCOPE__ & ": No answer while creating resource type " & int2str(enum2int(c_accessControlPolicyType)));
+							}
+						}
+
+						f_checkAeSimuStatus();
+    						
+						//Check to see if the resource is present or not
+						if(f_isResourcePresent(v_acpIndex)) {
+							setverdict(pass, __SCOPE__ & ":INFO: Resource created");
+						} else {
+							setverdict(fail, __SCOPE__ & ":ERROR: Resource not created");
+						}
+
+						//Postamble
+						f_cse_postamble_deleteResources();
+
+						//Tear down
+						f_cf01Down();
+
+					}//end TC_CSE_SEC_ACP_CRE_003
+
+					/**
+					 * @desc Check that the IUT responds with an error when the creation of a accessControlPolicy resource with selfPrivileges attribute having empty rules
+					 * 
+					 */
+					testcase TC_CSE_SEC_ACP_CRE_004() runs on AeSimu system CseSystem {
+						// Local variables
+						var MsgIn v_response;
+						var integer v_acpIndex := -1;
+						var RequestPrimitive v_createRequest := valueof(m_createAcpBase);
+						const ResourceType c_accessControlPolicyType := int1;
+
+						// Test control
+
+						// Test component configuration
+						f_cf01Up();
+
+						// Test adapter configuration
+
+						// Preamble
+						v_createRequest.primitiveContent.accessControlPolicy.selfPrivileges.accessControlRule_list := {};
+						
+						// Test Body
+						v_createRequest := f_getCreateRequestPrimitive(c_accessControlPolicyType, v_createRequest, -1);
+						
+						mcaPort.send(m_request(v_createRequest));
+						tc_ac.start;
+						alt {
+							[] mcaPort.receive(mw_response(mw_responsePrimitive(int4000))) -> value v_response {
+								tc_ac.stop;
+								setverdict(pass, __SCOPE__ & ": Resource type " & int2str(enum2int(c_accessControlPolicyType)) & " creation correctly rejected due to empty selfPriviles accessControlRules");
+							}
+							[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
+								tc_ac.stop;
+								setverdict(fail, __SCOPE__ & ": Wrong response status code");
+							}							
+							[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
+								tc_ac.stop;
+								setverdict(fail, __SCOPE__ & ": Error while creating resource type " & int2str(enum2int(c_accessControlPolicyType)));
+								f_checkAttributesToBeSaved(c_accessControlPolicyType, v_createRequest, v_response.primitive.responsePrimitive);
+								v_acpIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, int1, -, -);
+							}
+							[] tc_ac.timeout {
+								setverdict(fail, __SCOPE__ & ": No answer while creating resource type " & int2str(enum2int(c_accessControlPolicyType)));
+							}
+						}
+
+						f_checkAeSimuStatus();
+    						
+						//Check to see if the resource is present or not
+						if(f_isResourceNotPresent(-1, v_createRequest.primitiveContent.accessControlPolicy.resourceName)) {
+							setverdict(pass, __SCOPE__ & ":INFO: Resource not created");
+						} else {
+							setverdict(fail, __SCOPE__ & ":ERROR: Resource created");
+						}
+
+						//Postamble
+						f_cse_postamble_deleteResources();
+
+						//Tear down
+						f_cf01Down();
+
+					}//end TC_CSE_SEC_ACP_CRE_004
 				
 				}// end of group Create
 			
-- 
GitLab