OneM2M_Functions.ttcn 74.2 KB
Newer Older
1
2
3
4
5
6
7
/**
 *  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.
 *  
8
 *  @author     oneM2M
9
 *  @version    $URL: https://forge.etsi.org/svn/oneM2M/trunk/ttcn/LibOneM2M/OneM2M_Functions.ttcn $
10
 *              $Id: OneM2M_Functions.ttcn 296 2017-06-02 13:16:50Z reinaortega $
11
12
13
14
15
16
17
18
19
20
21
22
 *  @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;
23
	import from OneM2M_Pics all;
24
25
26
//	import from OneM2M_AdditionalTypes all;
	
	
27
	group ConfigFunctions {
28
		
29
30
31
32
33
		/**
			@desc Ports mapping and default behaviour activation for Config 1
		*/
		function f_cf01Up() runs on CseTester {
				
34
			// Variables
35
36
			vc_config := e_cf01;	
			
37
38
39
40
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:acPort, system:acPort);
			activate(a_default());
41
			activate(a_cse_cf01());
42
				
43
			// Connect
44
						
45
			//Initialze the IUT
46
							
47
		} // end f_cf01Up
48
		
49
		function f_cf02Up() runs on CseTester {
50
				
51
			// Variables
52
			vc_config := e_cf02;
53
				
54
55
56
57
58
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:mccPort, system:mccPort);
			map(self:acPort, system:acPort);
			activate(a_default());
59
			activate(a_cse_cf02());
60
				
61
			// Connect
62
					
63
			//Initialze the IUT
64
							
65
		} // end f_cf02Up
66
		
67
68
69
70
		/**
		 * @desc Ports mapping and default behaviour activation for Config 03
		 */
		function f_cf03Up() runs on AeTester {
71
72
		
			// Variables
73
74
			vc_config := e_cf03;
			
75
76
77
78
			// Map
			map(self:mcaPort, system:mcaPort);
			map(self:acPort, system:acPort);
			activate(a_default());
79
			activate(a_ae_cf03());
80
81
82
83
84
85
		
			// Connect
					
			//Initialze the IUT
					
		} // end f_cf03Up
86
87

		/**
88
89
		 * @desc Ports unmapping
		 * @verdict 
90
		 */
91
92
93
94
95
96
97
		function f_cfCseTesterDown() runs on CseTester {
		
			if(vc_config == e_cf01) {
				f_cf01Down()
			} else if (vc_config == e_cf02){
				f_cf02Down()
			} 
98
		}
99
100
101
102
103
104
105
106
107
108
		/**
		 * @desc Ports unmapping
		 * @verdict 
		 */
		function f_cfAeTesterDown() runs on AeTester {
		
			if(vc_config == e_cf03) {
				f_cf03Down()
			} 
		}			
109
110
111
		/**
		 * @desc Ports unmapping
		 * @verdict 
112
		 */
113
		function f_cf01Down() runs on CseTester {
114
		
115
			unmap(self:mcaPort, system:mcaPort);
116
117
			unmap(self:acPort, system:acPort);
		}	
118
119
120
121
		/**
		 * @desc Ports unmapping
		 * @verdict 
		 */
122
		function f_cf02Down() runs on CseTester {
123
		
124
			unmap(self:mcaPort, system:mcaPort);
125
			unmap(self:mccPort, system:mccPort);
126
			unmap(self:acPort, system:acPort);
127
		}		
128
129
130
131
132
133
134
135
		/**
		 * @desc Ports unmapping for Config 03
		 */
		function f_cf03Down() runs on AeTester {
			
			unmap(self:mcaPort, system:mcaPort);
			unmap(self:acPort, system:acPort);
		}
136
		
137
	}//end group configFunctions
138
	
139
	group CseFunctions {
140
	
141
		group PreambleFunctions {
142

143
144
145
146
147
148
149
150
151
152
153
			/**
			 * @desc Creation of auxiliar resources ACP for correct execution of the test case
			 * @param p_allowedOperations Allowed operations for the auxiliar AE resource
			 * @return Internal ACP resource index
			 * @verdict 
			 */
			function f_cse_preamble_createAcpAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) AccessControlOperations p_allowedOperations := int63) runs on CseTester return integer {//c_CRUDNDi
			
				return f_cse_createAccessControlPolicyAux(p_acpName, p_allowedOperations);
			
			}
154

