blob: 7bee8990b2d528ad2a86e24dc45097f8d2a70a5a [file] [log] [blame]
Harald Weltefaa42922019-03-04 18:31:11 +01001module RemsimClient_Tests {
2
3/* Integration Tests for osmo-remsim-client
4 * (C) 2019 by Harald Welte <laforge@gnumonks.org>
5 * All rights reserved.
6 *
7 * Released under the terms of GNU General Public License, Version 2 or
8 * (at your option) any later version.
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
12 * This test suite tests osmo-remsim-client by attaching to the external interfaces.
13 */
14
15import from Osmocom_Types all;
16import from IPA_Emulation all;
17
18import from RSPRO all;
19import from RSPRO_Types all;
20import from RSPRO_Server all;
21import from REMSIM_Tests all;
22
23type component client_test_CT extends rspro_server_CT {
24 var ComponentIdentity g_srv_comp_id, g_bankd_comp_id;
25};
26
27private function f_init() runs on client_test_CT {
28 g_srv_comp_id := valueof(ts_CompId(remsimServer, "ttcn-server"));
29 g_bankd_comp_id := valueof(ts_CompId(remsimBankd, "ttcn-bankd"));
30
31 f_rspro_srv_init(0, mp_server_ip, mp_server_port, g_srv_comp_id);
32 f_rspro_srv_init(1, mp_bankd_ip, mp_bankd_port, g_bankd_comp_id, exp_connect := false);
33}
34
35
36/* ConnectClientReq from client to remsim-server */
37testcase TC_srv_connectClient() runs on client_test_CT {
38 f_init();
Harald Weltec7b496c2020-02-16 16:31:30 +010039 /* expect inbound connectClientReq */
Harald Weltefaa42922019-03-04 18:31:11 +010040 as_connectClientReq();
41 setverdict(pass);
42 f_sleep(1.0);
43}
44
45/* ConnectClientReq from client to remsim-server */
46testcase TC_srv_connectClient_reject() runs on client_test_CT {
47 f_init();
Harald Weltec7b496c2020-02-16 16:31:30 +010048 /* expect inbound connectClientReq */
Harald Weltefaa42922019-03-04 18:31:11 +010049 as_connectClientReq(res := illegalClientId);
50 /* expect disconnect by client */
51 RSPRO_SRV[0].receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN));
52 setverdict(pass);
53 f_sleep(1.0);
54}
55
56/* ConnectClientReq from client to remsim-server */
57testcase TC_srv_connectClient_configClientBank() runs on client_test_CT {
58 var BankSlot bslot := { 1, 0 };
59 f_init();
Harald Weltec7b496c2020-02-16 16:31:30 +010060 /* expect inbound connectClientReq */
Harald Weltefaa42922019-03-04 18:31:11 +010061 as_connectClientReq();
Harald Weltec7b496c2020-02-16 16:31:30 +010062 /* configure client to connect to [simulated] bankd */
Harald Weltefaa42922019-03-04 18:31:11 +010063 f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4(mp_bankd_ip), mp_bankd_port));
Harald Weltec7b496c2020-02-16 16:31:30 +010064 /* expect inbound connect on simulated bankd */
Harald Weltefaa42922019-03-04 18:31:11 +010065 f_rspro_srv_exp_connect(1);
Harald Weltec7b496c2020-02-16 16:31:30 +010066 /* expect inbound connectClientReq on simulated bankd */
Harald Weltefaa42922019-03-04 18:31:11 +010067 as_connectClientReq(i := 1);
68 setverdict(pass);
69 f_sleep(1.0);
70}
71
72/* Test if client re-connects to server after connection is lost */
73testcase TC_srv_reconnect() runs on client_test_CT {
74 var BankSlot bslot := { 1, 0 };
75 f_init();
Harald Weltec7b496c2020-02-16 16:31:30 +010076 /* expect inbound connectClientReq */
Harald Weltefaa42922019-03-04 18:31:11 +010077 as_connectClientReq();
78
79 /* disconnect the client from server and expect re-establish + re-connect */
80 f_rspro_srv_fini(0);
81 f_rspro_srv_init(0, mp_server_ip, mp_server_port, g_srv_comp_id, exp_connect := true);
Harald Weltec7b496c2020-02-16 16:31:30 +010082 /* expect inbound connectClientReq */
Harald Weltefaa42922019-03-04 18:31:11 +010083 as_connectClientReq(i := 0);
84
85 setverdict(pass);
86 f_sleep(1.0);
87}
88
89/* Test if client re-connects to bank after connection is lost */
90testcase TC_bank_reconnect() runs on client_test_CT {
91 var BankSlot bslot := { 1, 0 };
92 f_init();
Harald Weltec7b496c2020-02-16 16:31:30 +010093 /* expect inbound connectClientReq */
Harald Weltefaa42922019-03-04 18:31:11 +010094 as_connectClientReq();
Harald Weltec7b496c2020-02-16 16:31:30 +010095 /* configure client to connect to [simulated] bankd */
Harald Weltefaa42922019-03-04 18:31:11 +010096 f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4(mp_bankd_ip), mp_bankd_port));
Harald Weltec7b496c2020-02-16 16:31:30 +010097 /* expect inbound connect on simulated bankd */
Harald Weltefaa42922019-03-04 18:31:11 +010098 f_rspro_srv_exp_connect(1);
Harald Weltec7b496c2020-02-16 16:31:30 +010099 /* expect inbound connectClientReq on simulated bankd */
Harald Weltefaa42922019-03-04 18:31:11 +0100100 as_connectClientReq(i := 1);
101
102 /* disconnect the client from bankd and expect re-establish + re-connect */
103 f_rspro_srv_fini(1);
104 f_rspro_srv_init(1, mp_bankd_ip, mp_bankd_port, g_bankd_comp_id, exp_connect := true);
Harald Weltec7b496c2020-02-16 16:31:30 +0100105 /* expect inbound connectClientReq on simulated bankd */
Harald Weltefaa42922019-03-04 18:31:11 +0100106 as_connectClientReq(i := 1);
107
108 setverdict(pass);
109 f_sleep(1.0);
110}
111
112/* TODO:
113 * send a configClientBankIpReq and change the bank of an active client
114 * send a configClientBankSlotReq and chagne the bank slot of an active client
115 * test keepalive mechanism: do we get IPA PING?
116 * test keepalive mechanism: do we see disconnect+reconnect if we don't respond to IPA PING?
117 * test actual APDU transfers
118 * test messages in invalid state, e.g. APDUs before we're connected to a bank
119 * test messages on server connection which are only permitted on bankd connection
120 */
121
122control {
123 execute( TC_srv_connectClient() );
124 execute( TC_srv_connectClient_reject() );
125 execute( TC_srv_connectClient_configClientBank() );
126 execute( TC_srv_reconnect() );
127 execute( TC_bank_reconnect() );
128}
129
130
131}