AtsMec_Grant_TestCases.ttcn 14 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
*    @author   ETSI / STF569
*    @version  $URL:$
*              $ID:$
*    @desc     This module provides the MEC test cases.
*    @copyright   ETSI Copyright Notification
*                 No part may be reproduced except as authorized by written permission.
*                 The copyright and the foregoing restriction extend to reproduction in all media.
*                 All rights reserved.
*    @see      ETSI GS MEC 003, Draft ETSI GS MEC 013 V2.0.3 (2018-10)
*/
module AtsMec_Grant_TestCases {

// Libcommon
import from LibCommon_Sync all;

// LibHttp
import from LibItsHttp_TypesAndValues all;
import from LibItsHttp_Functions all;
import from LibItsHttp_Templates all;
import from LibItsHttp_JsonTemplates all;
import from LibItsHttp_TestSystem all;

// LibMec_LocationAPI
import from Grant_Templates all;
import from Grant_Pics all;
import from Grant_Pixits all;

// LibMec
import from LibMec_Functions all;
import from LibMec_Pics all;
import from LibMec_Pixits all;

group grant {
  
    /**
    * @desc: Check that MEO sends a synchronous grant response when a grant request is requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.1,
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.2.2-1,      //GrantRequest
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.4.2-1       //Grant
    */
    testcase TP_MEC_MEO_GRANT_001_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_GRANTS_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_GRANTS_MANAGEMENT required for executing the TC ***");
            setverdict(inconc);
            stop;
        }

        // Test component configuration
        f_cf_01_http_up();

        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        httpPort.send(
            m_http_request(
                m_http_request_post(
                    "/" & PICS_ROOT_API & PX_MEO_GRANT_URI,
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_grant_request(
                                   m_grant_request(
                                        PX_APP_INSTANCE_ID,
                                        PX_APP_OPERATION
                                   )
                            )
                  )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
YannGarcia's avatar
YannGarcia committed
81
                    mw_http_response_201_created(
82
83
84
85
86
87
88
89
                        mw_http_message_body_json(
                            mw_body_json_grant_response(
                                mw_grant_response(
                                    PX_APP_INSTANCE_ID
                                )
          ))))) -> value v_response {
          tc_ac.stop;
          
YannGarcia's avatar
YannGarcia committed
90
91
          log("*** " & testcasename() & ": PASS: IUT successfully responds with a Grant Response ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
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
385
386
387
388
389
390
391
392
393
394
395
396
397
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
    } // End of testcase TP_MEC_MEO_GRANT_001_OK
 
 
 
    /**
    * @desc: Check that MEO responds with an error when it receives a malformed request when a new grant request is performed
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.1,
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.2.2-1,      //GrantRequest
    */
    testcase TP_MEC_MEO_GRANT_001_BR() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_GRANTS_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_GRANTS_MANAGEMENT required for executing the TC ***");
            setverdict(inconc);
            stop;
        }