155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
	
			/**
			 * @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 
			 */
			function f_cse_preamble_registerAe(template (omit) AcpType p_accessControlPolicyIDs := omit, in template (omit) PoaList p_poaList := omit) runs on CseTester return integer {//c_CRUDNDi
			
				var RequestPrimitive v_request;
				var MsgIn v_response;
				var integer v_aeAuxIndex := -1;
								
				v_request := valueof(m_createAeAux(p_accessControlPolicyIDs, p_poaList));
				v_request.to_ := f_getResourceAddress();
170
				
171
				mcaPort.send(m_request(v_request));
172
173
174
175
176
				
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
177
						setverdict(pass,__SCOPE__&":INFO: Application registered successfuly");
178
179
						if(ischosen(v_response.primitive.responsePrimitive.primitiveContent.aE_optional)) {
							vc_aeAux := v_response.primitive.responsePrimitive.primitiveContent.aE_optional;
180
							
181
182
							f_checkAttributesToBeSaved(int2, v_request, v_response.primitive.responsePrimitive);
							
183
184
185
186
187
188
189
190
191
192
193
194
							v_aeAuxIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent);
							vc_resourcesIndexToBeDeleted := vc_resourcesIndexToBeDeleted & {v_aeAuxIndex};
							
							if(ispresent(vc_aeAux.aE_ID)){
								f_sendAcPrimitive("AE-ID_changed", oct2char(unichar2oct(vc_aeAux.aE_ID)));
							} else {
								f_sendAcPrimitive("AE-ID_changed", "0");
							}
						}
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
195
						setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
196
197
198
199
						stop;
					}
					[] mcaPort.receive {
						tc_ac.stop;
200
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
201
202
203
						stop;
					};
					[] tc_ac.timeout {
204
						setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
205
206
207
208
						stop;
					}
				}	
				
209
				f_checkCseTesterStatus();
210
211
212
213
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
240
241
242
243
244
245
246
247
				return v_aeAuxIndex;
			
			}
			
			/**
			 * @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 
			 */
			function f_cse_preamble_registerAeWithId(XSD.ID p_appId, in template (value) AccessControlOperations p_allowedOperations := int63) runs on CseTester return integer {//c_CRUDNDi
			
				var RequestPrimitive v_request;
				var MsgIn v_response;
				var integer v_aeAuxIndex := -1;
				var integer v_acpAuxIndex := -1;
			
				if(PICS_ACP_SUPPORT){
					v_acpAuxIndex := f_cse_createAccessControlPolicyAux(p_allowedOperations := p_allowedOperations);
					vc_acpAuxIndex := v_acpAuxIndex;
				}
				
				if(v_acpAuxIndex != -1) {
					vc_resourcesIndexToBeDeleted := {v_acpAuxIndex};
					v_request := valueof(m_createAe(p_appId, {f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)}, -));
					
					//TODO Test, to be removed
					v_request.to_ := f_getResourceAddress();
					
					mcaPort.send(m_request(v_request));
					//mcaPort.send(m_request(m_createAeAux(p_name, {PX_URI_CSE & PX_CSE_NAME & "/" & PX_ACPAUX_NAME})));
				} else {
					mcaPort.send(m_request(m_createAe(p_appId)));
				}
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
248
						setverdict(pass, __SCOPE__&": INFO: Application registered successfuly");
249
250
						if(ischosen(v_response.primitive.responsePrimitive.primitiveContent.aE_optional)) {
							vc_aeAux := v_response.primitive.responsePrimitive.primitiveContent.aE_optional;
251
252
253
254
255
256
257
258
259
260
261
262
263
264
							
							v_aeAuxIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent);
							vc_resourcesIndexToBeDeleted := vc_resourcesIndexToBeDeleted & {v_aeAuxIndex};
							
							if(ispresent(vc_aeAux.aE_ID)){
								f_sendAcPrimitive("AE-ID_changed", oct2char(unichar2oct(vc_aeAux.aE_ID)));
							} else {
								f_sendAcPrimitive("AE-ID_changed", "0");
							}	
						}
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO))
					{
						tc_ac.stop;
265
						setverdict(inconc, __SCOPE__&":INFO: Error while registering application");
266
267
268
269
						stop;
					}
					[] mcaPort.receive {
						tc_ac.stop;
270
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
271
272
273
						stop;
					}
					[] tc_ac.timeout {
274
						setverdict(inconc, __SCOPE__&":INFO: No answer while registering resource");
275
276
277
278
						stop;
					}
				}	
				
279
				f_checkCseTesterStatus();
280
281
282
283
284
285
286
287
288
289
290
291
292
293
				return v_aeAuxIndex;
			
			}
			
			function f_cse_preamble_createServiceSubscribedAppRule(in template ListOfM2MID p_allowedAEs := {""}) runs on CseTester return integer {//c_CRUDNDi
			
				var integer v_serviceSubscribedAppRuleIndex := -1;
	
				v_serviceSubscribedAppRuleIndex := f_cse_createResource(int19, m_createServiceSubscribedAppRule({"None"}, {PX_APP_ID}, valueof(p_allowedAEs)));
				
				return v_serviceSubscribedAppRuleIndex;
			
			}
			
