From 3f225f7cce2d7f096795d6fb8c74210c976ac11c Mon Sep 17 00:00:00 2001
From: garciay <yann.garcia@fscom.fr>
Date: Wed, 26 Aug 2020 15:19:16 +0200
Subject: [PATCH] Rebuild project with Twb v30

---
 LibOneM2M/OneM2M_Functions.ttcn     |   4 +-
 OneM2M_Testcases_AE_Release_4.ttcn  | 121 ++++++++++++
 OneM2M_Testcases_CSE_Release_4.ttcn | 277 ++++++++++++++++++----------
 3 files changed, 307 insertions(+), 95 deletions(-)

diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn
index e9ff326..417e723 100644
--- a/LibOneM2M/OneM2M_Functions.ttcn
+++ b/LibOneM2M/OneM2M_Functions.ttcn
@@ -3286,7 +3286,7 @@ module OneM2M_Functions {
 				}	
 
 				f_checkCseSimuStatus();
-				    		
+				
 			}
 
 			/**
@@ -3307,7 +3307,7 @@ module OneM2M_Functions {
 				
 				return v_localResourceIndex;
 				
-			}//End of function		
+			}//End of function
 			
 			/**
 			 * @desc   Creation of a local resource (Test System simulating a CSE)
diff --git a/OneM2M_Testcases_AE_Release_4.ttcn b/OneM2M_Testcases_AE_Release_4.ttcn
index 635f9b0..5a0cb69 100644
--- a/OneM2M_Testcases_AE_Release_4.ttcn
+++ b/OneM2M_Testcases_AE_Release_4.ttcn
@@ -60,10 +60,131 @@ module OneM2M_Testcases_AE_Release_4 {
 							
 							group Direct_Dynamic_Authorization {
 								
+								/**
+								 * @desc	Check that the IUT processes properly basic Indirect Dynamic Authorization (Only mandatories steps applied)
+								 */
+								testcase TC_AE_SEC_DDA_CRE_001() runs on Tester system AeSystem {
+									
+									var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
+									
+									v_cse1.start(f_AE_SEC_DDA_CRE_001(e_absolute));
+									v_cse1.done;
+								}
+								
+								function f_AE_SEC_DDA_CRE_001(PrimitiveScope p_primitiveScope) runs on CseSimu system AeSystem {
+									
+									var template UtTriggerPrimitive v_utRequest := m_utCreateContainer;
+									var integer v_resourceIndex := -1;
+									var MsgIn v_request;
+									var universal charstring v_action :=	__SCOPE__ & ": Please, send a valid CREATE Request for container to ";
+									
+									if (not(PICS_ACP_SUPPORT)) {
+										setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+										stop;
+									}
+									if (not(PICS_DIRECT_DYN_AUTH_SUPPORT) or not(PICS_DYN_AUTH_SUPPORT)) {
+										setverdict(inconc, __SCOPE__ & ": Direct Dynamic Authorization support is required to run this test case");
+										stop;
+									}
+
+									// Test component configuration
+									f_cf03Up();
+									
+									// Preamble
+									// FIXME Security association establishment may be performed using AE1, E.g. TLS using AE1_ID
+									v_utRequest.requestPrimitive.to_ := f_getLocalResourceAddress(-, e_nonHierarchical, p_primitiveScope);
+									f_ae_sendUtPrimitive(v_utRequest, v_action & f_getLocalResourceAddress(-, e_nonHierarchical, p_primitiveScope));
+									
+									// Test body
+									tc_ac.start;
+									alt {
+										[] mcaPortIn.receive(mw_request(mw_createContainer(-,v_utRequest.requestPrimitive.to_))) -> value v_request {
+											tc_ac.stop;
+											setverdict(pass, __SCOPE__ & " : Container creation request received successfuly");
+											v_resourceIndex := f_processCreateRequestPrimitive(v_request.primitive.requestPrimitive); 
+											f_send(e_mcaPortIn, m_response(vc_response.primitive.responsePrimitive));
+										}
+										[] mcaPortIn.receive(mw_request(mw_createContainer())) -> value v_request {
+											tc_ac.stop;
+											setverdict(fail, __SCOPE__ & " : Create Request with unexpected target");
+											f_send(e_mcaPortIn, m_response(valueof(m_responsePrimitive(int4004, v_request.primitive.requestPrimitive.requestIdentifier, omit))));
+											stop;
+										}
+										[] tc_ac.timeout {
+											setverdict(fail, __SCOPE__ & " : No answer while creating resource");
+											stop;
+										}
+									}
+									
+									// Postamble
+									f_cf03Down();
+								}
+							
 							}//end group DirectDynamic_Authorization
 							
 							group Indirect_Dynamic_Authorization {
 								
+								/**
+								 * @desc	Check that the IUT processes properly basic Indirect Dynamic Authorization (Only mandatories steps applied)
+								 */
+								testcase TC_AE_SEC_IDA_CRE_001() runs on Tester system AeSystem {
+									
+									var CseSimu v_cse1 := CseSimu.create("CSE1") alive;
+									
+									v_cse1.start(f_AE_SEC_IDA_CRE_001(e_absolute));
+									v_cse1.done;
+								}
+								
+								function f_AE_SEC_IDA_CRE_001(PrimitiveScope p_primitiveScope) runs on CseSimu system AeSystem {
+									
+									var template UtTriggerPrimitive v_utRequest := m_utCreateContainer;
+									var integer v_resourceIndex := -1;
+									var MsgIn v_request;
+									var universal charstring v_action :=	__SCOPE__ & ": Please, send a valid CREATE Request for container to ";
+									
+									if (not(PICS_ACP_SUPPORT)) {
+										setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+										stop;
+									}
+									if (PICS_DIRECT_DYN_AUTH_SUPPORT or not(PICS_DYN_AUTH_SUPPORT)) {
+										setverdict(inconc, __SCOPE__ & ": Indirect Dynamic Authorization support is required to run this test case");
+										stop;
+									}
+
+									// Test component configuration
+									f_cf03Up();
+									
+									// Preamble
+									// FIXME Security association establishment may be performed using AE1, E.g. TLS using AE1_ID
+									v_utRequest.requestPrimitive.to_ := f_getLocalResourceAddress(-, e_nonHierarchical, p_primitiveScope);
+									v_utRequest.primitiveContent.securityInfos.dasRequest.tokenIDs := { fx_assign_originatorToken() };
+									f_ae_sendUtPrimitive(v_utRequest, v_action & f_getLocalResourceAddress(-, e_nonHierarchical, p_primitiveScope));
+									
+									// Test body
+									tc_ac.start;
+									alt {
+										[] mcaPortIn.receive(mw_request(mw_createContainer(-,v_utRequest.requestPrimitive.to_))) -> value v_request {
+											tc_ac.stop;
+											setverdict(pass, __SCOPE__ & " : Container creation request received successfuly");
+											v_resourceIndex := f_processCreateRequestPrimitive(v_request.primitive.requestPrimitive); 
+											f_send(e_mcaPortIn, m_response(vc_response.primitive.responsePrimitive));
+										}
+										[] mcaPortIn.receive(mw_request(mw_createContainer())) -> value v_request {
+											tc_ac.stop;
+											setverdict(fail, __SCOPE__ & " : Create Request with unexpected target");
+											f_send(e_mcaPortIn, m_response(valueof(m_responsePrimitive(int4004, v_request.primitive.requestPrimitive.requestIdentifier, omit))));
+											stop;
+										}
+										[] tc_ac.timeout {
+											setverdict(fail, __SCOPE__ & " : No answer while creating resource");
+											stop;
+										}
+									}
+									
+									// Postamble
+									f_cf03Down();
+								}
+							
 							}//end group IndirectDynamic_Authorization
 							
 					}//end group Dynamic_Authorization
