OneM2M_Functions.ttcn 22.6 KB
Newer Older
1 2 3 4 5 6 7 8
/**
 *  Copyright Notification
 *  No part of this document may be reproduced, in an electronic retrieval system or otherwise, except as authorized by written permission.
 *  The copyright and the foregoing restriction extend to reproduction in all media.
 *  © 2016, oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TSDSI, TTA, TTC).
 *  All rights reserved.
 *  
 *  @author     ETSI
9 10
 *  @version    $URL: https://forge.etsi.org/svn/oneM2M/trunk/ttcn/LibOneM2M/OneM2M_Functions.ttcn $
 *              $Id: OneM2M_Functions.ttcn 103 2016-08-30 09:39:32Z reinaortega $
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *  @desc       Module containing functions for oneM2M
 *
 */
module OneM2M_Functions {
	
	import from LibCommon_Time {modulepar all;}
	import from XSD all;
	import from OneM2M_Templates all;
	import from OneM2M_Types all;//{type XSD.ID};
	import from OneM2M_TypesAndValues all;
	import from OneM2M_TestSystem all;
	import from OneM2M_Pixits all;
//	import from OneM2M_AdditionalTypes all;
	
	
	group configFunctions {
    	/**
28
    		@desc Ports mapping and default behaviour activation for Config 1
29 30 31
    	*/
    	function f_cf01Up() runs on M2M {
    			
32
			// Variables
33
    			
34 35 36 37
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:acPort, system:acPort);
			activate(a_default());
38
    			
39
			// Connect
40
    						
41
			//Initialze the IUT
42
    						
43
		} // end f_cf01Up
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
		
		function f_cf02Up() runs on M2M {
    			
			// Variables
    			
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:mccPort, system:mccPort);
			map(self:acPort, system:acPort);
			activate(a_default());
    			
			// Connect
    						
			//Initialze the IUT
    						
		} // end f_cf02Up
60 61 62 63 64
    	
	}//end group configFunctions
	
	group preambleFunctions {

65 66 67 68 69
		/**
		 * @desc Creation of auxiliar resources ACP and AE for correct execution of the test case
		 * @param p_allowedOperations Allowed operations for the auxiliar AE resource
		 * @return Internal AE resource index
		 * @verdict 
70
		 */
71
		function f_preamble_registerAe(in template (value) AccessControlOperations p_allowedOperations := int63) runs on M2M return integer{//c_CRUDNDi
72 73 74
		
			var RequestPrimitive v_request;
			var M2MResponsePrimitive v_response;
75 76
			var integer v_aeAuxIndex := -1;
			var integer v_acpAuxIndex := -1;
77
		
78
			if(PX_ACP_SUPPORT){
79
				v_acpAuxIndex := f_createAccessControlPolicyAux(p_allowedOperations := p_allowedOperations);
80
				vc_acpAuxIndex := v_acpAuxIndex;
81
			}
82
			
83 84
			if(v_acpAuxIndex != -1) {
				vc_resourcesIndexToBeDeleted := {v_acpAuxIndex};
85
				v_request := valueof(m_createAeAux(p_accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)}));
86 87 88 89
				
				//TODO Test, to be removed
				v_request.to_ := f_addPrefix(f_getResourceAddress());
				
90
				mcaPort.send(m_request(v_request));
oneM2MTester Develop Team's avatar
oneM2MTester Develop Team committed
91
				//mcaPort.send(m_request(m_createAeAux(p_name, {PX_URI_CSE & PX_CSE_NAME & "/" & PX_ACPAUX_NAME})));
92 93 94
			} else {
				mcaPort.send(m_request(m_createAeAux()));
			}
95 96 97 98 99
			tc_ac.start;
			alt {
				[] mcaPort.receive(mw_responseOK) -> value v_response {
					tc_ac.stop;
					log("Preamble: Application registered successfuly");
100 101 102 103 104 105
					if(ischosen(v_response.responsePrimitive_.primitiveContent.any_1[0].AE_optional)) {
						vc_aeAux := v_response.responsePrimitive_.primitiveContent.any_1[0].AE_optional;
						
						v_aeAuxIndex := f_setResource(v_response.responsePrimitive_.primitiveContent);
						vc_resourcesIndexToBeDeleted := vc_resourcesIndexToBeDeleted & {v_aeAuxIndex};
						
106
						if(ispresent(vc_aeAux.aE_ID)){
107
							f_sendAcPrimitive("AE-ID_changed", oct2char(unichar2oct(vc_aeAux.aE_ID)));
108 109 110
						} else {
							f_sendAcPrimitive("AE-ID_changed", "0");
						}	
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
					}
				}
				[] mcaPort.receive(mw_responseKO) {
					tc_ac.stop;
					setverdict(inconc, "Preamble: Error while registering application");
					stop;
				}
				[] mcaPort.receive {
					tc_ac.stop;
					setverdict(inconc, "Preamble: Unexpected message received");
					stop;
				}
				[] tc_ac.timeout {
					setverdict(inconc, "Preamble: No answer while registering resource");
					stop;
				}
			}	