294
			function f_cse_preamble_subscriptionVerification(out CseTester p_notifyHandler,in integer p_aeIndex, inout integer p_ae2Index, inout template RequestPrimitive p_createRequestPrimitive,in ResourceType p_resourceType ) runs on CseTester {
295
296
				if(p_resourceType == int23){
					p_notifyHandler := CseTester.create("NotifyHandler") alive;
297
					p_ae2Index := f_cse_createResource(int2, m_createAe(PX_APP_ID, -, PX_AE2_ID_STEM, "MyAe2", {"http://" & PX_AE2_ADDRESS & "/"}), -1); // AE2 is registred
298
299
					if(ischosen(p_createRequestPrimitive.primitiveContent.subscription_optional)){		//this condition is necessary for Subscription TCs where notification URI is set in m_createSubscriptionAdvanced
						p_createRequestPrimitive.primitiveContent.subscription_optional.notificationURI := {f_getResourceAddress(p_ae2Index)}; 
300
301
302
					}
					p_notifyHandler.start(f_subscriptionVerificationHandler(f_getResourceAddress(p_aeIndex)));
				}
303
			}
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
		
		}//end group preambleFunctions
		
		group PostambleFunctions {
	
			/**
			 * @desc Deletion of all resources created during the test case execution. IUT gets clean and ready for next execution
			 * @verdict 
			 */
			function f_cse_postamble_deleteResources() runs on CseTester {
				var integer i;
				var XSD.ID v_resourceAddress;
				var RequestPrimitive v_request;
				
				if (PX_RUN_POSTAMBLE) {
					
					for(i := lengthof(vc_resourcesIndexToBeDeleted) -1; i >=0; i := i - 1) {
321
						
322
						v_resourceAddress := f_getResourceAddress(vc_resourcesIndexToBeDeleted[i]); 
323
						
324
325
						v_request := valueof(m_deleteRequest(v_resourceAddress));
						
326
327
328
						//For deletion of AEs, priority is to use AE-ID in From parameter
						//For other resources PX_SUPER_USER should be able to do DELETE operation
						if(PX_FROM_IS_AE_ID){
329
330
							if(ischosen(vc_resourcesList[vc_resourcesIndexToBeDeleted[i]].resource.aE_optional)) {	
								v_request.from_ := vc_resourcesList[vc_resourcesIndexToBeDeleted[i]].resource.aE_optional.aE_ID;
331
332
							}
						}
333
						
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
						mcaPort.send(m_request(v_request));
						
						tc_ac.start;
						alt {
							[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
								tc_ac.stop;
								log(__SCOPE__&" INFO: Resource" & v_request.to_ & " deleted");
							}
							[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
								tc_ac.stop;
								log(__SCOPE__&" INFO: Error while deleting resource " & v_request.to_);
							}
							[] tc_ac.timeout {
								log(__SCOPE__&" INFO: No answer while deleting resource " & v_request.to_);
							}	
						}	
350
						
351
352
353
354
355
356
					}
				}
							
				f_cse_postamble_default();
			}
			
357
358
359
360
361
			/**
			 * @desc Default postamble
			 * @verdict 
			 */
			function f_cse_postamble_default() runs on CseTester {
362
			}
363
364
			
			function f_is_component_done(in CseTester p_notifyHandler) runs on CseTester {
365
			
366
367
368
369
370
371
372
373
374
375
				tc_ac.start(10.0);
				alt {
					[] p_notifyHandler.done {
					tc_ac.stop;
					}
					[] tc_ac.timeout {
						setverdict(inconc, testcasename() & ": Notify verification not received");
					}
				}
			} //end f_is_component_done
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
			
			
		}//end group postambleFunctions
		
		group HelpingFunctions {
	
			/**
			 * @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 
			 */
			function f_cse_createResource(in ResourceType p_resourceType, template RequestPrimitive p_requestPrimitive := m_create, integer p_parentIndex := -1) runs on CseTester return integer {
			
				var MsgIn v_response;
				var RequestPrimitive v_request;
				var integer v_resourceIndex := -1;
				
				v_request := f_getCreateRequestPrimitive(p_resourceType, p_requestPrimitive, p_parentIndex);
			
				mcaPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
403
						setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(enum2int(p_resourceType)) & " created successfuly");
404
						f_checkAttributesToBeSaved(p_resourceType, v_request, v_response.primitive.responsePrimitive);
405
						v_resourceIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent, p_parentIndex);
406
407
408
						if(match(int2, p_resourceType) or match(-1, p_parentIndex)) {//If created resource is an AE or created under CSEBase, it needs to be added to the resourceToBeDeleted list
							vc_resourcesIndexToBeDeleted := vc_resourcesIndexToBeDeleted & {v_resourceIndex};
						}
409
410
411
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
412
						setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(enum2int(p_resourceType)));
