blob: d9501524f5afdccdd0e5e909d95093108a3ced5b [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
Harald Welte776b0e52020-02-16 16:31:47 +0100112/* Test if client disconnects from bankd after slotmap delete on server */
113testcase TC_bank_disconnect() runs on client_test_CT {
114 var BankSlot bslot := { 1, 0 };
115 f_init();
116 /* expect inbound connectClientReq */
117 as_connectClientReq();
118 /* configure client to connect to [simulated] bankd */
119 f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4(mp_bankd_ip), mp_bankd_port));
120 /* expect inbound connect on simulated bankd */
121 f_rspro_srv_exp_connect(1);
122 /* expect inbound connectClientReq on simulated bankd */
123 as_connectClientReq(i := 1);
124
125 f_sleep(1.0);
126
127 /* configure client to disconnect from [simulated] bankd */
128 f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4("0.0.0.0"), 0));
129
130 /* expect disconnect of client on simulated bankd side */
131 RSPRO_SRV[1].receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN));
132 setverdict(pass);
133}
134
135/* Test if client connects to bankd after disconnects from bankd after slotmap delete on server */
136testcase TC_bank_disconnect_reconnect() runs on client_test_CT {
137 var BankSlot bslot := { 1, 0 };
138 f_init();
139 /* expect inbound connectClientReq */
140 as_connectClientReq();
141 /* configure client to connect to [simulated] bankd */
142 f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4(mp_bankd_ip), mp_bankd_port));
143 /* expect inbound connect on simulated bankd */
144 f_rspro_srv_exp_connect(1);
145 /* expect inbound connectClientReq on simulated bankd */
146 as_connectClientReq(i := 1);
147
148 f_sleep(1.0);
149
150 /* configure client to disconnect from [simulated] bankd */
151 f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4("0.0.0.0"), 0));
152
153 /* expect disconnect of client on simulated bankd side */
154 RSPRO_SRV[1].receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN));
155
156 /* re-start the IPA emulation (which terminated itself on the TCP disconnect */
157 f_rspro_srv_init(1, mp_bankd_ip, mp_bankd_port, g_bankd_comp_id, exp_connect := false);
158
159 /* configure client to connect to [simulated] bankd */
160 f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4(mp_bankd_ip), mp_bankd_port));
161
162 /* expect inbound connect on simulated bankd */
163 f_rspro_srv_exp_connect(1);
164
165 /* expect inbound connect on simulated bankd */
166 as_connectClientReq(i := 1);
167
168 setverdict(pass);
169}
170
171
Harald Weltefaa42922019-03-04 18:31:11 +0100172/* TODO:
173 * send a configClientBankIpReq and change the bank of an active client
174 * send a configClientBankSlotReq and chagne the bank slot of an active client
175 * test keepalive mechanism: do we get IPA PING?
176 * test keepalive mechanism: do we see disconnect+reconnect if we don't respond to IPA PING?
177 * test actual APDU transfers
178 * test messages in invalid state, e.g. APDUs before we're connected to a bank
179 * test messages on server connection which are only permitted on bankd connection
180 */
181
182control {
183 execute( TC_srv_connectClient() );
184 execute( TC_srv_connectClient_reject() );
185 execute( TC_srv_connectClient_configClientBank() );
186 execute( TC_srv_reconnect() );
187 execute( TC_bank_reconnect() );
Harald Welte776b0e52020-02-16 16:31:47 +0100188 execute( TC_bank_disconnect() );
189 execute( TC_bank_disconnect_reconnect() );
Harald Weltefaa42922019-03-04 18:31:11 +0100190}
191
192
193}