diff --git a/OneM2M_Testcases_CSE_Release_4.ttcn b/OneM2M_Testcases_CSE_Release_4.ttcn
index 77a587f..a0160f7 100644
--- a/OneM2M_Testcases_CSE_Release_4.ttcn
+++ b/OneM2M_Testcases_CSE_Release_4.ttcn
@@ -654,12 +654,12 @@ module OneM2M_Testcases_CSE_Release_4 {
 									stop;
 								}
 								if(not(PICS_ACP_SUPPORT)) {
-								  setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
-								  stop;
+									setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+									stop;
 								}
 								
 								// Test component configuration
-								f_cf03Up();
+								f_cf02Up();
 		
 								// Test adapter configuration
 		
@@ -682,7 +682,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 								// Test Body
 								v_createRequest := f_getCreateRequestPrimitive(int1, v_createRequest, v_aeIndex);
 								// Alter the 'From' field using AE identifier different that AE1_ID
-								v_createRequest.from_ := PX_TS_AE2.appIdStem;
+								v_createRequest.from_ := PX_TS_AE2.appId;
 								
 								f_send(e_mcaPort, m_request(valueof(v_createRequest)));
 								tc_ac.start;
@@ -704,7 +704,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 								f_cse_postamble_deleteResources();
 		
 								//Tear down