413
414
415
					}
					[] mcaPort.receive {
						tc_ac.stop;
416
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
417
418
					}
					[] tc_ac.timeout {
419
						setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(enum2int(p_resourceType)));
420
421
422
					}
				}	
				
423
424
				f_checkCseTesterStatus();
				
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
				return v_resourceIndex;
		
			}
		
			/**
			 * @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 
			 */
			function f_cse_createAccessControlPolicyAux(in template (value) XSD.String p_acpName := c_acpAuxName, in template (value) AccessControlOperations p_allowedOperations := int63) runs on CseTester return integer{
				var RequestPrimitive v_request;
				var MsgIn v_response;
				var integer v_acpAuxIndex := -1;
				
				v_request := valueof(m_createAcpAux(p_acpName := p_acpName, p_allowedOperations := p_allowedOperations));
				
				v_request.to_ := f_getResourceAddress();
				
				mcaPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
450
						setverdict(pass, __SCOPE__&":INFO: Resource type " & int2str(1) & " created successfuly");
451
452
						f_checkAttributesToBeSaved(int1, v_request, v_response.primitive.responsePrimitive);
						v_acpAuxIndex := f_setResource(v_response.primitive.responsePrimitive.primitiveContent);
453
						vc_acpAuxIndex := v_acpAuxIndex;
454
455
						vc_resourcesIndexToBeDeleted := vc_resourcesIndexToBeDeleted & {v_acpAuxIndex};
					}
456
457
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
458
						setverdict(inconc, __SCOPE__&":INFO: Error while creating resource type " & int2str(1));
459
460
461
					}
					[] mcaPort.receive {
						tc_ac.stop;
462
						setverdict(inconc, __SCOPE__&":INFO: Unexpected message received");
463
464
					}
					[] tc_ac.timeout {
465
						setverdict(inconc, __SCOPE__&":INFO: No answer while creating resource type " & int2str(1));
466
467
					}
				}	
468
469
				
				f_checkCseTesterStatus();
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
			
				return v_acpAuxIndex;
	
			}
				
				
			/**
			 * @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 
			 */
			function f_cse_createContainerResourceAux (integer p_parentIndex := -1) runs on CseTester return integer {
			
				var RequestPrimitive v_request;
				var integer v_acpAuxIndex := -1;
				var integer v_containerResourceIndex := -1;
				
				v_acpAuxIndex := f_cse_createAccessControlPolicyAux(p_acpName := c_acpAuxName);//"MyAcp_2"
				
				v_request := valueof(m_createContainerBase);
491
492
				v_request.primitiveContent.container_optional.accessControlPolicyIDs := {f_getResourceId(vc_resourcesList[v_acpAuxIndex].resource)};
				v_request.primitiveContent.container_optional.resourceName := "MyContainerAux";
493
494
495
496
497
498
499
				
				v_containerResourceIndex := f_cse_createResource(int3, v_request, p_parentIndex);
				
				return v_containerResourceIndex;		
		
			}
			
500
501
502
503
504
505
506
507
508
509
510
511
512
			/**
			 * @desc 
			 * @param p_requestPrimitive
			 * @verdict 
			 */
			function f_cse_updateResource(in RequestPrimitive p_requestPrimitive) runs on CseTester {
				var MsgIn v_response;

				mcaPort.send(m_request(p_requestPrimitive));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
513
						setverdict(pass, __SCOPE__&":INFO: Attribute of resource updated successfuly");
514
515
516
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
						tc_ac.stop;
517
						setverdict(fail, __SCOPE__&":ERROR: Error while updating resource");
518
519
520
					}
					[] mcaPort.receive{
						tc_ac.stop;
521
						setverdict(fail, __SCOPE__&":ERROR: Unexpected message received");
522
523
					}
					[] tc_ac.timeout {
524
						setverdict(inconc, __SCOPE__&":INFO: No answer while updating resource");
525
526
					}
				}	
527
528
529
				
				f_checkCseTesterStatus();
				
530
			}// end f_cse_updateResource
531
			
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
			/**
			 * @desc 
			 * @param p_resourceIndex
			 * @verdict 
			 */
			function f_cse_retrieveResource(integer p_resourceIndex) runs on CseTester return PrimitiveContent{
				var MsgIn v_response;

				mcaPort.send(m_request(m_retrieveResource(f_getResourceAddress(p_resourceIndex), f_getOriginator(p_resourceIndex))));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) -> value v_response {
						tc_ac.stop;
						setverdict(pass, __SCOPE__&":INFO: Resource retrieved successfuly");
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) -> value v_response {
						tc_ac.stop;
						setverdict(fail, __SCOPE__&":ERROR: Error while retrieving resource");
					}
					[] mcaPort.receive{
						tc_ac.stop;
						setverdict(fail, __SCOPE__&":ERROR: Unexpected message received");
					}
					[] tc_ac.timeout {
						setverdict(inconc, __SCOPE__&":INFO: No answer while retrieving resource");
					}
				}	
				
				f_checkCseTesterStatus();
				
				return v_response.primitive.responsePrimitive.primitiveContent;
				
			}// end f_cse_retrievingResource
			
