From 7fdd1de365148361e0880a2a80e56508cc3aa73b Mon Sep 17 00:00:00 2001
From: reinaortega <miguelangel.reinaortega@etsi.org>
Date: Mon, 23 Nov 2020 09:56:33 +0100
Subject: [PATCH] Fix for f_cse_notifyProcedure_subscriptionVerificationHandler
 in case notification request is not received

Signed-off-by: reinaortega <miguelangel.reinaortega@etsi.org>
---
 LibOneM2M/OneM2M_Functions.ttcn | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/LibOneM2M/OneM2M_Functions.ttcn b/LibOneM2M/OneM2M_Functions.ttcn
index 57089ed..c6db8f3 100644
--- a/LibOneM2M/OneM2M_Functions.ttcn
+++ b/LibOneM2M/OneM2M_Functions.ttcn
@@ -1842,6 +1842,7 @@ module OneM2M_Functions {
 				function f_cse_notifyProcedure_subscriptionVerificationHandler(in ResponseStatusCode p_responseStatusCode := int2000) runs on AeSimu {
 					// Local variables
 					var ResponsePrimitive v_responsePrimitive;
+					var boolean v_notificationReceived := false;
 					var template Notification v_notificationRequest := mw_contentNotificationVerification;
 					
 					//Activate defaults when running on a PTC
@@ -1856,10 +1857,12 @@ module OneM2M_Functions {
 					alt {
 						[] mcaPortIn.receive(mw_request(mw_notifyNotification(v_notificationRequest))) -> value vc_request {
 							tc_ac.stop;
+							v_notificationReceived := true;
 							setverdict(pass, __SCOPE__ & ":INFO: Subscription Verification Notification received");
 						}
 						[] mcaPortIn.receive(mw_request(mw_notifyNotification(mw_contentNotification(?)))) -> value vc_request {
 							tc_ac.stop;
+							v_notificationReceived := true;
 							setverdict(inconc, __SCOPE__ & ":ERROR: Notification received but verificationRequest isn't set to TRUE");							
 						}
 						[] tc_ac.timeout {
@@ -1868,16 +1871,18 @@ module OneM2M_Functions {
 						}
 					}
 					
-					//Sending response to the notification received	
-					//Preparation of Notification response to be sent
-					v_responsePrimitive := valueof(m_responseNotification(p_responseStatusCode, omit));
-    				v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
-					
-					if(getverdict != pass) {
-						v_responsePrimitive.responseStatusCode := int4000; 
+					if(v_notificationReceived) {
+						//Sending response to the notification received	
+						//Preparation of Notification response to be sent
+						v_responsePrimitive := valueof(m_responseNotification(p_responseStatusCode, omit));
+	    				v_responsePrimitive.requestIdentifier := vc_request.primitive.requestPrimitive.requestIdentifier;
+						
+						if(getverdict != pass) {
+							v_responsePrimitive.responseStatusCode := int4000; 
+						}
+						f_send(e_mca_in_port, m_response(v_responsePrimitive));
 					}
-					f_send(e_mca_in_port, m_response(v_responsePrimitive));
-					        
+					    
 				} //end f_cse_notifyProcedure_subscriptionVerificationHandler
 				
 				/**
-- 
GitLab