blob: 35ab79fc19ba9817d04ba2599ad7527ff6726270 [file] [log] [blame]
Philipp Maierbb169b22024-03-04 11:09:00 +01001/* IPAd testsuite in TTCN-3
2 *
3 * Author: Philipp Maier <pmaier@sysmocom.de> / sysmocom - s.f.m.c. GmbH
4 *
5 * Released under the terms of GNU General Public License, Version 2 or
6 * (at your option) any later version.
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
11module IPAd_Tests {
12
13import from Misc_Helpers all;
14import from General_Types all;
15import from Osmocom_Types all;
16
17import from SGP32Definitions all;
18import from SGP32Definitions_Types all;
19import from SGP32Definitions_Templates all;
20
21import from RSPDefinitions all;
22import from RSPDefinitions_Types all;
23import from RSPDefinitions_Templates all;
24
25import from PKIX1Explicit88 all;
26import from PKIX1Explicit88_Templates all;
27import from PKIX1Explicit88_Types all;
28
29import from HTTP_Server_Emulation all;
30import from HTTPmsg_Types all;
31
32import from VPCD_Types all;
33import from VPCD_CodecPort all;
34import from VPCD_Adapter all;
35
36modulepar {
37 /* emulated eIM HTTPs server */
38 charstring mp_esipa_ip := "127.0.0.1";
39 integer mp_esipa_port := 4430;
40 boolean mp_esipa_disable_ssl := false;
41 boolean mp_use_vpcd := true;
42 float mp_restart_guardtime := 2.0
43}
44
45/* Altstep to handle card power up/down and ATR transmission */
46private altstep as_vpcd_atr() runs on VPCD_Adapter_CT {
47 [] VPCD.receive(tr_VPCD_Recv(g_vpcd_conn_id, tr_VPCD_CTRL_ATR)) {
48 f_vpcd_send(ts_VPCD_DATA('3B9F96801FC78031A073BE21136743200718000001A5'O));
49 repeat;
50 }
51 [] VPCD.receive(tr_VPCD_Recv(g_vpcd_conn_id, tr_VPCD_CTRL_OFF)) {
52 repeat;
53 }
54 [] VPCD.receive(tr_VPCD_Recv(g_vpcd_conn_id, tr_VPCD_CTRL_ON)) {
55 repeat;
56 }
57}
58
59/* Helper template to format HTTP responses */
60private template (value) HTTPMessage ts_http_resp(template (value) octetstring resp := ''O) := {
61 response_binary := {
62 client_id := omit,
63 version_major := 1,
64 version_minor := 1,
65 statuscode := 200,
66 statustext := "OK",
67 /* See also SGP.32, section 6.1.1 */
68 header := {
69 {
70 header_name := "X-Admin-Protocol",
71 header_value := "gsma/rsp/v1.0.0"
72 },
73 {
74 header_name := "Content-Type",
75 header_value := "application/x-gsma-rsp-asn1"
76 },
77 {
78 header_name := "Content-Length",
79 header_value := int2str(lengthof(resp))
80 }
81 },
82 body := resp
83 }
84}
85
86type component MTC_CT {
87 timer g_Tguard;
88
89 /* HTTP server */
90 var HTTP_Server_Emulation_CT vc_HTTP;
91};
92
93type component IPAd_ConnHdlr extends HTTP_ConnHdlr, VPCD_Adapter_CT {
94 var IPAd_ConnHdlrPars g_pars;
95};
96
97type record IPAd_ConnHdlrPars {
98 /* TODO: add some useful parameters */
99};
100
101private function f_init_pars()
102runs on MTC_CT return IPAd_ConnHdlrPars {
103 var IPAd_ConnHdlrPars pars := {
104 /* TODO: fill parameters with meaninful values */
105 };
106 return pars;
107}
108
109private altstep as_Tguard() runs on MTC_CT {
110 [] g_Tguard.timeout {
111 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail, "Tguard timeout");
112 }
113}
114
115private type function void_fn(charstring id) runs on IPAd_ConnHdlr;
116
117private function f_init_handler(void_fn fn, charstring id, IPAd_ConnHdlrPars pars) runs on IPAd_ConnHdlr {
118 g_pars := pars;
119
120 /* Initialize VPDC (virtual smartcard) */
121 if (mp_use_vpcd) {
122 VPCD_Adapter.f_connect();
123 activate(as_vpcd_atr());
124 }
125
126 fn.apply(id);
127}
128
129private function f_start_handler(void_fn fn, IPAd_ConnHdlrPars pars)
130runs on MTC_CT return IPAd_ConnHdlr {
131 var IPAd_ConnHdlr vc_conn;
132 var charstring id := testcasename();
133
134 vc_conn := IPAd_ConnHdlr.create(id);
135
136 if (isbound(vc_HTTP)) {
137 connect(vc_conn:HTTP_SRV, vc_HTTP:CLIENT);
138 connect(vc_conn:HTTP_SRV_PROC, vc_HTTP:CLIENT_PROC);
139 }
140
141 vc_conn.start(f_init_handler(fn, id, pars));
142 return vc_conn;
143}
144
145function f_init_esipa(charstring id) runs on MTC_CT {
146 var HttpServerEmulationCfg http_cfg := {
147 http_bind_ip := mp_esipa_ip,
148 http_bind_port := mp_esipa_port,
149 use_ssl := not mp_esipa_disable_ssl
150 };
151
152 vc_HTTP := HTTP_Server_Emulation_CT.create(id);
153 vc_HTTP.start(HTTP_Server_Emulation.main(http_cfg));
154}
155
156private function f_init(charstring id, float t_guard := 40.0) runs on MTC_CT {
157 /* Ensure a guard time inbetween tests. This is to make sure that the IPAd is able to finish its current poll
158 * cycle. In practice this means that the IPAd will notice that the connectivity towards the eIM is lost and
159 * since this is one of the conditions for ending the current poll cycle it will exit. A freshly restarted
160 * IPAd is a mandatory start condition for the tests since all tests expect the initialization procedure
161 * (selection of ISD-P etc.) that the IPAd executes on startup. */
162 f_sleep(mp_restart_guardtime);
163
164 g_Tguard.start(t_guard);
165 activate(as_Tguard());
166 f_init_esipa(id);
167}
168
169/* Expect a GetResponse request from IUT and transfer as many response bytes the IUT requests */
170private function f_vpcd_get_response(octetstring response) runs on IPAd_ConnHdlr return integer {
171 var octetstring sw;
172 var VPCD_PDU req;
173 var integer len;
174
175 req := f_vpcd_exp(tr_VPCD_DATA(?));
176 len := oct2int(req.u.data[4]);
177 if (len == 0) {
178 len := 256;
179 }
180
181 /* Make sure that the request APDU is actually a GetResponse request (on logical channel 2) */
182 if (substr(req.u.data, 0, 4) != '01c00000'O) {
183 setverdict(fail, "unexpected APDU, expecting GetResponse");
184 return 0;
185 }
186
187 /* Compute status word, in case the requested data is shorter then the response data we intend to send, we must
188 * tell the IUT that there is still data available, so that a consecutive GetResponse request can be issued.
189 * (caller must check return code to determine if a consecutive GetResponse is needed/expected) */
190 if (lengthof(response) > len) {
191 if (lengthof(response) - len > 255) {
192 sw := '6100'O;
193 } else {
194 sw := '61'O & int2oct(lengthof(response) - len, 1);
195 }
196 } else {
197 sw := '9000'O;
198 }
199
200 /* Send response to IUT */
201 f_vpcd_send(ts_VPCD_DATA(substr(response, 0, len) & sw));
202
203 /* Return how many bytes have sent */
204 return len;
205}
206
207/* Expect one or more GetResponse requests from IUT until the full response is transferred */
208private function f_vpcd_get_response_multi(octetstring response) runs on IPAd_ConnHdlr {
209 var integer bytes_sent := 0;
210 var octetstring response_remainder := response;
211
212 while (true) {
213 response_remainder := substr(response_remainder, bytes_sent, lengthof(response_remainder) - bytes_sent);
214 bytes_sent := f_vpcd_get_response(response_remainder);
215
216 /* Check if we reached the last chunk */
217 if (lengthof(response_remainder) <= bytes_sent) {
218 return;
219 }
220 }
221}
222
223/* Expect one or more STORE DATA requests until the IUT has completed the transmision cycle */
224private function f_vpcd_store_data(octetstring exp := ''O) runs on IPAd_ConnHdlr return octetstring {
225
226 var VPCD_PDU req;
227 var octetstring block;
228 var integer len;
229 var octetstring data := ''O;
230
231 while (true) {
232 req := f_vpcd_exp(tr_VPCD_DATA(?));
233
234 /* Make sure that the request APDU is actually a STORE DATA request (on logical channel 1) */
235 if (substr(req.u.data, 0, 3) != '81E291'O and
236 substr(req.u.data, 0, 3) != '81E211'O) {
237 setverdict(fail, "unexpected APDU, expecting GetResponse");
238 return ''O;
239 }
240
241 if (lengthof(req.u.data) - 5 > 255) {
242 len := 255;
243 } else {
244 len := lengthof(req.u.data) - 5;
245 }
246 block := substr(req.u.data, 5, len);
247 data := data & block;
248
249 /* The final status word contains the length of the response. We can not send it right now
250 * since the caller must first process the received data block and compute a response. When
251 * the exact length of the response data is known. The final status word can be sent using
252 * f_vpcd_store_data_final_ack() */
253 if (substr(req.u.data, 2, 1) == '91'O) {
254 if (exp != ''O and block != exp) {
255 setverdict(fail, "received block contains unexpected data (", block, " != ", exp, ")");
256 }
257 return block;
258 }
259
260 f_vpcd_send(ts_VPCD_DATA('9000'O));
261 }
262
263 setverdict(fail, "no data? (we should not reach this code path)");
264 return ''O;
265}
266
267/* Send a final status word to acknowledge the last block of a STORE DATA transmission. The status word will tell
268 * the IUT how many response bytes are available. (The IUT will immediately begin to fetch the response using
269 * one or more GetResponse requests */
270private function f_vpcd_store_data_final_ack(integer response_len) runs on IPAd_ConnHdlr {
271 var octetstring second_sw_byte;
272 var octetstring first_sw_byte;
273
274 if (response_len > 255) {
275 second_sw_byte := '00'O;
276 } else {
277 second_sw_byte := int2oct(response_len, 1);
278 }
279
280 if (response_len > 0) {
281 first_sw_byte := '61'O; /* 61xx */
282 } else {
283 first_sw_byte := '90'O; /* 9000 */
284 }
285
286 f_vpcd_send(ts_VPCD_DATA(first_sw_byte & second_sw_byte));
287}
288
289/* Expect a pre-defined request (optional), and send a pre-defined response. This is a shortcut that only works in case
290 * the response does not depend on the request. */
291private function f_vpcd_transceive(octetstring response, octetstring expected_request := ''O) runs on IPAd_ConnHdlr {
292
293 /* In case we do not use the VPCD (because we have some other kind of eUICC emulation or even a real card
294 * present), we just skip. */
295 if (mp_use_vpcd == false) {
296 return;
297 }
298
299 f_vpcd_store_data(expected_request);
300 f_vpcd_store_data_final_ack(lengthof(response));
301 if (response != ''O) {
302 f_vpcd_get_response_multi(response);
303 }
304}
305
306/* Handle the opening of logical channel 1 and the selection of the ISD-R */
307private function f_es10x_init() runs on IPAd_ConnHdlr {
308 var charstring eim_fqdn := mp_esipa_ip & ":" & int2str(mp_esipa_port);
309
310 /* If we decide not to use vpcd, then we must not initialize anything here */
311 if (mp_use_vpcd == false) {
312 return;
313 }
314
315 /* Expect a MANAGE CHANNEL request that opens logical channel 1 */
316 f_vpcd_exp(tr_VPCD_DATA('0070000100'O));
317 f_vpcd_send(ts_VPCD_DATA('9000'O));
318
319 /* Expect selection of ISD-R request */
320 f_vpcd_exp(tr_VPCD_DATA('01a4040410a0000005591010ffffffff8900000100'O));
321 f_vpcd_send(ts_VPCD_DATA('6121'O)); /* 21 bytes of response, which are not requested by the ipad. */
322
323 /* Expect the IPAd to query the eID from the eUICC */
324 f_vpcd_transceive(enc_GetEuiccDataResponse(valueof(ts_getEuiccDataResponse)), 'BF3E035C015A'O);
325
326 /* Expect the IPAd to query the eIM configuration data from the eUICC */
327 f_vpcd_transceive(enc_GetEimConfigurationDataResponse(valueof(ts_getEimConfigurationDataResponse(eim_fqdn))), 'BF5500'O);
328}
329
330/* Handle the closing of logical channel 1 */
331private function f_es10x_close() runs on IPAd_ConnHdlr {
332
333 /* Expect a MANAGE CHANNEL request that closes logical channel 1 */
334 f_vpcd_exp(tr_VPCD_DATA('0070800100'O));
335 f_vpcd_send(ts_VPCD_DATA('9000'O));
336}
337
338/* Receive ESipa HTTP request */
339private function f_esipa_receive() runs on IPAd_ConnHdlr return EsipaMessageFromIpaToEim {
340 var HTTPMessage esipa_req;
341 timer T := 10.0;
342 var EsipaMessageFromIpaToEim request;
343
344 T.start;
345 alt {
346 [] HTTP_SRV.receive({ request_binary := ? }) -> value esipa_req {
347 request := dec_EsipaMessageFromIpaToEim(esipa_req.request_binary.body);
348 }
349 [] T.timeout {
350 setverdict(fail, "no HTTP request received?");
351 }
352 }
353
354 return request;
355}
356
357/* Send ESipa HTTP response */
358private function f_esipa_send(EsipaMessageFromEimToIpa response) runs on IPAd_ConnHdlr {
359 var octetstring esipa_res;
360 esipa_res := enc_EsipaMessageFromEimToIpa(response);
361 HTTP_SRV.send(ts_http_resp(esipa_res));
362}
363
364/* Perform one ESipa HTTP request/response cycle */
365private function f_esipa_transceive(EsipaMessageFromEimToIpa response) runs on IPAd_ConnHdlr return EsipaMessageFromIpaToEim {
366 var EsipaMessageFromIpaToEim request;
367
368 request := f_esipa_receive();
369 f_esipa_send(response);
370
371 return request;
372}
373
374/* Perform one ESipa HTTP request/response cycle but with an empty response */
375private function f_esipa_transceive_empty_response() runs on IPAd_ConnHdlr return EsipaMessageFromIpaToEim {
376 var EsipaMessageFromIpaToEim request;
377
378 request := f_esipa_receive();
379 HTTP_SRV.send(ts_http_resp(''O));
380 return request;
381}
382
383/* Common Mutual Authentication Procedure, see also: GSMA SGP.22, section 3.0.1 */
384private function f_proc_cmn_mtl_auth() runs on IPAd_ConnHdlr {
385 var EsipaMessageFromIpaToEim esipa_req;
386 var EsipaMessageFromEimToIpa esipa_res;
387
388 /* Step #1 */
389 f_vpcd_transceive(enc_EUICCInfo1(valueof(ts_EUICCInfo1)), 'bf2000'O);
390
391 /* Step #2-#4 */
392 f_vpcd_transceive(enc_GetEuiccChallengeResponse(valueof(ts_GetEuiccChallengeResponse)), 'bf2e00'O);
393
394 /* Step #5-#10 */
395 esipa_req := f_esipa_receive();
396 if (not match(esipa_req, tr_initiateAuthenticationRequestEsipa)) {
397 setverdict(fail, "unexpected message from IPAd");
398 }
399 esipa_res := valueof(ts_initiateAuthenticationResponseEsipa(euiccChallenge := esipa_req.initiateAuthenticationRequestEsipa.euiccChallenge));
400 f_esipa_send(esipa_res);
401
402 /* Step #11-#14 */
403 f_vpcd_transceive(enc_AuthenticateServerResponse(valueof(ts_authenticateServerResponse)));
404
405 /* Step #15-#17 */
406 esipa_req := f_esipa_transceive(valueof(ts_authenticateClientResponseEsipa_dpe));
407 if (not match(esipa_req, tr_authenticateClientRequestEsipa)) {
408 setverdict(fail, "unexpected message from IPAd");
409 }
410}
411
412/* ********************************************* */
413/* ********** BELOW ONLY TESTCASES! ************ */
414/* ********************************************* */
415
416
417/* A testcase to try out an the Common Mutual Authentication Procedure */
418private function f_TC_proc_direct_prfle_dwnld(charstring id) runs on IPAd_ConnHdlr {
419 var EsipaMessageFromIpaToEim esipa_req;
420 var EsipaMessageFromEimToIpa esipa_res;
421 var integer i;
422 var charstring eim_fqdn := mp_esipa_ip & ":" & int2str(mp_esipa_port);
423 var BoundProfilePackage boundProfilePackage;
424
425 f_es10x_init();
426 f_http_register();
427
428 /* Prepare direct profile download by responding with a download trigger request */
429 esipa_res := valueof(ts_getEimPackageResponse_dnlTrigReq);
430 esipa_req := f_esipa_transceive(esipa_res);
431 if (not match(esipa_req, tr_getEimPackageRequest)) {
432 setverdict(fail, "unexpected message from IPAd");
433 }
434
435 /* Expect the IPAd to query the eIM configuration data from the eUICC */
436 f_vpcd_transceive(enc_GetEimConfigurationDataResponse(valueof(ts_getEimConfigurationDataResponse(eim_fqdn))), 'BF5500'O);
437
438 f_proc_cmn_mtl_auth();
439
440 f_vpcd_transceive(enc_PrepareDownloadResponse(valueof(ts_prepareDownloadResponse)));
441
442 esipa_res := valueof(ts_getBoundProfilePackageResponseEsipa);
443 esipa_req := f_esipa_transceive(esipa_res);
444 boundProfilePackage := esipa_res.getBoundProfilePackageResponseEsipa.getBoundProfilePackageOkEsipa.boundProfilePackage;
445 /* TODO: match response (we do not have a template yet) */
446
447 /* initialiseSecureChannelRequest */
448 f_vpcd_transceive(''O);
449
450 /* Step #3 (ES8+.ConfigureISDP) */
451 for (i := 0; i < sizeof(boundProfilePackage.firstSequenceOf87); i := i + 1) {
452 f_vpcd_transceive(''O);
453 }
454
455 /* Step #4 (ES8+.StoreMetadata) */
456 for (i := 0; i < sizeof(boundProfilePackage.sequenceOf88); i := i + 1) {
457 f_vpcd_transceive(''O);
458 }
459
460 /* Step #5 (ES8+.ReplaceSessionKeys", optional, left out) */
461 if (ispresent(boundProfilePackage.secondSequenceOf87)) {
462 for (i := 0; i < sizeof(boundProfilePackage.secondSequenceOf87); i := i + 1) {
463 f_vpcd_transceive(''O);
464 }
465 }
466
467 /* Step #6 (ES8+.LoadProfileElements) */
468 for (i := 0; i < sizeof(boundProfilePackage.sequenceOf86); i := i + 1) {
469 if (i < sizeof(boundProfilePackage.sequenceOf86) - 1) {
470 f_vpcd_transceive(''O);
471 } else {
472 /* In the last message we send the ProfileInstallationResult */
473 f_vpcd_transceive(enc_ProfileInstallationResult(valueof(ts_profileInstallationResult)));
474 }
475 }
476
477 /* Receive ProfileInstallationResult from iPAD->eIM */
478 esipa_req := f_esipa_transceive_empty_response();
479 /* TODO: match response (we do not have a template yet) */
480
481 /* Receive RemoveNotificationFromList from iPAD->eUICC */
482 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
483
484 /* Wait some time until the the last HTTP response is actually delivered */
485 f_sleep(2.0);
486
487 f_es10x_close();
488
489 setverdict(pass);
490}
491testcase TC_proc_direct_prfle_dwnld() runs on MTC_CT {
492 var charstring id := testcasename();
493 var IPAd_ConnHdlrPars pars := f_init_pars();
494 var IPAd_ConnHdlr vc_conn;
495 f_init(id);
496 vc_conn := f_start_handler(refers(f_TC_proc_direct_prfle_dwnld), pars);
497 vc_conn.done;
498 setverdict(pass);
499}
500
501
502/* A testcase to try out an the Generic eUICC Package Download and Execution Procedure */
503private function f_TC_proc_euicc_pkg_dwnld_exec(charstring id) runs on IPAd_ConnHdlr {
504 var EsipaMessageFromIpaToEim esipa_req;
505 var EsipaMessageFromEimToIpa esipa_res;
506
507 f_es10x_init();
508 f_http_register();
509
510 /* Step #1-#2 */
511 esipa_res := valueof(ts_getEimPackageResponse_euiccPkgReq);
512 esipa_req := f_esipa_transceive(esipa_res);
513 if (not match(esipa_req, tr_getEimPackageRequest)) {
514 setverdict(fail, "unexpected message from IPAd");
515 }
516
517 /* Step #3-#8 */
518 f_vpcd_transceive(enc_EuiccPackageResult(valueof(ts_euiccPackageResult)));
519
520 /* Step #9 */
521 f_vpcd_transceive(enc_RetrieveNotificationsListResponse(valueof(ts_retrieveNotificationsListResponse)));
522
523 /* Step #10-14 */
524 esipa_res := valueof(ts_provideEimPackageResultResponse_eimAck(eimAcknowledgements := {1,2,3,4}));
525 esipa_req := f_esipa_transceive(esipa_res);
526 if (not match(esipa_req, tr_provideEimPackageResult_ePRAndNotif)) {
527 setverdict(fail, "unexpected message from IPAd");
528 }
529
530 /* Step #15-17 */
531 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
532 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
533 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
534 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
535 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
536
537 /* Wait some time until the the last HTTP response is actually delivered */
538 f_sleep(2.0);
539
540 f_es10x_close();
541
542 setverdict(pass);
543}
544
545testcase TC_proc_euicc_pkg_dwnld_exec() runs on MTC_CT {
546 var charstring id := testcasename();
547 var IPAd_ConnHdlrPars pars := f_init_pars();
548 var IPAd_ConnHdlr vc_conn;
549 f_init(id);
550 vc_conn := f_start_handler(refers(f_TC_proc_euicc_pkg_dwnld_exec), pars);
551 vc_conn.done;
552 setverdict(pass);
553}
554
555
556/* A testcase to try out an the Generic eUICC Package Download and Execution Procedure, but this time we force a rollback meneuver */
557private function f_TC_proc_euicc_pkg_dwnld_exec_rollback(charstring id) runs on IPAd_ConnHdlr {
558 var EsipaMessageFromIpaToEim esipa_req;
559 var EsipaMessageFromEimToIpa esipa_res;
560
561 f_es10x_init();
562 f_http_register();
563
564 /* Step #1-#2 */
565 esipa_res := valueof(ts_getEimPackageResponse_euiccPkgReq);
566 esipa_req := f_esipa_transceive(esipa_res);
567 if (not match(esipa_req, tr_getEimPackageRequest)) {
568 setverdict(fail, "unexpected message from IPAd");
569 }
570
571 /* Step #3-#8 */
572 f_vpcd_transceive(enc_EuiccPackageResult(valueof(ts_euiccPackageResult)));
573
574 /* Step #9 */
575 f_vpcd_transceive(enc_RetrieveNotificationsListResponse(valueof(ts_retrieveNotificationsListResponse)));
576
577 /* We now ignore the response from the IPAd. The IPAd will interpret this as a disturbed IP connection. */
578 f_esipa_receive();
579
580 /* To fix the problem, the IPAd will now try a profile rollback meneuver. */
581 f_vpcd_transceive(enc_ProfileRollbackResponse(valueof(ts_profileRollbackResponse)),
582 enc_ProfileRollbackRequest(valueof(ts_profileRollbackRequest)));
583
584 /* At this point the old profile is active again. The IPAd is now expected to start at Step #9 again
585 * to continue the procedure normally. */
586
587 /* Step #9 */
588 f_vpcd_transceive(enc_RetrieveNotificationsListResponse(valueof(ts_retrieveNotificationsListResponse)));
589
590 /* Step #10-14 */
591 esipa_res := valueof(ts_provideEimPackageResultResponse_eimAck(eimAcknowledgements := {1,2,3,4}));
592 esipa_req := f_esipa_transceive(esipa_res);
593 if (not match(esipa_req, tr_provideEimPackageResult_ePRAndNotif)) {
594 setverdict(fail, "unexpected message from IPAd");
595 }
596
597 /* Step #15-17 */
598 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
599 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
600 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
601 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
602 f_vpcd_transceive(enc_NotificationSentResponse(valueof(ts_notificationSentResponse)));
603
604 /* Wait some time until the the last HTTP response is actually delivered */
605 f_sleep(2.0);
606
607 f_es10x_close();
608
609 setverdict(pass);
610}
611
612testcase TC_proc_euicc_pkg_dwnld_exec_rollback() runs on MTC_CT {
613 var charstring id := testcasename();
614 var IPAd_ConnHdlrPars pars := f_init_pars();
615 var IPAd_ConnHdlr vc_conn;
616 f_init(id);
617 vc_conn := f_start_handler(refers(f_TC_proc_euicc_pkg_dwnld_exec_rollback), pars);
618 vc_conn.done;
619 setverdict(pass);
620}
621
622
623/* A testcase to try out an IpaEuiccDataRequest */
624private function f_TC_proc_euicc_data_req(charstring id) runs on IPAd_ConnHdlr {
625 var EsipaMessageFromIpaToEim esipa_req;
626 var EsipaMessageFromEimToIpa esipa_res;
627 var charstring eim_fqdn := mp_esipa_ip & ":" & int2str(mp_esipa_port);
628
629 f_es10x_init();
630 f_http_register();
631
632 /* IPAd requests a package, we tell it to execute an ipaEuiccDataRequest */
633 esipa_res := valueof(ts_getEimPackageResponse_euiccDataReq);
634 esipa_req := f_esipa_transceive(esipa_res);
635 if (not match(esipa_req, tr_getEimPackageRequest)) {
636 setverdict(fail, "unexpected message from IPAd");
637 }
638
639 /* IPAd will obtain the data from the eUICC */
640 f_vpcd_transceive(enc_EuiccConfiguredAddressesResponse(valueof(ts_euiccConfiguredAddressesResponse)));
641 f_vpcd_transceive(enc_EUICCInfo1(valueof(ts_EUICCInfo1)));
642 f_vpcd_transceive(enc_EUICCInfo2(valueof(ts_EUICCInfo2)));
643 f_vpcd_transceive(enc_GetEimConfigurationDataResponse(valueof(ts_getEimConfigurationDataResponse(eim_fqdn))));
644 f_vpcd_transceive(enc_GetCertsResponse(valueof(ts_getCertsResponse)));
645 f_vpcd_transceive(enc_RetrieveNotificationsListResponse(valueof(ts_retrieveNotificationsListResponse)));
646
647 /* IPAd will return the data to us */
648 esipa_res := valueof(ts_provideEimPackageResultResponse_eimAck(eimAcknowledgements := {1,2,3,4}));
649 esipa_req := f_esipa_transceive(esipa_res);
650
651 /* Wait some time until the the last HTTP response is actually delivered */
652 f_sleep(2.0);
653
654 f_es10x_close();
655
656 setverdict(pass);
657}
658testcase TC_proc_euicc_data_req() runs on MTC_CT {
659 var charstring id := testcasename();
660 var IPAd_ConnHdlrPars pars := f_init_pars();
661 var IPAd_ConnHdlr vc_conn;
662 f_init(id);
663 vc_conn := f_start_handler(refers(f_TC_proc_euicc_data_req), pars);
664 vc_conn.done;
665 setverdict(pass);
666}
667
668/* A testcase to try out what happens when the eIM package request is rejected */
669private function f_TC_get_eim_pkg_req_rej(charstring id) runs on IPAd_ConnHdlr {
670 var EsipaMessageFromIpaToEim esipa_req;
671 var EsipaMessageFromEimToIpa esipa_res;
672
673 f_es10x_init();
674 f_http_register();
675
676 /* IPAd requests a package, we respond with an eimPackageError code 127 (undefined error) */
677 esipa_res := valueof(ts_getEimPackageResponse_eimPkgErrUndef);
678 esipa_req := f_esipa_transceive(esipa_res);
679 if (not match(esipa_req, tr_getEimPackageRequest)) {
680 setverdict(fail, "unexpected message from IPAd");
681 }
682
683 /* Wait some time until the the last HTTP response is actually delivered */
684 f_sleep(2.0);
685
686 f_es10x_close();
687
688 setverdict(pass);
689}
690testcase TC_get_eim_pkg_req_rej() runs on MTC_CT {
691 var charstring id := testcasename();
692 var IPAd_ConnHdlrPars pars := f_init_pars();
693 var IPAd_ConnHdlr vc_conn;
694 f_init(id);
695 vc_conn := f_start_handler(refers(f_TC_get_eim_pkg_req_rej), pars);
696 vc_conn.done;
697 setverdict(pass);
698}
699
700control {
701 execute ( TC_proc_direct_prfle_dwnld() );
702 execute ( TC_proc_euicc_pkg_dwnld_exec() );
703 execute ( TC_proc_euicc_pkg_dwnld_exec_rollback() );
704 execute ( TC_proc_euicc_data_req() );
705 execute ( TC_get_eim_pkg_req_rej() );
706}
707
708}