566
567
568
569
570
571
572
573
574
575
576
577
578
579
			/**
			 * @desc 
			 * @param p_requestPrimitive
			 * @verdict 
			 */
			function f_cse_deleteResource(in RequestPrimitive p_requestPrimitive) runs on CseTester {
				var MsgIn v_response;
				
				mcaPort.send(m_request(p_requestPrimitive));
						
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK)) {
						tc_ac.stop;
580
						setverdict(pass, __SCOPE__&" INFO: Resource" & p_requestPrimitive.to_ & " deleted");
581
582
583
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
584
						setverdict(inconc, __SCOPE__&" INFO: Error while deleting resource " & p_requestPrimitive.to_);
585
586
					}
					[] tc_ac.timeout {
587
						setverdict(inconc, __SCOPE__&" INFO: No answer while deleting resource " & p_requestPrimitive.to_);
588
589
590
					}	
				}	
				
591
592
				f_checkCseTesterStatus();
				
593
594
			}// end f_cse_deleteResource
			
595
596
597
598
599
600
601
602
603
604
605
			/**
			 * @desc Update of the auxiliar ACP resource
			 * @param p_allowedOperations New allowed operations
			 * @verdict 
			 */
			function f_cse_updateAcpAuxResource (in template (value) AccessControlOperations p_allowedOperations) runs on CseTester {
				var RequestPrimitive v_request;
				
				v_request := valueof(m_updateAcpBase);
				
				v_request.to_ := f_getResourceAddress(vc_acpAuxIndex);
606
				v_request.from_ := f_getOriginator(vc_acpAuxIndex);
607
				v_request.primitiveContent.accessControlPolicy_optional.privileges.accessControlRule_list := {
608
609
610
611
					{
						accessControlOriginators := PX_ACOR, //{"admin:admin"}
						accessControlOperations := valueof(p_allowedOperations),
						accessControlContexts_list := {},
612
613
						accessControlAuthenticationFlag := omit, 
						accessControlObjectDetails_list := {}
614
615
616
617
618
619
620
621
					}
				};
							
				mcaPort.send(m_request(v_request));
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_response(mw_responsePrimitiveOK))  {
						tc_ac.stop;
622
						setverdict(pass, __SCOPE__&":INFO: " & v_request.to_ & " resource updated successfuly");
623
624
625
					}
					[] mcaPort.receive(mw_response(mw_responsePrimitiveKO)) {
						tc_ac.stop;
626
						setverdict(fail, __SCOPE__&":ERROR: Error while updating " & v_request.to_ & " resource");
627
628
					}
					[] tc_ac.timeout {
629
						setverdict(inconc, __SCOPE__&":INFO: No answer while updating " & v_request.to_ & " resource" );
630
631
					}
				}		
632
633
				
				f_checkCseTesterStatus();
634
635
			}   
			
636
637
638
639
640
641
642
643
644
645
646
647
648
649
			/**
			 * @desc Function to handle announcement of resources
			 * @param p_from
			 * @param p_to
			 * @verdict 
			 */
			 //TODO To finalize this function
			function f_cse_resourceAnnouncementHandler(template XSD.ID p_from := *, template XSD.ID p_to := ?) runs on CseTester {
				// Local variables
				var MsgIn v_request;
				var ResponsePrimitive v_responsePrimitive;
				
				map(self:mccPort, system:mccPort);
				map(self:acPort, system:acPort);
650

651
652
653
654
655
656
657
				tc_ac.start;
				alt {
					[] mcaPort.receive(mw_request(mw_create(p_from, p_to))) -> value v_request {
						tc_ac.stop;
						setverdict(pass, testcasename() & ": Announcement received");
						v_responsePrimitive := f_getCreateResponsePrimitive(v_request.primitive.requestPrimitive.resourceType, v_request.primitive.requestPrimitive);
						mcaPort.send(m_response(v_responsePrimitive)); 						
658
					}
659
660
661
					[] mcaPort.receive{
						tc_ac.stop;
						setverdict(fail, testcasename() & ": Error, unexpected message received");
662
					}
663
664
					[] tc_ac.timeout {
						setverdict(inconc, testcasename() & ":  No announcement received");
665
666
667
					}
				}
	
668
669
				unmap(self:mccPort, system:mccPort);
				unmap(self:acPort, system:acPort); 
670

671
672
			} //end f_cse_resourceAnnouncementHandler			
			