128 129
			
			return v_aeAuxIndex;
130 131
		
		}
132 133
		
		//Added by @Naum
134
		function f_preamble_prepareCSE(in template ListOfM2MID p_allowedAEs, in template (value) AccessControlOperations p_allowedOperations := int63) runs on M2M return integer{//c_CRUDNDi
135
		
136
			var M2MResponsePrimitive v_response;
Naum Spaseski's avatar
Naum Spaseski committed
137
			var integer v_serviceSubscribedAppRuleIndex := -1;
138
			var RequestPrimitive v_request;
139

Naum Spaseski's avatar
Naum Spaseski committed
140
			v_serviceSubscribedAppRuleIndex := f_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
141
			
Naum Spaseski's avatar
Naum Spaseski committed
142
			return v_serviceSubscribedAppRuleIndex;
143 144
		
		}
145 146 147 148 149
	
	}//end group preambleFunctions
	
	group postambleFunctions {

150 151 152
		/**
		 * @desc Deletion of all resources created during the test case execution. IUT gets clean and ready for next execution
		 * @verdict 
153
		 */
154
		function f_postamble_deleteResources() runs on M2M {
155 156
			var integer i;
			var XSD.ID v_resourceAddress;
157
			var M2MResponsePrimitive v_response;
158
			var RequestPrimitive v_request;
159 160
			
			if (PX_RUN_POSTAMBLE) {
161 162 163 164 165 166 167 168 169 170 171 172 173
				
				for(i := 0; i < lengthof(vc_resourcesIndexToBeDeleted); i := i + 1) {
					
					v_resourceAddress := f_getResourceAddress(lengthof(vc_resourcesIndexToBeDeleted)-1 - i);
					
					v_request := valueof(m_deleteRequest(v_resourceAddress));
					
					if(PX_FROM_IS_AE_ID){
						if(ischosen(vc_resourcesList[i].resource.any_1[0].AccessControlPolicy_optional)) {
							v_request.from_ := PX_AE_ID_STEM;
						} else {
							v_request.from_ := vc_aeAux.aE_ID;
						}
174
					}
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
					mcaPort.send(m_request(v_request));
					
					tc_ac.start;
					alt {
						[] mcaPort.receive(mw_responseOK) {
							tc_ac.stop;
							log("Postamble: AE Resource deleted");
						}
						[] mcaPort.receive(mw_responseKO) {
							tc_ac.stop;
							log("Postamble: Error while deleting resource");
						}
						[] tc_ac.timeout {
							log("Postamble: No answer while deleting resource");
						}	
190
					}	
191
				}
192
			}
193
						
194 195 196
			f_postamble_default();
		}
			
197 198 199
		/**
		 * @desc Ports unmapping
		 * @verdict 
200
		 */
201 202
		function f_postamble_default() runs on M2M {
	
203
			unmap(self:mcaPort, system:mcaPort);
204 205 206 207 208 209 210
			unmap(self:acPort, system:acPort);
			//stop;
		}	
		
		function f_postamble_CF02() runs on M2M {
	
			unmap(self:mcaPort, system:mcaPort);
211
			unmap(self:mccPort, system:mccPort);
212 213
			unmap(self:acPort, system:acPort);
			//stop;
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
		}		
		
	}//end group postambleFunctions
	
	group altstepFunctions {

		/**
		  * @desc	Default altstep
		  */
		 altstep a_default() runs on M2M {
			
			[] mcaPort.receive {
				log("a_default: WARNING: Unexpected message received");
				repeat;
			}
			[] tc_wait.timeout {
				 setverdict(inconc,"a_default: ERROR: Timeout while awaiting reaction of the IUT prior to Upper Tester action");
			}
			[] tc_ac.timeout {
				setverdict(inconc,"a_default: ERROR: Timeout while awaiting the reception of a message");
			}
		 }		
	}//end group altstepFunctions
	
	group getSetFunctions {

240 241 242 243 244 245 246
		/**
		 * @desc Creation of a CREATE request primitive from a template request primitive
		 * @param p_resourceType Type of resource to be created
		 * @param p_request Template request primitive 
		 * @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
		 * @return Created CREATE request primitive
		 * @verdict 
247 248
		 */
		function f_getCreateRequestPrimitive(in ResourceType p_resourceType, template RequestPrimitive p_request, integer p_parentIndex) runs on M2M return RequestPrimitive {
249
		
250
			p_request.from_ := f_getOriginator(p_parentIndex);
251
            
252
			p_request.to_ := f_addPrefix(f_getResourceAddress(p_parentIndex));
253
            
254 255 256 257
			if (p_resourceType == int1) {//AccessControlPolicy
			
			} 
			if (p_resourceType == int9) {//group
258
				p_request.primitiveContent.any_1[0].Group_optional.memberIDs := {f_getResourceAddress(p_parentIndex)};
259 260 261
			}
		
			if (p_resourceType == int15) {//pollingChannel
262
				p_request.from_ := vc_aeAux.aE_ID;
263
			} 
264 265
			
			if (p_resourceType == int23) {//subscription
266 267 268
				p_request.primitiveContent.any_1[0].Subscription_optional.notificationURI := {f_getResourceAddress(p_parentIndex)};
					
				/*if(PX_FROM_IS_AE_ID) {
269 270 271 272 273 274
					if(PX_UNSTRUCTURED){
						p_request.primitiveContent.any_1[0].Subscription_optional.notificationURI := {vc_aeAux.aE_ID};
					} else {
						p_request.primitiveContent.any_1[0].Subscription_optional.notificationURI := {PX_CSE_ID & "/" & vc_aeAux.aE_ID};
					}
				} else {
oneM2MTester Develop Team's avatar
oneM2MTester Develop Team committed
275
					p_request.primitiveContent.any_1[0].Subscription_optional.notificationURI := {"/" & PX_CSE_NAME & "/" & PX_AEAUX_NAME};//c_aeAuxName
276
				}*/
277
			}
278 279 280 281
		
			return valueof(p_request);
		}
	
282 283 284 285 286 287 288
		/**
		 * @desc Creation of an UPDATE request primitive from a template request primitive
		 * @param p_resourceType Type of resource to be created
		 * @param p_resourceIndex Internal resource index which indicates the resource to be updated
		 * @param p_request Template request primitive
		 * @return Created UPDATE request primitive
		 * @verdict 
289
		 */
290
		function f_getUpdateRequestPrimitive(in ResourceType p_resourceType, integer p_resourceIndex, template RequestPrimitive p_request) runs on M2M return RequestPrimitive {
291
		
292 293 294 295
			p_request.from_ := f_getOriginator(p_resourceIndex);
            
			p_request.to_ := f_addPrefix(f_getResourceAddress(p_resourceIndex));
			
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
			if (p_resourceType == int3) {//Container
			
			//TODO
			} 
		
			if (p_resourceType == int9) {//group
				//TODO	
		
			}
		
			if (p_resourceType == int18) {//schedule
				//TODO			
	
			} 

			if (p_resourceType == int15) {//pollingChannel
				//TODO		
			}
		
			if (p_resourceType == int23) {//subscription
				//TODO		
			} 
		
			return 	valueof(p_request);
		}

322 323 324 325 326
		/**
		 * @desc Extraction from a primitiveContent field the resourceID attribute
		 * @param p_contentResource primitiveContent field
		 * @return resourceID attribute
		 * @verdict 
327
		 */
328 329
		function f_getResourceId(PrimitiveContent p_contentResource) return XSD.ID {
				
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
			if(ischosen(p_contentResource.any_1[0].AccessControlPolicy_optional)) {
				return p_contentResource.any_1[0].AccessControlPolicy_optional.resourceID;
			}
			if(ischosen(p_contentResource.any_1[0].Container_optional)) {
				return p_contentResource.any_1[0].Container_optional.resourceID;
			}
			if(ischosen(p_contentResource.any_1[0].Schedule_optional)) {
				return p_contentResource.any_1[0].Schedule_optional.resourceID;
			}
			if(ischosen(p_contentResource.any_1[0].PollingChannel_optional)) {
				return p_contentResource.any_1[0].PollingChannel_optional.resourceID;
			}
			if(ischosen(p_contentResource.any_1[0].Subscription_optional)) {
				return p_contentResource.any_1[0].Subscription_optional.resourceID;
			}
			if(ischosen(p_contentResource.any_1[0].Group_optional)) {
				return p_contentResource.any_1[0].Group_optional.resourceID;
347
			}
348 349 350 351 352 353 354
			if(ischosen(p_contentResource.any_1[0].AE_optional)) {
				return p_contentResource.any_1[0].AE_optional.resourceID;
			}
			return "1";
  
		}
		
355 356 357 358 359
		/**
		 * @desc Extraction from a primitiveContent field the resourceName attribute
		 * @param p_contentResource primitiveContent field
		 * @return resourceName attribute
		 * @verdict 
360
		 */
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
		function f_getResourceName(PrimitiveContent p_contentResource) return XSD.ID {
				
			if(ischosen(p_contentResource.any_1[0].AccessControlPolicy_optional)) {
				return p_contentResource.any_1[0].AccessControlPolicy_optional.resourceName;
			}
			if(ischosen(p_contentResource.any_1[0].Container_optional)) {
				return p_contentResource.any_1[0].Container_optional.resourceName;
			}
			if(ischosen(p_contentResource.any_1[0].Schedule_optional)) {
				return p_contentResource.any_1[0].Schedule_optional.resourceName;
			}
			if(ischosen(p_contentResource.any_1[0].PollingChannel_optional)) {
				return p_contentResource.any_1[0].PollingChannel_optional.resourceName;
			}
			if(ischosen(p_contentResource.any_1[0].Subscription_optional)) {
				return p_contentResource.any_1[0].Subscription_optional.resourceName;
			}
			if(ischosen(p_contentResource.any_1[0].Group_optional)) {
				return p_contentResource.any_1[0].Group_optional.resourceName;
			}
			if(ischosen(p_contentResource.any_1[0].AE_optional)) {
				return p_contentResource.any_1[0].AE_optional.resourceName;
			}
			
385 386 387
			return "1";
  
		}
388
		
389 390 391 392 393
		/**
		 * @desc Resolution of the originator field (from) for a given resource
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @return Originator for a given resource
		 * @verdict 
394
		 */
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
		function f_getOriginator(integer  p_targetResourceIndex := -1) runs on M2M return XSD.AnyURI {
			
			if(p_targetResourceIndex == -1) {
				return PX_AE_ID_STEM;
			}	
			
			if(PX_FROM_IS_AE_ID) {
				if(ischosen(vc_resourcesList[p_targetResourceIndex].resource.any_1[0].AE_optional)) {
					return vc_resourcesList[p_targetResourceIndex].resource.any_1[0].AE_optional.aE_ID;
				} else {
					return f_getOriginator(vc_resourcesList[p_targetResourceIndex].parentIndex);
				}
			} else {
				return PX_AE_ID_STEM;
			}
		}
		
412 413 414 415 416 417
		/**
		 * @desc Return of a index of a specific attribute from an attributeList by attributeName
		 * @param p_attributeList Target attributeList
		 * @param p_attributeName attributeName to be searched
		 * @return Index of the attribute in the attributeList
		 * @verdict 
418
		 */
419
		function f_getAttribute(in AttributeList p_attributeList, in XSD.NCName p_attributeName) return integer {
420 421 422 423
		var integer i;
		var Attribute v_attribute := {-, -};
		
		for (i:=0; i < lengthof(p_attributeList); i := i + 1){
424 425
			if(p_attributeList[i] == p_attributeName){
				return i;
426 427 428
			}	
		}
			
429
		return -1;
430 431
		
		}
432
		
433 434 435 436 437
		/**
		 * @desc Resolution of the resource address field (to) for a given resource depending on addressing and hierarchical format 
		 * @param p_targetResourceIndex Internal resource index of the given resource
		 * @return Resource address for the given resource
		 * @verdict 
438
		 */
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
		function f_getResourceAddress(integer  p_targetResourceIndex := -1) runs on M2M return XSD.ID {
			var XSD.ID v_resourceAddress;
		
			if(PX_ADDRESSING_FORMAT == e_cseRelative) {
				
				if(PX_UNSTRUCTURED) {
					if(p_targetResourceIndex == -1) {
						return "";
					} else {
						return f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return PX_CSE_NAME;
					} else {
						v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}	
				}
				
			} else if (PX_ADDRESSING_FORMAT == e_spRelative) {
				if(PX_UNSTRUCTURED) {
					if(p_targetResourceIndex == -1) {
						return "/" & PX_CSE_ID;
					} else {
						v_resourceAddress := f_getResourceAddress() & "/" & f_getResourceId(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return "/" & PX_CSE_ID & "/" & PX_CSE_NAME;
					} else {
						v_resourceAddress := f_getResourceAddress(vc_resourcesList[p_targetResourceIndex].parentIndex) & "/" & f_getResourceName(vc_resourcesList[p_targetResourceIndex].resource);
						return v_resourceAddress;
					}
				}
			} else if (PX_ADDRESSING_FORMAT ==  e_absolute) {
				if(PX_UNSTRUCTURED) {
					if(p_targetResourceIndex == -1) {
						return "";
					} else {
						return "";
					}
				} else {
					if(p_targetResourceIndex == -1) {
						return "";
					} else {
						return "";
					}	
				}				
			} else {
				return "";
			}
			
		}
494 495 496 497 498 499
		/**
		 * @desc Saving of a resource and its parent index in the internal resource list
		 * @param p_resource Resource to be saved
		 * @param p_parentIndex Parent index of resource to be saved
		 * @return Internal resource index of the saved resource
		 * @verdict 
500
		 */
501 502 503 504 505 506 507 508 509 510
		function f_setResource(PrimitiveContent p_resource, integer  p_parentIndex := -1) runs on M2M return integer {
			
			if(isbound(vc_resourcesList)) {
				vc_resourcesList[lengthof(vc_resourcesList)] := {p_parentIndex, p_resource};
			} else {
				vc_resourcesList[0] := {p_parentIndex, p_resource};
			}
			return lengthof(vc_resourcesList)-1;
					
		}
511 512 513 514 515
				
	}//end group getSetFunctions
	
	group helpingFunctions {

516 517 518 519 520 521 522
		/**
		 * @desc Creation of a resource
		 * @param p_resourceType Resource type of the resource to be created
		 * @param p_requestPrimitive Template request primitive
		 * @param p_parentIndex Internal resource index which indicates the parent of the resource to be created
		 * @return Internal resource index of the created resource
		 * @verdict 
523
		 */
524
		function f_createResource(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive, integer p_parentIndex := -1) runs on M2M return integer {
525 526 527
		
			var M2MResponsePrimitive v_response;
			var RequestPrimitive v_request;
528
			var XSD.ID v_resourceId;
529
			var integer v_resourceIndex := -1;
530
			
531
			v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
532 533 534 535 536 537 538
		
			mcaPort.send(m_request(v_request));
			tc_ac.start;
			alt {
				[] mcaPort.receive(mw_responseOK) -> value v_response {
					tc_ac.stop;
					setverdict(pass, "f_createResource: Resource type " & int2str(enum2int(p_resourceType)) & " created successfuly");
539
					v_resourceIndex := f_setResource(v_response.responsePrimitive_.primitiveContent, p_parentIndex);
540 541 542 543 544 545 546 547 548 549 550 551 552
				}
				[] mcaPort.receive(mw_responseKO) {
					tc_ac.stop;
					setverdict(inconc, "f_createResource: Error while creating resource type " & int2str(enum2int(p_resourceType)));
				}
				[] mcaPort.receive {
					tc_ac.stop;
					setverdict(inconc, "f_createResource: Unexpected message received");
				}
				[] tc_ac.timeout {
					setverdict(inconc, "f_createResource: No answer while creating resource type " & int2str(enum2int(p_resourceType)));
				}
			}	
553
			
554
			return v_resourceIndex;
555 556 557
	
		}
	
558 559 560 561 562 563
		/**
		 * @desc Creation of the auxiliar ACP resource
		 * @param p_acpName ACP name
		 * @param p_allowedOperations Allowed operations
		 * @return Internal resource index of the created auxiliar ACP resource
		 * @verdict 
564 565
		 */
		function f_createAccessControlPolicyAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) AccessControlOperations p_allowedOperations := int63) runs on M2M return integer{
566
			var RequestPrimitive v_request;
567
			var M2MResponsePrimitive v_response;
568 569 570 571 572 573 574
			var integer v_acpAuxIndex := -1;
			
			v_request := valueof(m_createAcpAux(p_acpName := p_acpName, p_allowedOperations := p_allowedOperations));
			
			v_request.to_ := f_addPrefix(f_getResourceAddress());
			
			mcaPort.send(m_request(v_request));
575 576 577 578 579
			tc_ac.start;
			alt {
				[] mcaPort.receive(mw_responseOK) -> value v_response {
					tc_ac.stop;
					setverdict(pass, "f_createAccessControlPolicy: Resource type " & int2str(1) & " created successfuly");
580 581
					v_acpAuxIndex := f_setResource(v_response.responsePrimitive_.primitiveContent);
					vc_acpAux := v_response.responsePrimitive_.primitiveContent.any_1[0].AccessControlPolicy_optional;//TODO To be removed
582 583 584 585 586 587 588 589 590 591 592 593 594
				}
				[] mcaPort.receive(mw_responseKO) {
					tc_ac.stop;
					setverdict(inconc, "f_createAccessControlPolicy: Error while creating resource type " & int2str(1));
				}
				[] mcaPort.receive {
					tc_ac.stop;
					setverdict(inconc, "f_createAccessControlPolicy: Unexpected message received");
				}
				[] tc_ac.timeout {
					setverdict(inconc, "f_createAccessControlPolicy: No answer while creating resource type " & int2str(1));
				}
			}	
595
		
596
			return v_acpAuxIndex;
597 598

		}
