Harald Welte | faa4292 | 2019-03-04 18:31:11 +0100 | [diff] [blame] | 1 | module 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 | |
| 15 | import from Osmocom_Types all; |
| 16 | import from IPA_Emulation all; |
| 17 | |
| 18 | import from RSPRO all; |
| 19 | import from RSPRO_Types all; |
| 20 | import from RSPRO_Server all; |
| 21 | import from REMSIM_Tests all; |
| 22 | |
| 23 | type component client_test_CT extends rspro_server_CT { |
| 24 | var ComponentIdentity g_srv_comp_id, g_bankd_comp_id; |
| 25 | }; |
| 26 | |
| 27 | private 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 */ |
| 37 | testcase TC_srv_connectClient() runs on client_test_CT { |
| 38 | f_init(); |
| 39 | as_connectClientReq(); |
| 40 | setverdict(pass); |
| 41 | f_sleep(1.0); |
| 42 | } |
| 43 | |
| 44 | /* ConnectClientReq from client to remsim-server */ |
| 45 | testcase TC_srv_connectClient_reject() runs on client_test_CT { |
| 46 | f_init(); |
| 47 | as_connectClientReq(res := illegalClientId); |
| 48 | /* expect disconnect by client */ |
| 49 | RSPRO_SRV[0].receive(t_ASP_IPA_EVT_UD(ASP_IPA_EVENT_DOWN)); |
| 50 | setverdict(pass); |
| 51 | f_sleep(1.0); |
| 52 | } |
| 53 | |
| 54 | /* ConnectClientReq from client to remsim-server */ |
| 55 | testcase TC_srv_connectClient_configClientBank() runs on client_test_CT { |
| 56 | var BankSlot bslot := { 1, 0 }; |
| 57 | f_init(); |
| 58 | as_connectClientReq(); |
| 59 | f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4(mp_bankd_ip), mp_bankd_port)); |
| 60 | f_rspro_srv_exp_connect(1); |
| 61 | as_connectClientReq(i := 1); |
| 62 | setverdict(pass); |
| 63 | f_sleep(1.0); |
| 64 | } |
| 65 | |
| 66 | /* Test if client re-connects to server after connection is lost */ |
| 67 | testcase TC_srv_reconnect() runs on client_test_CT { |
| 68 | var BankSlot bslot := { 1, 0 }; |
| 69 | f_init(); |
| 70 | as_connectClientReq(); |
| 71 | |
| 72 | /* disconnect the client from server and expect re-establish + re-connect */ |
| 73 | f_rspro_srv_fini(0); |
| 74 | f_rspro_srv_init(0, mp_server_ip, mp_server_port, g_srv_comp_id, exp_connect := true); |
| 75 | as_connectClientReq(i := 0); |
| 76 | |
| 77 | setverdict(pass); |
| 78 | f_sleep(1.0); |
| 79 | } |
| 80 | |
| 81 | /* Test if client re-connects to bank after connection is lost */ |
| 82 | testcase TC_bank_reconnect() runs on client_test_CT { |
| 83 | var BankSlot bslot := { 1, 0 }; |
| 84 | f_init(); |
| 85 | as_connectClientReq(); |
| 86 | f_rspro_config_client_bank(bslot, ts_IpPort(ts_IPv4(mp_bankd_ip), mp_bankd_port)); |
| 87 | f_rspro_srv_exp_connect(1); |
| 88 | as_connectClientReq(i := 1); |
| 89 | |
| 90 | /* disconnect the client from bankd and expect re-establish + re-connect */ |
| 91 | f_rspro_srv_fini(1); |
| 92 | f_rspro_srv_init(1, mp_bankd_ip, mp_bankd_port, g_bankd_comp_id, exp_connect := true); |
| 93 | as_connectClientReq(i := 1); |
| 94 | |
| 95 | setverdict(pass); |
| 96 | f_sleep(1.0); |
| 97 | } |
| 98 | |
| 99 | /* TODO: |
| 100 | * send a configClientBankIpReq and change the bank of an active client |
| 101 | * send a configClientBankSlotReq and chagne the bank slot of an active client |
| 102 | * test keepalive mechanism: do we get IPA PING? |
| 103 | * test keepalive mechanism: do we see disconnect+reconnect if we don't respond to IPA PING? |
| 104 | * test actual APDU transfers |
| 105 | * test messages in invalid state, e.g. APDUs before we're connected to a bank |
| 106 | * test messages on server connection which are only permitted on bankd connection |
| 107 | */ |
| 108 | |
| 109 | control { |
| 110 | execute( TC_srv_connectClient() ); |
| 111 | execute( TC_srv_connectClient_reject() ); |
| 112 | execute( TC_srv_connectClient_configClientBank() ); |
| 113 | execute( TC_srv_reconnect() ); |
| 114 | execute( TC_bank_reconnect() ); |
| 115 | } |
| 116 | |
| 117 | |
| 118 | } |