673
    		function f_subscriptionVerificationHandler(in XSD.ID p_creator, in ResponseStatusCode p_responseStatusCode := int2000) runs on CseTester {
674
675
676
677
678
679
680
681
682
    			// Local variables
    			var MsgIn v_response;
    			var ResponsePrimitive v_responsePrimitive;
    			var template Notification v_notificationRequest := mw_contentNotificationBase;
    			var PrimitiveContent v_notificationResponse; // TODO Need to see if this parameter is required however there is a problem if it s omitted during the verification
    			
    			map(self:mcaPort, system:mcaPort);
    			map(self:acPort, system:acPort);
    
683
    			v_notificationResponse := {notification := valueof(m_contentNotification_allOmit)};
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
    	
    			v_notificationRequest.verificationRequest := true;
    			//v_notificationRequest.creator := p_creator; TODO To check what address format is to be expected
    			//Some participants use SP relative UNSTRUCTURED
    			//v_notificationRequest.subscriptionReference := "I Don't know which URI is expected"; // TODO mandatory parameter 
    			v_responsePrimitive := valueof(m_responseNotification(p_responseStatusCode,v_notificationResponse));//TODO No PrimitiveContent is expected
    	
    			if(p_responseStatusCode != int2001){
    				v_responsePrimitive.primitiveContent := omit;
    			}
    	
    			tc_ac.start;
    			alt {
    				[] mcaPort.receive(mw_request(mw_notify(v_notificationRequest))) -> value v_response {
    					tc_ac.stop;
    					setverdict(pass, testcasename() & ": Notification received");
700
701
    					v_responsePrimitive.requestIdentifier := v_response.primitive.requestPrimitive.requestIdentifier;
    					mcaPort.send(m_httpResponse(v_responsePrimitive)); 						
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
    				}
    				[] mcaPort.receive(mw_request(mw_notify(mw_contentNotification(?)))) -> value v_response {
    					tc_ac.stop;
    					setverdict(fail, testcasename() & ": Notification received but verificationRequest isn't set to TRUE");							
    				}
    				[] mcaPort.receive{
    					tc_ac.stop;
    					setverdict(fail, testcasename() & ": Error, unexpected message received");
    				}
    				[] tc_ac.timeout {
    					setverdict(inconc, testcasename() & ":  No notification received");
    				}
    			}
    	
    			//mcaPort.send(m_response(v_responsePrimitive));	// TODO have to be deleted
    
    			unmap(self:mcaPort, system:mcaPort);
    			unmap(self:acPort, system:acPort); 
    
    		} //end f_subscriptionVerificationHandler
    		
    		function f_checkAttributesToBeSaved (ResourceType p_resourceType, RequestPrimitive p_request, inout ResponsePrimitive p_response) {
    			select (p_resourceType) {
    				case (int1) {
726
727
728
729
    					if(isvalue(p_response.primitiveContent.accessControlPolicy_optional) and
    							not(ispresent(p_response.primitiveContent.accessControlPolicy_optional.resourceName))) {
    						p_response.primitiveContent.accessControlPolicy_optional.resourceName :=  p_request.primitiveContent.accessControlPolicy_optional.resourceName;
    						log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.accessControlPolicy_optional.resourceName)
730
731
732
    					}
    				}
    				case (int2) {
733
734
735
736
    					if(isvalue(p_response.primitiveContent.aE_optional) and
    							not(ispresent(p_response.primitiveContent.aE_optional.resourceName))) {
    						p_response.primitiveContent.aE_optional.resourceName :=  p_request.primitiveContent.aE_optional.resourceName;
							log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.aE_optional.resourceName)
737
738
739
    					}
    				}
    				case (int3) {
740
741
742
743
    					if(isvalue(p_response.primitiveContent.container_optional) and
    							not(ispresent(p_response.primitiveContent.container_optional.resourceName))) {
    						p_response.primitiveContent.container_optional.resourceName :=  p_request.primitiveContent.container_optional.resourceName;
							log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.container_optional.resourceName)
744
745
    					}
    				}
746
					case (int4) {
747
748
749
750
						if(isvalue(p_response.primitiveContent.contentInstance_optional) and
								not(ispresent(p_response.primitiveContent.contentInstance_optional.resourceName))) {
							p_response.primitiveContent.contentInstance_optional.resourceName :=  p_request.primitiveContent.contentInstance_optional.resourceName;
							log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.contentInstance_optional.resourceName)
751
752
						}
					}