599 600
			
			
601 602 603 604 605
		/**
		 * @desc Creation of the auxiliar Container resource
		 * @param p_parentIndex Internal resource index which indicates the parent of the Container resource to be created
		 * @return Internal resource index of the created Container resource
		 * @verdict 
606 607
		 */
		function f_createContainerResourceAux (integer p_parentIndex := -1) runs on M2M return integer {
608 609 610
		
			var M2MResponsePrimitive v_response;
			var RequestPrimitive v_request;
611 612
			var integer v_acpAuxIndex := -1;
			var integer v_containerResourceIndex := -1;
613
			
614
			v_acpAuxIndex := f_createAccessControlPolicyAux(p_acpName := c_acpAuxName);//"MyAcp_2"
615 616
			
			v_request := valueof(m_createContainerBase);
617
			v_request.primitiveContent.any_1[0].Container_optional.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)};
618
			v_request.primitiveContent.any_1[0].Container_optional.resourceName := "MyContainerAux";
619
			
620
			v_containerResourceIndex := f_createResource(int3, v_request, p_parentIndex);
621
			
622
			return v_containerResourceIndex;		
623
	
624 625
		}
		
626 627 628 629
		/**
		 * @desc Update of the auxiliar ACP resource
		 * @param p_allowedOperations New allowed operations
		 * @verdict 
630 631
		 */
		function f_updateAcpAuxResource (in template (value) AccessControlOperations p_allowedOperations) runs on M2M {
632 633 634 635
			var RequestPrimitive v_request;
			
			v_request := valueof(m_updateAcpBase);
			
636
			v_request.to_ := f_addPrefix(f_getResourceAddress(vc_acpAuxIndex));
637
			v_request.primitiveContent.any_1[0].AccessControlPolicy_optional.privileges.accessControlRule_list := {
638 639 640 641 642 643
				{
					accessControlOriginators := PX_ACOR, //{"admin:admin"}
					accessControlOperations := valueof(p_allowedOperations),
					accessControlContexts_list := omit
				}
			};
644 645 646 647 648 649
						
			mcaPort.send(m_request(v_request));
			tc_ac.start;
			alt {
				[] mcaPort.receive(mw_responseOK)  {
					tc_ac.stop;
650
					setverdict(pass, "f_updateAcpAuxResource: " & v_request.to_ & " resource updated successfuly");
651 652 653
				}
				[] mcaPort.receive(mw_responseKO) {
					tc_ac.stop;
654
					setverdict(fail, "f_updateAcpAuxResource: Error while updating " & v_request.to_ & " resource");
655 656
				}
				[] tc_ac.timeout {
657
					setverdict(inconc, "f_updateAcpAuxResource: No answer while updating " & v_request.to_ & " resource" );
658 659 660 661
				}
			}		
		}
		
662 663 664 665 666 667
		/**
		 * @desc Sending of an Adapter Control primitive
		 * @param event Action to be performed by TA
		 * @param data Corresponding information for the correct execution of the given action
		 * @verdict 
		 */
668 669 670 671 672 673
		function f_sendAcPrimitive(in charstring event, in charstring data) runs on M2M {

			var charstring v_data := "" & data; // clear encoding rules (ttwb issue ?)
			acPort.send(AcRequestPrimitive:{event, {charstring := v_data}});
			
		}
674 675


676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692
	}//end group helpingFunctions	


	

		

	

		

		

	

	
}  // end of module