From 46e7a7379108ad13c6d70d0473a95e451aed392e Mon Sep 17 00:00:00 2001
From: aahmad <ABBAS.AHMAD@eglobalmark.com>
Date: Thu, 8 Mar 2018 16:41:01 +0100
Subject: [PATCH] Added contentSecurityInfo response message to template.
 Implemented TP CSE/ESC/BV/001 of TS0028 with one initial missing (provision
 of key and certificate)

---
 LibOneM2M/OneM2M_Templates.ttcn               | 13 ++++++
 ...2M_Testcases_CSE_Release_2_SEC_STF531.ttcn | 40 ++++++++++++++-----
 2 files changed, 44 insertions(+), 9 deletions(-)

diff --git a/LibOneM2M/OneM2M_Templates.ttcn b/LibOneM2M/OneM2M_Templates.ttcn
index c96334f..45a2592 100644
--- a/LibOneM2M/OneM2M_Templates.ttcn
+++ b/LibOneM2M/OneM2M_Templates.ttcn
@@ -1354,6 +1354,19 @@ module OneM2M_Templates {
 			escertkeMessage := omit
 		}
 		
+		/**
+		 * @desc SecurityInfo content
+		 * @param p_securityInfoType security type integer 
+		 */
+		template SecurityInfo mw_contentSecurityInfo (in SecurityInfoType p_securityInfoType, in XSD.Base64Binary p_escertkeMessage) := {
+			securityInfoType :=  p_securityInfoType,
+			dasRequest := ?,
+			dasResponse := ?,
+			esprimRandObject := ?,
+			esprimObject := ?,
+			escertkeMessage := p_escertkeMessage
+		}
+		
 		 
 		/**
 		 * @desc Base primitiveContent for CREATE operation for AEAnnc resource
diff --git a/OneM2M_Testcases_CSE_Release_2_SEC_STF531.ttcn b/OneM2M_Testcases_CSE_Release_2_SEC_STF531.ttcn
index ce89a24..4f6c2a0 100644
--- a/OneM2M_Testcases_CSE_Release_2_SEC_STF531.ttcn
+++ b/OneM2M_Testcases_CSE_Release_2_SEC_STF531.ttcn
@@ -81,10 +81,9 @@ module OneM2M_Testcases_CSE_Release_2_SEC_STF531 {
 		
 		group ESCertKE {
 			
-			testcase TC_CSE_ESC_BV_001() runs on AeSimu system CseSystem {
+			testcase TC_CSE_ESC_BV_001() runs on CseSimu system CseSystem {
 				var MsgIn v_response;
-				var integer v_aeIndex := -1;
-				var template RequestPrimitive v_requestNotify := m_notifyEmpty;
+				var template RequestPrimitive v_requestNotify := m_notify;
 				
 				//Test component configuration
 				f_cf02Up();
@@ -92,15 +91,38 @@ module OneM2M_Testcases_CSE_Release_2_SEC_STF531 {
 				// Test adapter configuration
 				
 				// Preamble
-				v_aeIndex := f_cse_preamble_registerAe();//c_CRUDNDi);
+				vc_remoteCseIndex := f_cse_registerRemoteCse(m_createRemoteCSEBase);
+				//TODO => " and the IUT has been provisioned with private key and certificate"
 				
 				//TestBody
+				v_requestNotify.to_ := f_getResourceAddress(vc_remoteCseIndex);
+				v_requestNotify.from_ := PX_CSE1_ID;
 				v_requestNotify.primitiveContent := {securityInfo := m_contentSecurityInfo(int6)};
-				v_requestNotify.primitiveContent.securityInfo.escertkeMessage := "Q2xpZW50IEhlbGxv"; //'Q2xpZW50IEhlbGxv'O => "Client Hello" Bqse64 representation  Was ''O
-				
-				
-				
-				
+				v_requestNotify.primitiveContent.securityInfo.escertkeMessage := str2oct("VExTIE1lc3NhZ2U6IENsaWVudCBIZWxsbw==");
+ 				
+ 				
+ 				mccPort.send(m_request(v_requestNotify));
+			 	tc_ac.start;
+				alt {
+					[] mccPort.receive(mw_response(mw_responsePrimitive(int2000, mw_contentSecurityInfo(int6, str2oct("VExTIE1lc3NhZ2VzOiBTZXJ2ZXIgSGVsbG8sIENlcnRpZmljYXRlKiwgU2VydmVyS2V5RXhjaGFuZ2UqLCBDZXJ0aWZpY2F0ZVJlcXVlc3QqLCBTZXJ2ZXJIZWxsb0RvbmU=")))))-> value v_response {
+						tc_ac.stop;
+						setverdict(pass, __SCOPE__ & ": Message 2 received successfully");	
+					}
+					[] mccPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
+						tc_ac.stop;
+						setverdict(fail, __SCOPE__ & ": Wrong Message received (Should be Message 2)");
+					}
+					[] mccPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
+						tc_ac.stop;
+						setverdict(fail, __SCOPE__ & ": Wrong response status code");
+					}				
+					[] tc_ac.timeout {
+						setverdict(inconc, __SCOPE__&":INFO: Timeout while awaiting the reception of a message");
+					}
+				}		
+						
+				f_cse_postamble_deleteResources();
+				f_cf02Down();
 			}
 		
 		} // end of group ESCertKE
-- 
GitLab