753
    				case (int15) {
754
755
756
757
    					if (isvalue(p_response.primitiveContent.pollingChannel_optional) and
    							not(ispresent(p_response.primitiveContent.pollingChannel_optional.resourceName))) {
    						p_response.primitiveContent.pollingChannel_optional.resourceName :=  p_request.primitiveContent.pollingChannel_optional.resourceName;
							log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.pollingChannel_optional.resourceName)
758
759
760
    					}
    				}
    				case (int18) {
761
762
763
764
    					if (isvalue(p_response.primitiveContent.schedule_optional) and
    							not(ispresent(p_response.primitiveContent.schedule_optional.resourceName))) {
    						p_response.primitiveContent.schedule_optional.resourceName :=  p_request.primitiveContent.schedule_optional.resourceName;
							log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.schedule_optional.resourceName)
765
766
767
    					}
    				}
    				case (int23) {
768
769
770
771
    					if (isvalue(p_response.primitiveContent.subscription_optional) and
    							not(ispresent(p_response.primitiveContent.subscription_optional.resourceName))) {
    						p_response.primitiveContent.subscription_optional.resourceName :=  p_request.primitiveContent.subscription_optional.resourceName;
							log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.subscription_optional.resourceName)
772
773
774
    					}
    				}
    				case (int9) {
775
776
777
778
    					if (isvalue(p_response.primitiveContent.group_optional) and
    							not(ispresent(p_response.primitiveContent.group_optional.resourceName))) {
    						p_response.primitiveContent.group_optional.resourceName :=  p_request.primitiveContent.group_optional.resourceName;
							log(__SCOPE__ & ": Info: resourceName not returned. Using the one provided in the request: " & p_request.primitiveContent.group_optional.resourceName)
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
    					}
    				}
    				case else {
    					log(__SCOPE__&":WARNING: Resource Type "&int2str(enum2int(p_resourceType))&" not implemented");
    				}
    			}
    
    			// TODO test that if the resource name is returned is the same resource name as used in the create message
    		}
    
    		function f_check_notificationContent(in RequestPrimitive p_requestPrimitive, template PrimitiveContent p_primitiveContent) runs on CseTester return boolean{
    			// Local variables
    			var boolean v_matchResult := false;
    			var integer i;
    			var integer v_numberOfAggregatedNotification;
    	
795
796
797
    			if (ischosen(p_primitiveContent.aE_optional)){
    				if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource)) {
    					v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.AE_optional, p_primitiveContent.aE_optional)
798
    				}
799
800
    				else if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive)) {
    					v_matchResult :=match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.aE_optional, p_primitiveContent.aE_optional)
801
    				}
802
    				else if (ischosen(p_requestPrimitive.primitiveContent.aggregatedNotification)) {
803
    					v_matchResult := true;
804
    					v_numberOfAggregatedNotification := lengthof(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list);
805
    					for(i := 0; i< v_numberOfAggregatedNotification; i := i + 1){
806
807
    						if(ischosen(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource)) {
    							if(not (match(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.resource.AE_optional, p_primitiveContent.aE_optional))){
808
809
810
    								v_matchResult := false;
    							}
    						}
811
812
    						else if(ischosen(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.responsePrimitive)) {
    							if(not (match(p_requestPrimitive.primitiveContent.aggregatedNotification.notification_list[i].notificationEvent.representation.responsePrimitive.primitiveContent.aE_optional, p_primitiveContent.aE_optional))){
813
814
815
816
817
818
819
820
821
822
823
    								v_matchResult := false;
    							}
    						}						
    					}
    					if (i == 0){
    						v_matchResult := false;
    					}
    				}
    
    			}
    	
824
825
826
    			if (ischosen(p_primitiveContent.container_optional)){
    				if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource)) {
    					v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.resource.Container_optional, p_primitiveContent.container_optional)
827
    				}
828
829
    				else if(ischosen(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive)) {
    					v_matchResult := match(p_requestPrimitive.primitiveContent.notification.notificationEvent.representation.responsePrimitive.primitiveContent.container_optional, p_primitiveContent.container_optional)
830
831
832
833
834
835
    				}
    			}
    	
    			return v_matchResult;
    
    		} //end f_check_notificationContent	
836
		
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
    		function f_cse_notifyProcedure(template PrimitiveContent p_primitiveContent) runs on CseTester {
    			// Local variables
    			var MsgIn v_response;
    	
    			map(self:mcaPort, system:mcaPort);
    			map(self:acPort, system:acPort);
    	
    			tc_ac.start;
    			alt {
    				[] mcaPort.receive(mw_request(mw_notify(mw_contentNotification(?)))) -> value v_response {
    					tc_ac.stop;
    					if(f_check_notificationContent(v_response.primitive.requestPrimitive, p_primitiveContent)){
    						setverdict(pass, testcasename() & ": Notification received");
    						mcaPort.send(m_response(valueof(m_responseNotification(int2001))));
    					}
    					else{
    						setverdict(fail, testcasename() & ": Notification received but the content doesn't match");
    					}
    				}
    				[] mcaPort.receive{
    					tc_ac.stop;
    					setverdict(fail, testcasename() & ": Error, unexpected message received");
    				}
    				[] tc_ac.timeout {
    					setverdict(inconc, testcasename() & ": No notification received");
    				}
    			}
    	
    		
    			unmap(self:mcaPort, system:mcaPort);
    			unmap(self:acPort, system:acPort); 
    	
    		} //end f_cse_notifyProcedure