        // Test component configuration
        f_cf_01_http_up();

        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        httpPort.send(
            m_http_request(
                m_http_request_post(
                    "/" & PICS_ROOT_API & PX_MEO_GRANT_URI,
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_grant_request_with_error(
                                   m_grant_request_with_error(
                                        PX_APP_INSTANCE_ID,
                                        PX_APP_OPERATION_ERROR
                                   )
                            )
                  )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_400_bad_request(
            ))) -> value v_response {
          tc_ac.stop;
          
          if (v_response.response.statuscode == 400) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a Bad response ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } 
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
    } // End of testcase TP_MEC_MEO_GRANT_001_BR  


    /**
    * @desc: Check that MEO sends a asynchronous grant response when a grant request is requested
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.1,
    *        ETSI GS MEC 010-2 2.0.10, Table 6.2.4.2.2-1,      //GrantRequest
    */
    testcase TP_MEC_MEO_GRANT_002_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_GRANTS_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_GRANTS_MANAGEMENT required for executing the TC ***");
            setverdict(inconc);
            stop;
        }

        // Test component configuration
        f_cf_01_http_up();

        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        httpPort.send(
            m_http_request(
                m_http_request_post(
                    "/" & PICS_ROOT_API & PX_MEO_GRANT_URI,
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_grant_request(
                                   m_grant_request(
                                        PX_APP_INSTANCE_ID,
                                        PX_APP_OPERATION
                                   )
                            )
                  )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
          //@TODO: Need to add 202 accepted to the library      
                    mw_http_response_202_accepted()
		  )) -> value v_response {
          tc_ac.stop;
          //@TODO: How to check Location???
          if (v_response.response.statuscode == 202) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted status code ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } 
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
    } // End of testcase TP_MEC_MEO_GRANT_002_OK


    /**
    * @desc: Check that MEO sends the status of a grant request when a query on a granting ID is performed
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.2,
    */
    testcase TP_MEC_MEO_GRANT_003_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_GRANTS_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_GRANTS_MANAGEMENT required for executing the TC ***");
            setverdict(inconc);
            stop;
        }

        // Test component configuration
        f_cf_01_http_up();

        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        httpPort.send(
            m_http_request(
                m_http_request_get(
                    "/" & PICS_ROOT_API & PX_MEO_GRANT_URI & oct2char(unichar2oct(PX_GRANTING_ID, "UTF-8")),
                        v_headers
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
          //@TODO: Need to add 202 accepted to the library      
                    mw_http_response_202_accepted()
          )) -> value v_response {
          tc_ac.stop;
          //@TODO: How to check Location???
          if (v_response.response.statuscode == 201) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted status code ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } 
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
    } // End of testcase TP_MEC_MEO_GRANT_003_OK


    /**
    * @desc: Check that MEO responds with an error when it receives a request for returning a grant referred with a wrong ID
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.2
    */
    testcase TP_MEC_MEO_GRANT_003_NF() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_GRANTS_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_GRANTS_MANAGEMENT required for executing the TC ***");
            setverdict(inconc);
            stop;
        }

        // Test component configuration
        f_cf_01_http_up();

        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        httpPort.send(
            m_http_request(
                m_http_request_get(
                    "/" & PICS_ROOT_API & PX_MEO_GRANT_URI & oct2char(unichar2oct(PX_NON_EXISTANT_GRANTING_ID, "UTF-8")),
                        v_headers,
                        m_http_message_body_json(
                            m_body_json_grant_request(
                                   m_grant_request(
                                        PX_APP_INSTANCE_ID,
                                        PX_APP_OPERATION
                                   )
                            )
                  )
                        
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_404_not_found(
            ))) -> value v_response {
          tc_ac.stop;
          
          if (v_response.response.statuscode == 404) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a not found status code ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } 
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
    } // End of testcase TP_MEC_MEO_GRANT_003_NF  


    /**
    * @desc: Check that MEO sends the status of a grant request when a query on a granting ID is performed
    *        ETSI GS MEC 010-2 2.0.10, clause 7.6.1.3.2
    *	     ETSI GS MEC 010-2 2.0.10, Table 6.2.4.4.2-1 //Grant
    */
    testcase TP_MEC_MEO_GRANT_004_OK() runs on HttpComponent system HttpTestAdapter {
        // Local variables
        var HeaderLines v_headers;
        var HttpMessage v_response;

        // Test control
        if (not(PIC_GRANTS_MANAGEMENT)){
            log("*** " & testcasename() & ": PIC_GRANTS_MANAGEMENT required for executing the TC ***");
            setverdict(inconc);
            stop;
        }

        // Test component configuration
        f_cf_01_http_up();

        // Preamble
        f_init_default_headers_list(-, -, v_headers);
        httpPort.send(
            m_http_request(
                m_http_request_get(
                    "/" & PICS_ROOT_API & PX_MEO_GRANT_URI & oct2char(unichar2oct(PX_GRANTING_ID, "UTF-8")),
                        v_headers
                )));
        f_selfOrClientSyncAndVerdict(c_prDone, e_success);

        // Test Body
        tc_ac.start;
        alt {
            [] httpPort.receive(
                mw_http_response(
                    mw_http_response_ok(
                        mw_http_message_body_json(
                            mw_body_json_grant_response(
                                mw_grant_response(
                                    PX_APP_INSTANCE_ID
                                )
          ))))) -> value v_response {
          tc_ac.stop;
          //@TODO: How to check Location???
          if (v_response.response.statuscode == 200) {
            log("*** " & testcasename() & ": PASS: IUT successfully responds with a 202 accepted status code ***");
            f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
          } 
        }
        [] tc_ac.timeout {
          log("*** " & testcasename() & ": INCONC: Expected message not received ***");
          f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
        }
      } // End of 'alt' statement
    } // End of testcase TP_MEC_MEO_GRANT_004_OK

}


  
}