blob: c4cad38287baac7fa850a64bab522fda9447607f [file] [log] [blame]
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +01001module Asterisk_Tests {
2
3/* Asterisk test suite in TTCN-3
4 * (C) 2024 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
5 * All rights reserved.
6 * Author: Pau Espin Pedrol <pespin@sysmocom.de>
7 *
8 * Released under the terms of GNU General Public License, Version 2 or
9 * (at your option) any later version.
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
Pau Espin Pedrol05eaa1a2024-04-02 12:56:26 +020014import from TCCOpenSecurity_Functions all;
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010015import from General_Types all;
16import from Osmocom_Types all;
17import from Native_Functions all;
18import from Misc_Helpers all;
Pau Espin Pedrol54b614a2024-04-17 18:58:36 +020019import from TELNETasp_PortType all;
20import from AMI_Functions all;
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010021
22import from SDP_Types all;
23import from SDP_Templates all;
24
25import from SIP_Emulation all;
26import from SIPmsg_Types all;
27import from SIP_Templates all;
28
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +020029import from SIP_ConnectionHandler all;
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +020030import from IMS_ConnectionHandler all;
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +020031
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010032modulepar {
33 charstring mp_local_sip_host := "127.0.0.2";
34 integer mp_local_sip_port := 5060;
35 charstring mp_remote_sip_host := "127.0.0.1";
36 integer mp_remote_sip_port := 5060;
Pau Espin Pedrol54b614a2024-04-17 18:58:36 +020037
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +020038 charstring mp_local_ims_host := "127.0.0.3";
39 integer mp_local_ims_port := 5060;
Pau Espin Pedrolf46132e2024-06-04 17:11:59 +020040 charstring mp_ims_domain := "ims.mnc001.mcc238.3gppnetwork.org"
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +020041 charstring mp_ims_imsi := "238010000090828";
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +020042
Pau Espin Pedrol54b614a2024-04-17 18:58:36 +020043 /* Asterisk AMI: */
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +020044 charstring mp_ami_remote_host := "127.0.0.1";
45 integer mp_ami_remote_port := 5038;
46 charstring mp_ami_local_host := "0.0.0.0";
47 integer mp_ami_local_port := 0;
Pau Espin Pedrol54b614a2024-04-17 18:58:36 +020048 charstring mp_ami_user := "test_user";
49 charstring mp_ami_secret := "1234";
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +020050 charstring mp_volte_ims_outbound_registration := "volte_ims";
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010051}
52
53type component test_CT {
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +020054 /* Manages all local VoIP users Asterisk is serving: */
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010055 var SIP_Emulation_CT vc_SIP;
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +020056 /* Manages the IMS server Asterisk connects to: */
57 var SIP_Emulation_CT vc_IMS;
58
Pau Espin Pedrolbcb4e822024-04-26 20:16:47 +020059 /* Connection towards Asterisk AMI iface: */
60 var AMI_Adapter_CT vc_AMI;
61 port AMI_Msg_PT AMI_CLIENT;
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +020062
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +020063 port Coord_PT COORD;
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +020064 port IMSCoord_PT IMS_COORD;
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010065}
66
Pau Espin Pedrol32167d82024-04-10 13:14:51 +020067const charstring broadcast_sip_extension := "0500";
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010068
Pau Espin Pedrol901cede2024-05-30 13:03:42 +020069
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +020070function f_init_ConnHdlrPars(integer idx := 1) runs on test_CT return SIPConnHdlrPars {
71 var template (value) CallPars cp := t_CallPars(mp_local_sip_host, 1234 + 2*idx);
72 var template (value) SIPConnHdlrPars pars := t_Pars(mp_local_sip_host,
73 mp_local_sip_port,
74 mp_remote_sip_host,
75 mp_remote_sip_port,
76 "0" & int2str(str2int(broadcast_sip_extension) + idx),
77 cp := cp);
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +020078 return valueof(pars);
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +010079}
80
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +020081function f_init_IMS_ConnHdlrPars(integer idx := 1) runs on test_CT return IMS_ConnHdlrPars {
Pau Espin Pedrolf385c752024-06-07 19:15:47 +020082 var template (value) IMS_CallPars cp := t_IMS_CallPars(mp_local_ims_host, 1234 + 2*idx);
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +020083 var template (value) IMS_ConnHdlrPars pars := t_IMS_Pars(mp_local_ims_host,
84 mp_local_ims_port,
Pau Espin Pedrolf46132e2024-06-04 17:11:59 +020085 mp_ims_domain,
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +020086 mp_ims_imsi,
87 cp := cp);
88 return valueof(pars);
89}
90
Pau Espin Pedrol54b614a2024-04-17 18:58:36 +020091/* Initialize connection towards Asterisk AMI */
92private function f_init_ami() runs on test_CT {
Pau Espin Pedrolbcb4e822024-04-26 20:16:47 +020093 var charstring id := "Asterisk_Tests_AMI_EMU";
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +020094 vc_AMI := AMI_Adapter_CT.create(id) alive;
Pau Espin Pedrolbcb4e822024-04-26 20:16:47 +020095 connect(self:AMI_CLIENT, vc_AMI:CLIENT);
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +020096
97 var AMI_Adapter_Parameters ami_pars := {
98 remote_host := mp_ami_remote_host,
99 remote_port := mp_ami_remote_port,
100 local_host := mp_ami_local_host,
101 local_port := mp_ami_local_port,
102 welcome_str := c_default_AMI_Adapter_pars.welcome_str
103 };
104 vc_AMI.start(f_AMI_Adapter_main(ami_pars));
Pau Espin Pedrolbcb4e822024-04-26 20:16:47 +0200105
Pau Espin Pedrolbcb4e822024-04-26 20:16:47 +0200106 f_ami_action_login(AMI_CLIENT, mp_ami_user, mp_ami_secret);
Pau Espin Pedrole98f4412024-05-17 19:33:46 +0200107
108 timer tReady;
109 tReady.start(10.0);
110 alt {
111 [] AMI_CLIENT.receive(tr_AMI_Event_FullyBooted);
112 [] as_ami_rx_ignore(AMI_CLIENT);
113 [] tReady.timeout {
114 Misc_Helpers.f_shutdown(__BFILE__, __LINE__, fail,
115 log2str("AMI FullyBooted timeout: "));
116 }
117 }
Pau Espin Pedrol54b614a2024-04-17 18:58:36 +0200118}
119
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +0200120/* Local SIP UAs */
121private function f_init_sip_local() runs on test_CT {
122 var charstring id := "Asterisk_Tests_LOCAL_SIP_EMU";
123 f_init_sip(vc_SIP, id);
124}
125
126/* IMS Server connection */
127private function f_init_sip_ims() runs on test_CT {
128 var charstring id := "Asterisk_Tests_IMS_SIP_EMU";
129 f_init_sip(vc_IMS, id);
130}
131
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100132function f_init() runs on test_CT {
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +0200133 var charstring id;
134
Pau Espin Pedrol54b614a2024-04-17 18:58:36 +0200135 f_init_ami();
Pau Espin Pedrolac8a0542024-04-19 17:30:57 +0200136 f_init_sip_local();
137 f_init_sip_ims();
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100138 log("end of f_init");
139}
140
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +0200141function f_shutdown() runs on test_CT {
142 /* Tear down AMI Adapter to avoid it keep receiving data from Asterisk
143 * and sending it to us after we stopped, causing error (Broken Pipe): */
144 vc_AMI.stop;
145 vc_AMI.done;
146 log("end of ", testcasename());
147 setverdict(pass);
148}
149
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200150function f_start_handler(void_fn fn, SIPConnHdlrPars pars)
151runs on test_CT return SIPConnHdlr {
152 var SIPConnHdlr vc_conn;
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200153 var charstring id := testcasename() & "-ConnHdlr-" & pars.user;
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100154
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200155 vc_conn := SIPConnHdlr.create(id) alive;
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100156
157 connect(vc_conn:SIP, vc_SIP:CLIENT);
158 connect(vc_conn:SIP_PROC, vc_SIP:CLIENT_PROC);
159
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200160 connect(vc_conn:COORD, self:COORD);
161
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100162 vc_conn.start(f_handler_init(fn, id, pars));
163 return vc_conn;
164}
165
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200166function f_start_handler_IMS(ims_void_fn fn, IMS_ConnHdlrPars pars)
167runs on test_CT return IMS_ConnHdlr {
168 var IMS_ConnHdlr vc_conn;
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200169 var charstring id := testcasename() & "-IMS_ConnHdlr-" & pars.subscr.imsi;
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200170
171 vc_conn := IMS_ConnHdlr.create(id) alive;
172
173 connect(vc_conn:SIP, vc_IMS:CLIENT);
174 connect(vc_conn:SIP_PROC, vc_IMS:CLIENT_PROC);
175
176 connect(vc_conn:COORD, self:IMS_COORD);
177
178 vc_conn.start(f_ims_handler_init(fn, id, pars));
179 return vc_conn;
180}
181
Pau Espin Pedrol05eaa1a2024-04-02 12:56:26 +0200182/* Test SIP registration of local clients */
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200183private function f_TC_internal_registration(charstring id) runs on SIPConnHdlr {
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100184
185 f_SIP_register();
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100186 // f_SIP_deregister();
187 setverdict(pass);
188}
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100189testcase TC_internal_registration() runs on test_CT {
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200190 var SIPConnHdlrPars pars;
191 var SIPConnHdlr vc_conn;
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100192 f_init();
193 pars := f_init_ConnHdlrPars();
194 vc_conn := f_start_handler(refers(f_TC_internal_registration), pars);
195 vc_conn.done;
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +0200196 f_shutdown();
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100197}
198
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200199/* Successful SIP MO-MT Call between local clients: */
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200200private function f_TC_internal_call_mo(charstring id) runs on SIPConnHdlr {
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200201
202 f_SIP_register();
203 COORD.send(COORD_CMD_REGISTERED);
204
205 COORD.receive(COORD_CMD_START);
206 f_SIP_mo_call_setup();
207 COORD.send(COORD_CMD_CALL_ESTABLISHED);
208
209 COORD.receive(COORD_CMD_HANGUP);
210 f_SIP_do_call_hangup();
211
212 setverdict(pass);
213}
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200214private function f_TC_internal_call_mt(charstring id) runs on SIPConnHdlr {
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200215
216 f_create_sip_expect(valueof(ts_SipUrl_from_Addr_Union(g_pars.cp.called.addr)));
217
218 f_SIP_register();
219 COORD.send(COORD_CMD_REGISTERED);
220
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200221 if (g_pars.cp.mt.exp_cancel) {
222 as_SIP_mt_call_cancelled();
223 COORD.send(COORD_CMD_CALL_CANCELLED);
224 setverdict(pass);
225 return;
226 }
227
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200228 as_SIP_mt_call_accept();
229 COORD.send(COORD_CMD_CALL_ESTABLISHED);
230
231 /* Once MO hangs up, Asterisk updates us to point RTP to it: */
232 as_SIP_exp_call_update(g_pars.cp.sip_seq_nr + 1);
233 as_SIP_exp_call_hangup(g_pars.cp.sip_seq_nr + 1);
234
235 setverdict(pass);
236}
237testcase TC_internal_call_momt() runs on test_CT {
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200238 var SIPConnHdlrPars pars[2];
239 var SIPConnHdlr vc_conn[2];
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200240
241 f_init();
242
243 pars[0] := f_init_ConnHdlrPars(idx := 1);
244 pars[1] := f_init_ConnHdlrPars(idx := 2);
245
246 pars[0].cp.calling := pars[0].registrar_sip_record;
247 pars[0].cp.called := pars[1].registrar_sip_record;
248
249 pars[1].cp.calling := pars[0].registrar_sip_record;
250 pars[1].cp.called := pars[1].local_sip_record;
251
252 vc_conn[0] := f_start_handler(refers(f_TC_internal_call_mo), pars[0]);
253 vc_conn[1] := f_start_handler(refers(f_TC_internal_call_mt), pars[1]);
254
255 interleave {
256 [] COORD.receive(COORD_CMD_REGISTERED) from vc_conn[0];
257 [] COORD.receive(COORD_CMD_REGISTERED) from vc_conn[1];
258 }
259
260 COORD.send(COORD_CMD_START) to vc_conn[0];
261
262 interleave {
263 [] COORD.receive(COORD_CMD_CALL_ESTABLISHED) from vc_conn[0];
264 [] COORD.receive(COORD_CMD_CALL_ESTABLISHED) from vc_conn[1];
265 }
266
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200267 /* Call on-going */
268 f_sleep(1.0);
269
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200270 COORD.send(COORD_CMD_HANGUP) to vc_conn[0];
271
272
273 vc_conn[0].done;
274 vc_conn[1].done;
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +0200275 f_shutdown();
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200276}
277
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200278/* One of the users calls (INVITE) shared extension, which makes all other user
279 * equipments ring (INVITE). The first one to pick up the call (OK 200) gets the
280 * call established (ACK), others get a CANCEL event. */
281private function TC_internal_call_all_Nregistered(integer num_conns := 2) runs on test_CT {
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200282 var SIPConnHdlrList vc_conn_list := {};
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200283 const integer vc_conn_mo_idx := 0; /* Index of MO leg in vc_conn_list */
284 const integer vc_conn_mt_idx := 1; /* Index of MT leg in vc_conn_list, peer picking up first the call */
285 var SipAddr broadcast_sip_record;
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200286 var SIPConnHdlrPars pars_mo;
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200287
288 f_init();
289
290 broadcast_sip_record := valueof(ts_SipAddr(ts_HostPort(mp_local_sip_host),
291 ts_UserInfo(broadcast_sip_extension)));
292
293 for (var integer i := 0; i < num_conns; i := i + 1) {
Pau Espin Pedrolcaf028d2024-04-18 13:47:07 +0200294 var SIPConnHdlrPars pars;
295 var SIPConnHdlr vc_conn;
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200296 pars := f_init_ConnHdlrPars(idx := i + 1);
297 if (i == vc_conn_mo_idx) { /* MO */
298 pars.cp.calling := pars.registrar_sip_record;
299 pars.cp.called := broadcast_sip_record;
300 vc_conn := f_start_handler(refers(f_TC_internal_call_mo), pars);
301 pars_mo := pars;
302 } else { /* MT */
303 pars.cp.calling := pars_mo.registrar_sip_record;
304 pars.cp.called := pars.local_sip_record;
305 pars.cp.mt.wait_coord_cmd_pickup := true;
306 if (i != vc_conn_mt_idx) {
307 /* Only first MT picking up (OK 200 INVITE) will be ACKed, others CANCELed: */
308 pars.cp.mt.exp_cancel := true;
309 }
310 vc_conn := f_start_handler(refers(f_TC_internal_call_mt), pars);
311 }
312 vc_conn_list := vc_conn_list & { vc_conn };
313 }
314
315 /* Wait all users are registered: */
316 for (var integer i := 0; i < num_conns; i := i + 1) {
317 /* Note: "from vc_conn_list[i]" can't be used since they may arrive from components in any order: */
318 COORD.receive(COORD_CMD_REGISTERED);
319 }
320
321 /* Ask MO user to start the call: */
322 COORD.send(COORD_CMD_START) to vc_conn_list[vc_conn_mo_idx];
323
324 /* Make sure the desired MT is the one picking up first the call: */
325 COORD.send(COORD_CMD_PICKUP) to vc_conn_list[vc_conn_mt_idx];
326 interleave {
327 [] COORD.receive(COORD_CMD_CALL_ESTABLISHED) from vc_conn_list[vc_conn_mo_idx];
328 [] COORD.receive(COORD_CMD_CALL_ESTABLISHED) from vc_conn_list[vc_conn_mt_idx];
329 }
330
331 /* Pick up from other phone calls and expect CANCEL: */
332 for (var integer i := 0; i < num_conns; i := i + 1) {
333 if (i != vc_conn_mo_idx and i != vc_conn_mt_idx) {
334 COORD.send(COORD_CMD_PICKUP) to vc_conn_list[i];
335 COORD.receive(COORD_CMD_CALL_CANCELLED) from vc_conn_list[i];
336 }
337 }
338
339 /* Call on-going */
340 f_sleep(1.0);
341
342 COORD.send(COORD_CMD_HANGUP) to vc_conn_list[vc_conn_mo_idx];
343
344 for (var integer i := 0; i < num_conns; i := i + 1) {
345 vc_conn_list[i].done;
346 }
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +0200347 f_shutdown();
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200348}
349testcase TC_internal_call_all_2registered() runs on test_CT {
350 TC_internal_call_all_Nregistered(2);
351}
352testcase TC_internal_call_all_3registered() runs on test_CT {
353 TC_internal_call_all_Nregistered(3);
354}
355testcase TC_internal_call_all_4registered() runs on test_CT {
356 TC_internal_call_all_Nregistered(4);
357}
358
Pau Espin Pedrol05eaa1a2024-04-02 12:56:26 +0200359testcase TC_selftest() runs on test_CT {
Pau Espin Pedrol01f1df82024-05-08 16:55:55 +0200360 f_ami_selftest();
Pau Espin Pedrol05eaa1a2024-04-02 12:56:26 +0200361 f_sip_digest_selftest();
362 setverdict(pass);
363}
364
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200365private function f_AMI_IMS_register(IMS_ConnHdlrPars pars) runs on test_CT
366{
367 /* Give some time for IMS_ConnHdlr to register SIP expect. This could be done through IMS_COORD. */
368 f_sleep(1.0);
369 /* Clear events: */
370 AMI_CLIENT.clear;
371
372 /* Announce network information, this should usually happen when UE
373 * becomes attached to network and before IMS APN is set up: */
374 f_ami_action_PJSIPAccessNetworkInfo(AMI_CLIENT, mp_volte_ims_outbound_registration,
375 f_ami_gen_PJSIPAccessNetworkInfo_Info_EUTRAN(pars.subscr.uli_str));
376
377 /* Trigger registration: */
378 f_ami_action_PJSIPRegister(AMI_CLIENT, mp_volte_ims_outbound_registration);
379
Pau Espin Pedrol80b981a2024-06-04 18:37:22 +0200380 var charstring rand_str := oct2str(pars.subscr.auth.rand);
381 var charstring autn_str := oct2str(pars.subscr.auth.autn);
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200382 AMI_CLIENT.receive(tr_AMI_Event_AuthRequest(mp_volte_ims_outbound_registration,
383 rand := pattern @nocase rand_str,
384 autn := pattern @nocase autn_str));
385
386 f_ami_action_AuthResponse_RES(AMI_CLIENT,
387 mp_volte_ims_outbound_registration,
Pau Espin Pedrol80b981a2024-06-04 18:37:22 +0200388 f_str_tolower(oct2str(pars.subscr.auth.res)),
389 f_str_tolower(oct2str(pars.subscr.auth.ck)),
390 f_str_tolower(oct2str(pars.subscr.auth.ik)));
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200391
392 AMI_CLIENT.receive(tr_AMI_Event_Registry(f_sip_SipAddr_to_str(pars.subscr.local_sip_record),
Pau Espin Pedrolf46132e2024-06-04 17:11:59 +0200393 "sip:" & mp_ims_domain,
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200394 "Registered"));
Pau Espin Pedrol586eec52024-06-04 19:07:33 +0200395}
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200396
Pau Espin Pedrol586eec52024-06-04 19:07:33 +0200397private function f_AMI_IMS_unregister(IMS_ConnHdlrPars pars) runs on test_CT
398{
399 f_ami_action_PJSIPUnregister(AMI_CLIENT, mp_volte_ims_outbound_registration);
400 AMI_CLIENT.receive(tr_AMI_Event_Registry(f_sip_SipAddr_to_str(pars.subscr.local_sip_record),
401 "sip:" & mp_ims_domain,
402 "Unregistered"));
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200403}
404
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200405/* Test SIP registration of local clients */
406private function f_TC_ims_registration(charstring id) runs on IMS_ConnHdlr {
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200407 f_create_sip_expect(valueof(ts_SipUrl_from_Addr_Union(g_pars.subscr.registrar_sip_record.addr)));
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200408 as_IMS_register();
Pau Espin Pedrol586eec52024-06-04 19:07:33 +0200409 as_IMS_unregister();
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200410 setverdict(pass);
411}
412testcase TC_ims_registration() runs on test_CT {
413 var IMS_ConnHdlrPars pars;
414 var IMS_ConnHdlr vc_conn;
415 f_init();
416 pars := f_init_IMS_ConnHdlrPars();
417 vc_conn := f_start_handler_IMS(refers(f_TC_ims_registration), pars);
418
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200419 f_AMI_IMS_register(pars);
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200420
Pau Espin Pedrol586eec52024-06-04 19:07:33 +0200421 /* Stay registered for one second */
422 f_sleep(1.0);
423
424 /* Trigger unregistration: */
425 f_AMI_IMS_unregister(pars);
426
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200427 vc_conn.done;
428 f_shutdown();
429}
430
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200431/* Test SIP registration of local clients */
432private function f_TC_ims_call_mo(charstring id) runs on IMS_ConnHdlr {
433 f_create_sip_expect(valueof(ts_SipUrl_from_Addr_Union(g_pars.subscr.registrar_sip_record.addr)));
434 if (ispresent(g_pars.subscr.cp.called)) {
435 f_create_sip_expect(valueof(ts_SipUrl_from_Addr_Union(g_pars.subscr.cp.called.addr)));
436 }
437 as_IMS_register();
438 setverdict(pass);
439 as_IMS_mo_call_accept();
440 setverdict(pass);
441 COORD.send(COORD_CMD_CALL_ESTABLISHED);
442 as_IMS_exp_call_hangup(g_pars.subscr.cp.sip_seq_nr + 1);
443 setverdict(pass);
Pau Espin Pedrol2b0c6642024-06-05 14:04:21 +0200444 as_IMS_unregister();
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200445}
446testcase TC_ims_call_mo() runs on test_CT {
447 var SIPConnHdlrPars sip_pars;
448 var IMS_ConnHdlrPars ims_pars;
449 var SIPConnHdlr vc_conn_sip;
450 var IMS_ConnHdlr vc_conn_ims;
451 const charstring c_ext_msisdn := "90829";
452
453 f_init();
454
455 sip_pars := f_init_ConnHdlrPars(idx := 1);
456 ims_pars := f_init_IMS_ConnHdlrPars();
457
458 sip_pars.cp.calling := sip_pars.registrar_sip_record;
459 sip_pars.cp.called := valueof(ts_SipAddr(ts_HostPort(sip_pars.remote_sip_host),
460 ts_UserInfo(c_ext_msisdn)));
Pau Espin Pedrolf46132e2024-06-04 17:11:59 +0200461 ims_pars.subscr.cp.calling := valueof(ts_SipAddr(ts_HostPort(ims_pars.realm),
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200462 ts_UserInfo(ims_pars.subscr.msisdn)));
Pau Espin Pedrolf46132e2024-06-04 17:11:59 +0200463 ims_pars.subscr.cp.called := valueof(ts_SipAddr(ts_HostPort(ims_pars.realm),
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200464 ts_UserInfo(c_ext_msisdn)));
465
466 vc_conn_ims := f_start_handler_IMS(refers(f_TC_ims_call_mo), ims_pars);
467 vc_conn_sip := f_start_handler(refers(f_TC_internal_call_mo), sip_pars);
468
469 COORD.receive(COORD_CMD_REGISTERED) from vc_conn_sip;
470
471 f_AMI_IMS_register(ims_pars);
472
473 COORD.send(COORD_CMD_START) to vc_conn_sip;
474 COORD.receive(COORD_CMD_CALL_ESTABLISHED) from vc_conn_sip;
475 IMS_COORD.receive(COORD_CMD_CALL_ESTABLISHED) from vc_conn_ims;
476
Pau Espin Pedrol586eec52024-06-04 19:07:33 +0200477 /* TODO: "Action: DedicatedBearerStatus" */
478
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200479 /* Call on-going */
480 f_sleep(1.0);
481
482 COORD.send(COORD_CMD_HANGUP) to vc_conn_sip;
483
Pau Espin Pedrol2b0c6642024-06-05 14:04:21 +0200484 /* Trigger unregistration: */
485 f_sleep(1.0);
486 AMI_CLIENT.clear;
487 f_AMI_IMS_unregister(ims_pars);
488
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200489 vc_conn_sip.done;
490 vc_conn_ims.done;
491 f_shutdown();
492}
493
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100494control {
495 execute( TC_internal_registration() );
Pau Espin Pedrol7011bf42024-04-08 17:56:58 +0200496 execute( TC_internal_call_momt() );
Pau Espin Pedrol32167d82024-04-10 13:14:51 +0200497 execute( TC_internal_call_all_2registered() );
498 execute( TC_internal_call_all_3registered() );
499 execute( TC_internal_call_all_4registered() );
Pau Espin Pedrola2812ec2024-05-10 20:30:44 +0200500 execute( TC_ims_registration() );
Pau Espin Pedrol901cede2024-05-30 13:03:42 +0200501 execute( TC_ims_call_mo() );
Pau Espin Pedrol37ee0ed2024-03-28 21:17:12 +0100502}
503
504}