-								f_cf03Down();
+								f_cf02Down();
 		
 							}//end TC_CSE_SEC_IP_CRE_001
 							
@@ -730,9 +730,9 @@ module OneM2M_Testcases_CSE_Release_4 {
 								var integer v_aeIndex := -1;
 								var integer v_acpIndex := -1;
 								var integer v_groupIndex := -1;
-								var XSD.ID v_parentIndex;
-								var XSD.ID v_resourceIndex;
-								var template RequestPrimitive v_request := valueof(m_retrieve);
+								var integer v_parentIndex;
+								var integer v_resourceIndex;
+								var template RequestPrimitive v_request;
 								
 								// Test control
 								if (not PICS_ESC_SUPPORT) {
@@ -740,12 +740,12 @@ module OneM2M_Testcases_CSE_Release_4 {
 									stop;
 								}
 								if(not(PICS_ACP_SUPPORT)) {
-								  setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
-								  stop;
+									setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+									stop;
 								}
 								
 								// Test component configuration
-								f_cf03Up();
+								f_cf02Up();
 		
 								// Test adapter configuration
 		
@@ -763,7 +763,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 								// Test Body
 								v_request := m_retrieve(f_getResourceAddress(v_resourceIndex), f_getOriginator(v_resourceIndex));
 								// Alter the 'From' field using AE identifier different that AE1_ID
-								v_request.from_ := PX_TS_AE2.appIdStem;
+								v_request.from_ := PX_TS_AE2.appId;
 								
 								f_send(e_mcaPort, m_request(valueof(v_request)));
 								tc_ac.start;
@@ -785,7 +785,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 								f_cse_postamble_deleteResources();
 		
 								//Tear down
-								f_cf03Down();
+								f_cf02Down();
 		
 							}//end TC_CSE_SEC_IP_RET_001
 							
@@ -811,8 +811,8 @@ module OneM2M_Testcases_CSE_Release_4 {
 								var integer v_aeIndex := -1;
 								var integer v_acpIndex := -1;
 								var integer v_groupIndex := -1;
-								var XSD.ID v_parentIndex;
-								var XSD.ID v_resourceIndex;
+								var integer v_parentIndex;
+								var integer v_resourceIndex;
 								var template RequestPrimitive v_update := valueof(m_update);
 								
 								// Test control
@@ -821,12 +821,12 @@ module OneM2M_Testcases_CSE_Release_4 {
 									stop;
 								}
 								if(not(PICS_ACP_SUPPORT)) {
-								  setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
-								  stop;
+									setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+									stop;
 								}
 								
 								// Test component configuration
-								f_cf03Up();
+								f_cf02Up();
 		
 								// Test adapter configuration
 		
@@ -842,9 +842,9 @@ module OneM2M_Testcases_CSE_Release_4 {
 								v_resourceIndex := f_cse_createResource(int4, m_createContainerBase, v_parentIndex);
 								
 								// Test Body
-								v_update := m_update(f_getResourceAddress(v_resourceIndex), f_getOriginator(v_resourceIndex));
+								v_update := valueof(m_update);
 								// Alter the 'From' field using AE identifier different that AE1_ID
-								v_update.from_ := PX_TS_AE2.appIdStem;
+								v_update.from_ := PX_TS_AE2.appId;
 								
 								f_send(e_mcaPort, m_request(valueof(v_update)));
 								tc_ac.start;
@@ -866,7 +866,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 								f_cse_postamble_deleteResources();
 		
 								//Tear down
-								f_cf03Down();
+								f_cf02Down();
 		
 							}//end TC_CSE_SEC_IP_UPD_001
 							
@@ -890,9 +890,9 @@ module OneM2M_Testcases_CSE_Release_4 {
 							function f_CSE_SEC_IP_DEL_001() runs on AeSimu system CseSystem {
 								// Local variables
 								var integer v_aeIndex := -1;
-								var XSD.ID v_parentIndex;
-								var XSD.ID v_resourceIndex;
-								var template RequestPrimitive v_delete := valueof(m_delete);
+								var integer v_parentIndex;
+								var integer v_resourceIndex;
+								var template RequestPrimitive v_delete;
 								
 								// Test control
 								if (not PICS_ESC_SUPPORT) {
@@ -900,12 +900,12 @@ module OneM2M_Testcases_CSE_Release_4 {
 									stop;
 								}
 								if(not(PICS_ACP_SUPPORT)) {
-								  setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
-								  stop;
+									setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+									stop;
 								}
 								
 								// Test component configuration
-								f_cf03Up();
+								f_cf02Up();
 		
 								// Test adapter configuration
 		
@@ -923,7 +923,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 								// Test Body
 								v_delete := m_delete(f_getResourceAddress(v_resourceIndex), f_getOriginator(v_resourceIndex));
 								// Alter the 'From' field using AE identifier different that AE1_ID
-								v_delete.from_ := PX_TS_AE2.appIdStem;
+								v_delete.from_ := PX_TS_AE2.appId;
 								
 								f_send(e_mcaPort, m_request(valueof(v_delete)));
 								tc_ac.start;
@@ -945,7 +945,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 								f_cse_postamble_deleteResources();
 		
 								//Tear down
-								f_cf03Down();
+								f_cf02Down();
 		
 							}//end TC_CSE_SEC_IP_DEL_001
 							
@@ -983,16 +983,16 @@ module OneM2M_Testcases_CSE_Release_4 {
 										
 										// Test control
 										if(not(PICS_ACP_SUPPORT)) {
-										  setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
-										  stop;
+											setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+											stop;
 										}
 										if(not(PICS_DIRECT_DYN_AUTH_SUPPORT) or not(PICS_DYN_AUTH_SUPPORT)) {
-										  setverdict(inconc, __SCOPE__ & ": Direct Dynamic Authorization support is required to run this test case");
-										  stop;
+											setverdict(inconc, __SCOPE__ & ": Direct Dynamic Authorization support is required to run this test case");
+											stop;
 										}
 										
 										// Test component configuration
-										f_cf03Up();
+										f_cf02Up();
 				
 										// Test adapter configuration
 				
@@ -1025,25 +1025,26 @@ module OneM2M_Testcases_CSE_Release_4 {
 													if(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.securityInfoType != int2) { // Dynamic Authorization Response
 														setverdict(fail, __SCOPE__ & ": SecurityInfoType element is not set to '2' (Dynamic Authorization Response)");
 													}
-													if(
-														ispresent(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.authorSignReqInfo) and 
-														(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.authorSignReqInfo == true)
-													) {
-														setverdict(fail, __SCOPE__ & ": authorSignReqInfo element is not set to 'false' (Steps 6-8 not applied)");
-													}
-													if (
-														ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse) and 
-														(
-															ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokens) or
-															ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokenIDs)
-														)
-													) {
-														setverdict(pass, __SCOPE__ & ": Tokens/TokenIDs were created");
+													if (ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse)) {
+														if(
+															ispresent(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.authorSignReqInfo) and 
+															(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.authorSignReqInfo == true)
+														) {
+															setverdict(fail, __SCOPE__ & ": authorSignReqInfo element is not set to 'false' (Steps 6-8 not applied)");
+														}
+														if (
+																ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokens) or
+																ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokenIDs)
+														) {
+															setverdict(pass, __SCOPE__ & ": Tokens/TokenIDs were created");
+														} else {
+															setverdict(fail, __SCOPE__ & ": Direct Dynamic Authorization failure");
+														}
 													} else {
-														setverdict(fail, __SCOPE__ & ": Direct Dynamic Authorization failure");
+														setverdict(fail, __SCOPE__ & ": 'dynAuthRelMapResponse' field not present");
 													}
 												} else {
-													setverdict(fail, __SCOPE__ & ": Direct Dynamic Authorization failure");
+													setverdict(fail, __SCOPE__ & ": 'securityInfo' field not present");
 												}
 											}
 											[] mcaPort.receive(mw_response) -> value vc_response {
@@ -1059,7 +1060,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 										f_cse_postamble_deleteResources();
 				
 										//Tear down
-										f_cf03Down();
+										f_cf02Down();
 				
 									}//end TC_CSE_SEC_DDA_CRE_001
 									
