From 2c861ae8d7f56ed380f8fbc0906943d9eeb5a922 Mon Sep 17 00:00:00 2001
From: reinaortega <miguelangel.reinaortega@etsi.org>
Date: Thu, 29 Mar 2018 09:48:25 +0200
Subject: [PATCH] Fix #43

Signed-off-by: reinaortega <miguelangel.reinaortega@etsi.org>
---
 LibOneM2M/OneM2M_Functions.ttcn  | 12 ++++++++++--
 OneM2M_PermutationFunctions.ttcn | 21 +++++++++++++++------
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn
index 9b4d759..c051e7b 100644
--- a/LibOneM2M/OneM2M_Functions.ttcn
+++ b/LibOneM2M/OneM2M_Functions.ttcn
@@ -2211,12 +2211,20 @@ module OneM2M_Functions {
 				}
 				[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value v_request {
 					//Send response 
-					v_responsePrimitive := valueof(m_responseNotification(int2001, omit));
+					v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
 					v_responsePrimitive.requestIdentifier := v_request.primitive.requestPrimitive.requestIdentifier;
 					mcaPortIn.send(m_response(v_responsePrimitive));
 					log(__SCOPE__&": WARNING: Unexpected Notification message received");
 					repeat;
 				}
+				[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotificationVerification))) -> value v_request {
+					//Send response 
+					v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
+					v_responsePrimitive.requestIdentifier := v_request.primitive.requestPrimitive.requestIdentifier;
+					mcaPortIn.send(m_response(v_responsePrimitive));
+					log(__SCOPE__&": WARNING: Unexpected Notification for Subscription Verification message received");
+					repeat;
+				}
 			 }			
 			 
 			/**
@@ -2374,7 +2382,7 @@ module OneM2M_Functions {
 			 * @return 	Internal resource index of AE or -1 in case of failure		
 			 * @verdict	inconc if no AE registration request is received 
 			 */
-			function f_ae_preamble_registerAe(template UtTriggerPrimitive p_utRequest := m_utCreateAe) runs on CseSimu return integer {
+	 		function f_ae_preamble_registerAe(template UtTriggerPrimitive p_utRequest := m_utCreateAe) runs on CseSimu return integer {
     		
 				var MsgIn v_request;
 				var integer v_localResourceIndex, v_parentIndex;
diff --git a/OneM2M_PermutationFunctions.ttcn b/OneM2M_PermutationFunctions.ttcn
index 2c7bc62..752c810 100644
--- a/OneM2M_PermutationFunctions.ttcn
+++ b/OneM2M_PermutationFunctions.ttcn
@@ -4718,10 +4718,11 @@ module OneM2M_PermutationFunctions {
 						 //Local variables
 						 var MsgIn v_response;
 						 var RequestPrimitive v_request;
+						 var ResponsePrimitive v_responsePrimitive;
 						 var integer v_aeIndex := -1;
 						 var integer v_resourceIndex := -1;
 						 var integer v_ae2Index := -1;
-						var integer v_acpAuxIndex := -1;
+						 var integer v_acpAuxIndex := -1;
 							   
 						 // Test control
 
@@ -4751,6 +4752,9 @@ module OneM2M_PermutationFunctions {
 							f_cse_preamble_subscriptionVerification(v_ae2Index, p_createRequestPrimitive, p_resourceType);
 
 						 	v_resourceIndex := f_cse_createResource(p_resourceType, p_createRequestPrimitive);//under the CSEBase resource
+							if(vc_ae2.running) {
+						 		vc_ae2.stop;
+						 	}
 						} else {	//ResourceType = RemoteCSE
 							vc_cse1.start(f_cse_registerRemoteCse(p_createRequestPrimitive));
 							vc_cse1.done;
@@ -4761,16 +4765,12 @@ module OneM2M_PermutationFunctions {
 						//Test Body
 						v_request := f_getUpdateRequestPrimitive(p_resourceType, v_resourceIndex, p_updateRequestPrimitive);
 						
-						if(p_resourceType == int23) {	//Subscription
+						if((p_resourceType == int23) and (ispresent(v_request.primitiveContent.subscription.notificationURI))) {	//Subscription
 							v_request.primitiveContent.subscription.notificationURI := {f_getResourceAddress(v_aeIndex)};							
 						}
 						
 						mcaPort.send(m_request(v_request));
 						
-						if(p_resourceType == int23) {	//Subscription
-							f_cse_notifyProcedure_subscriptionVerificationHandler();
-						}
-						
 						tc_ac.start;
 						alt {
 							[] mcaPort.receive(mw_response(mw_responsePrimitive(int2004))) -> value vc_response {
@@ -4785,6 +4785,15 @@ module OneM2M_PermutationFunctions {
 								tc_ac.stop;
 								setverdict(fail, __SCOPE__, ": Error while updating mandatory attribute");
 							}
+							[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotificationVerification))) -> value vc_request {
+								tc_ac.stop;
+								setverdict(pass, __SCOPE__ & ":INFO: Notification for Subscription verification received");
+								v_responsePrimitive := valueof(m_responseNotification(int2000, omit));
+								v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
+								mcaPortIn.send(m_response(v_responsePrimitive));
+								tc_ac.start;
+								repeat;
+							}
 							[] tc_ac.timeout {
 								setverdict(fail, __SCOPE__, ": No answer while updating resource type " & int2str(enum2int(p_resourceType)));
 							}
-- 
GitLab