870
    		
871
872
873
874
875
    		/**
    		 * @desc It determines whether the addressing method of the given address is non-hierarchical. Not valid for CSE-Base as target
    		 * @param p_resourceAddress
    		 * @return boolean
    		 */
876
    		function f_isNonHierarchical(XSD.ID p_resourceAddress) runs on Tester return boolean {	
877
    			var integer i;
878
    			var integer v_nbOfSlashes:= 0;
879
    			
880
881
882
883
884
885
886
887
888
889
890
891
892
				for (i := 0; i < lengthof(p_resourceAddress); i:= i+1){
					if(match (p_resourceAddress[i], "/")){
						v_nbOfSlashes:= v_nbOfSlashes+1;
					}
				}
				
    			if(f_isScopeCseRelative(p_resourceAddress)) {
    				if(v_nbOfSlashes == 0 ) {
    					return true;
    				} else {
    					return false;
    				}
    				
893
    			} else if (f_isScopeSpRelative(p_resourceAddress)){	
894
895
896
897
898
899
900
901
902
903
904
905
906
					if(v_nbOfSlashes == 2 ) {
						return true;
					} else {
						return false;
					}
    			} else if (f_isScopeAbsolute(p_resourceAddress)){
					if(v_nbOfSlashes == 4 ) {
						return true;
					} else {
						return false;
					}
    			} else {
    			   return false;
907
908
909
    			}
    		}
    		
910
911
912
913
914
915
			/**
			 * @desc It determines whether the addressing method of the given address is hierarchical. Not valid for CSE-Base as target
			 * @param p_resourceAddress
			 * @return boolean
			 */
			 function f_isHierarchical(XSD.ID p_resourceAddress) runs on Tester return boolean {
916
917
918
919
920
				if(f_isNonHierarchical(p_resourceAddress)) {
					return false;
				} else {
					return true;
				}	
921
922
    		} 
			
923
924
925
926
927
			/**
			 * @desc It determines whether the primitive scope of the given address is CSE-Relative
			 * @param p_resourceAddress
			 * @return boolean
			 */
928
929
930
931
932
			function f_isScopeCseRelative(XSD.ID p_resourceAddress) runs on Tester return boolean { 
			  if (p_resourceAddress[0] != "/") {
				return true;
			  } else {
			  	return false;
933
934
			  }
			}
935
			
936
937
938
939
940
			/**
			 * @desc It determines whether the primitive scope of the given address is SP-Relative
			 * @param p_resourceAddress
			 * @return boolean
			 */
941
942
943
944
945
946
			function f_isScopeSpRelative(XSD.ID p_resourceAddress) runs on Tester return boolean {	
			  	if ((p_resourceAddress[0] == "/") and (p_resourceAddress[1] != "/")){
				  return true;
				} else {
				  return false;
				}
947
948
			}
			
949
950
951
952
953
			/**
			 * @desc It determines whether the primitive scope of the given address is Absolute
			 * @param p_resourceAddress
			 * @return boolean
			 */
954
955
956
957
958
959
			function f_isScopeAbsolute(XSD.ID p_resourceAddress) runs on Tester return boolean {
				if ((p_resourceAddress[0] == "/") and (p_resourceAddress[1] == "/")) {
				  return true;
				} else {
				  return false;
				}
960
			}
961
962
963
964
965
	
		}//end group helpingFunctions
		
		group CseAltstepFunctions {
			 
966
967
968
969
970
971
			/**
			  * @desc	Cse altstep for config 01
			  */
			 altstep a_cse_cf01() runs on CseTester {
		
				[] mcaPort.receive {
972
					log(__SCOPE__&": WARNING: Unexpected message received");
973
974
975
					repeat;
				}
			 }			
976
			 
977
978
979
980
			/**
			  * @desc	Cse altstep for config 02
			  */
			 altstep a_cse_cf02() runs on CseTester {
981
			
982
				[] mcaPort.receive {
983
					log(__SCOPE__&": WARNING: Unexpected message received");
984
985
986
					repeat;
				}
				[] mccPort.receive {
987
					log(__SCOPE__&": WARNING: Unexpected message received");
988
989
990
991
992
					repeat;
				}
			 }	

		}//end group altstepFunctions	
993
		
994
	}//end cseFunctions
995
	
996
	group AeFunctions {
997
		
998
999
1000
		group preambleFunctions {
		
			/**
For faster browsing, not all history is shown. View entire blame