@@ -1088,16 +1089,16 @@ module OneM2M_Testcases_CSE_Release_4 {
 										
 										// Test control
 										if(not(PICS_ACP_SUPPORT)) {
-										  setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
-										  stop;
+											setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+											stop;
 										}
 										if(not(PICS_DIRECT_DYN_AUTH_SUPPORT) or not(PICS_DYN_AUTH_SUPPORT)) {
-										  setverdict(inconc, __SCOPE__ & ": Direct Dynamic Authorization support is required to run this test case");
-										  stop;
+											setverdict(inconc, __SCOPE__ & ": Direct Dynamic Authorization support is required to run this test case");
+											stop;
 										}
 										
 										// Test component configuration
-										f_cf03Up();
+										f_cf02Up();
 				
 										// Test adapter configuration
 				
@@ -1131,39 +1132,40 @@ module OneM2M_Testcases_CSE_Release_4 {
 													if(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.securityInfoType != int2) { // Dynamic Authorization Response
 														setverdict(fail, __SCOPE__ & ": SecurityInfoType element is not set to '2' (Dynamic Authorization Response)");
 													}
-													if(
-														ispresent(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.authorSignReqInfo) and 
-														(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.authorSignReqInfo == false)
-													) {
-														setverdict(fail, __SCOPE__ & ": authorSignReqInfo element is not set to 'true' (Steps 6-8 not applied)");
-													}
-													if (
-														ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse) and 
-														(
-															ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokens) or
-															ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokenIDs)
-														)
-													) {
-														var SignatureList v_authorSigns;
-														var template RequestPrimitive v_notifyRequest := m_notifyNotification(f_getResourceAddress(v_aeIndex));
-														
-														setverdict(pass, __SCOPE__ & ": Tokens/TokenIDs were created");
-														v_state := v_state + 1;
-														// TODO Process signature of MIC???
-														// TODO Send Notify to the IUT (step 6.1 & 6.2)
-														//fx_generateAuthorSignForTokens(vc_response.primitive.responsePrimitive, v_authorSigns);
-														v_notifyRequest.authorSigns := v_authorSigns;
-														v_notifyRequest.tokens := vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokens;
-														v_notifyRequest.tokenIDs := vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokenIDs;
-														v_notifyRequest.authorSignIndicator := true;
-														f_send(e_mcaPort, m_request(valueof(v_notifyRequest)));
-														tc_ac.start;
-														repeat;
+													if (ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse)) {
+														if(
+															ispresent(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.authorSignReqInfo) and 
+															(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.authorSignReqInfo == false)
+														) {
+															setverdict(fail, __SCOPE__ & ": authorSignReqInfo element is not set to 'true' (Steps 6-8 not applied)");
+														}
+														if (
+																ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokens) or
+																ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokenIDs)
+														) {
+															var SignatureList v_authorSigns;
+															var template RequestPrimitive v_notifyRequest := m_notifyNotification(f_getResourceAddress(v_aeIndex), m_contentCreateNotification({ uRI := "" }, omit, omit, omit));
+															
+															setverdict(pass, __SCOPE__ & ": Tokens/TokenIDs were created");
+															v_state := v_state + 1;
+															// TODO Process signature of MIC???
+															// TODO Send Notify to the IUT (step 6.1 & 6.2)
+															//fx_generateAuthorSignForTokens(vc_response.primitive.responsePrimitive, v_authorSigns);
+															v_notifyRequest.authorSigns := v_authorSigns;
+															v_notifyRequest.tokens := vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokens;
+															v_notifyRequest.tokenIDs := vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokenIDs;
+															v_notifyRequest.authorSignIndicator := true;
+															f_send(e_mcaPort, m_request(valueof(v_notifyRequest)));
+															tc_ac.start;
+															repeat;
+														} else {
+															setverdict(fail, __SCOPE__ & ": Direct Dynamic Authorization failure");
+														}
 													} else {
-														setverdict(fail, __SCOPE__ & ": Direct Dynamic Authorization failure");
+														setverdict(fail, __SCOPE__ & ": 'dynAuthRelMapResponse' field not present");
 													}
 												} else {
-													setverdict(fail, __SCOPE__ & ": Direct Dynamic Authorization failure");
+													setverdict(fail, __SCOPE__ & ": 'securityInfo' field not present");
 												}
 											}
 											[v_state == 1] mcaPort.receive(mw_response(mw_responseNotify(int2000))) -> value vc_response {
@@ -1183,7 +1185,7 @@ module OneM2M_Testcases_CSE_Release_4 {
 										f_cse_postamble_deleteResources();
 				
 										//Tear down
-										f_cf03Down();
+										f_cf02Down();
 				
 									}//end TC_CSE_SEC_DDA_CRE_002
 									
@@ -1215,19 +1217,108 @@ module OneM2M_Testcases_CSE_Release_4 {
 									/**
 									 * @desc	Check that the IUT processes properly basic Indirect Dynamic Authorization (Only mandatories steps applied)
 									 */
-									testcase TC_CSE_SEC_DDA_CRE_004() runs on Tester system CseSystem {
+									testcase TC_CSE_SEC_IDA_CRE_001() runs on Tester system CseSystem {
 									
 										var AeSimu v_ae1 := AeSimu.create("AE1") alive;
 													
-										v_ae1.start(f_CSE_SEC_DDA_CRE_004());
+										v_ae1.start(f_CSE_SEC_IDA_CRE_001());
 										
 										v_ae1.done;
 										
 									}
-												
-									function f_CSE_SEC_DDA_CRE_004() runs on AeSimu system CseSystem {
-										// TODO
-									}//end TC_CSE_SEC_DDA_CRE_004
+									
+									function f_CSE_SEC_IDA_CRE_001() runs on AeSimu system CseSystem {
+										// Local variables
+										var integer v_aeIndex := -1;
+										var integer v_acpIndex := -1;
+										var integer v_groupIndex := -1;
+										var XSD.ID v_ae1ResourceId;
+										var template RequestPrimitive v_groupRequest := m_createGroup(1, -, omit, int2, -, -, -);
+										var template RequestPrimitive v_createRequest := valueof(m_createAcpBase);
+										
+										// Test control
+										if(not(PICS_ACP_SUPPORT)) {
+											setverdict(inconc, __SCOPE__ & ": AccessControlPolicy support is required to run this test case");
+											stop;
+										}
+										if(PICS_DIRECT_DYN_AUTH_SUPPORT or not(PICS_DYN_AUTH_SUPPORT)) {
+											setverdict(inconc, __SCOPE__ & ": Indirect Dynamic Authorization support is required to run this test case");
+											stop;
+										}
+										
+										// Test component configuration
+										f_cf02Up();
+										
+										// Test adapter configuration
+										
+										// Preamble
+										// FIXME Security association establishment may be performed using AE1, E.g. TLS using AE1_ID
+										
+										v_aeIndex := f_cse_preamble_registerAe(-, -);
+										
+										vc_ae1.start(f_cse_createResource(int2, m_createAe(PX_TS_AE1.appId, -, PX_TS_AE1.aeIdStem, c_defaultAe1ResourceName, omit), -1)); // AE1 is registred
+										f_aeSimu_checkComponentDoneAndGetVerdict(vc_ae1);
+										
+										v_ae1ResourceId := f_getLatestResourceAddress(vc_ae1, e_nonHierarchical, e_absolute);
+										
+										v_groupRequest.primitiveContent.group_.memberIDs := {v_ae1ResourceId};
+										
+										v_groupIndex := f_cse_createResource(int3, v_groupRequest, v_aeIndex); 
+										
+										v_createRequest := m_createAcp(-, {f_getResourceId(vc_resourcesList[v_groupIndex].resource)} , -);
+										
+										// Test Body
+										v_createRequest := f_getCreateRequestPrimitive(int1, v_createRequest, v_aeIndex);
+										v_createRequest.primitiveContent.securityInfo.dynAuthRelMapRequest.tokenIDs := { fx_assign_originatorToken() };
+										
+										f_send(e_mcaPort, m_request(valueof(v_createRequest)));
+										tc_ac.start;
+										alt {
+											[] mcaPort.receive(mw_response(mw_responsePrimitive(int2001))) -> value vc_response {
+												tc_ac.stop;
+												//Check mandatory fields
+												if (ischosen(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo)) {
+													if(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.securityInfoType != int2) { // Dynamic Authorization Response
+														setverdict(fail, __SCOPE__ & ": SecurityInfoType element is not set to '2' (Dynamic Authorization Response)");
+													}
+													if (ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse)) {
+														if(
+															ispresent(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.authorSignReqInfo) and 
+															(vc_request.primitive.requestPrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.authorSignReqInfo == true)
+														) {
+															setverdict(fail, __SCOPE__ & ": authorSignReqInfo element is not set to 'false' (Steps 6-8 not applied)");
+														}
+														if (
+																ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokens) or
+																ispresent(vc_response.primitive.responsePrimitive.primitiveContent.securityInfo.dynAuthRelMapResponse.tokenIDs)
+														) {
+															setverdict(pass, __SCOPE__ & ": Tokens/TokenIDs were created");
+														} else {
+															setverdict(fail, __SCOPE__ & ": Direct Dynamic Authorization failure");
+														}
+													} else {
+														setverdict(fail, __SCOPE__ & ": 'dynAuthRelMapResponse' field is not present");
+													}
+												} else {
+													setverdict(fail, __SCOPE__ & ": 'securityInfo' field is not present");
+												}
+											}
+											[] mcaPort.receive(mw_response) -> value vc_response {
+												tc_ac.stop;
+												setverdict(fail, __SCOPE__ & ": Wrong response status code");
+											}
+											[] tc_ac.timeout {
+												setverdict(fail, __SCOPE__ & ": No answer while creating resource");
+											}
+										}
+										
+										//Postamble
+										f_cse_postamble_deleteResources();
+										
+										//Tear down
+										f_cf02Down();
+										
+									}//end TC_CSE_SEC_IDA_CRE_001
 									
 								}// end of group Create
 								
-- 
GitLab