blob: 1134d8971b73932aad6c6af0c2b59efcefb4c344 [file] [log] [blame]
Neels Hofmeyr6a29d322017-01-25 15:04:16 +01001/* Osmocom MSC+VLR end-to-end tests */
2
3/* (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
4 *
5 * All Rights Reserved
6 *
7 * Author: Neels Hofmeyr <nhofmeyr@sysmocom.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 *
22 */
23
24#include "msc_vlr_tests.h"
Harald Welte0df904d2018-12-03 11:00:04 +010025#include "stubs.h"
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010026
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010027static void test_hlr_rej_auth_info_unknown_imsi()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010028{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010029 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010030
31 net->authentication_required = true;
32
33 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
34 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010035 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010036 ms_sends_msg("050802008168000130089910070000006402");
37 OSMO_ASSERT(gsup_tx_confirmed);
38 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
39
40 btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI");
41 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +020042 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010043 gsup_rx("09" "010809710000004026f0" "020102" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010044 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
45 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +020046 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010047
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010048 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010049 EXPECT_CONN_COUNT(0);
50 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010051 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010052}
53
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010054static void test_hlr_rej_auth_info_net_fail()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010055{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010056 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010057
58 net->authentication_required = true;
59
60 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
61 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010062 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010063 ms_sends_msg("050802008168000130089910070000006402");
64 OSMO_ASSERT(gsup_tx_confirmed);
65 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
66
67 btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail");
68 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +020069 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010070 gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010071 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
72 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +020073 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010074
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010075 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010076 EXPECT_CONN_COUNT(0);
77 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010078 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010079}
80
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010081static void test_hlr_rej_auth_info_net_fail_no_reuse_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010082{
83 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010084 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010085
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010086 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010087
88 net->authentication_required = true;
89 net->vlr->cfg.auth_reuse_old_sets_on_error = false;
Neels Hofmeyr33f53412017-10-29 02:11:18 +010090 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010091
92 BTW("Submit a used auth tuple in the VLR");
93 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
94 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +010095 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010096 ms_sends_msg("050802008168000130089910070000006402");
97 OSMO_ASSERT(gsup_tx_confirmed);
98 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
99
100 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
101 auth_request_sent = false;
102 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
103 auth_request_expect_autn = NULL;
104 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
105 gsup_rx("0a"
106 /* imsi */
107 "0108" "09710000004026f0"
108 /* auth vectors... */
109 /* TL TL rand */
110 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
111 /* TL sres TL kc */
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100112 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" HLR_TO_VLR,
113 NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100114 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
115 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
116
117 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100118 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100119 ms_sends_msg("05542d8b2c3e");
120 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
121
122 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100123 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
124 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100125 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
126
127 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200128 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100129 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200130 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100131
132 btw("LU was successful, and the conn has already been closed");
133 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100134 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100135 EXPECT_CONN_COUNT(0);
136
137
138 BTW("Now one auth tuple is available, but used.");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100139 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100140 OSMO_ASSERT(vsub);
141 OSMO_ASSERT(vsub->last_tuple);
142 VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d");
143 /* no need to look at all auth tuples, the ongoing test would take an
144 * unexpected course if there were more. */
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100145 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100146
147 BTW("Another LU wants to get new tuples; HLR sends Network Failure, we reject.");
148
149 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
150 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100151 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100152 ms_sends_msg("050802008168000130089910070000006402");
153 OSMO_ASSERT(gsup_tx_confirmed);
154 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
155
156 btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail");
157 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +0200158 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100159 gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100160 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
161 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200162 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100163
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100164 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100165 EXPECT_CONN_COUNT(0);
166 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100167 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100168}
169
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100170static void test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100171{
172 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100173 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100174
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100175 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100176
177 net->authentication_required = true;
178 net->vlr->cfg.auth_reuse_old_sets_on_error = true;
Neels Hofmeyr33f53412017-10-29 02:11:18 +0100179 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100180
181 BTW("Submit a used auth tuple in the VLR");
182 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
183 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100184 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100185 ms_sends_msg("050802008168000130089910070000006402");
186 OSMO_ASSERT(gsup_tx_confirmed);
187 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
188
189 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
190 auth_request_sent = false;
191 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
192 auth_request_expect_autn = NULL;
193 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
194 gsup_rx("0a"
195 /* imsi */
196 "0108" "09710000004026f0"
197 /* auth vectors... */
198 /* TL TL rand */
199 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
200 /* TL sres TL kc */
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100201 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" HLR_TO_VLR,
202 NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100203 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
204 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
205
206 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100207 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100208 ms_sends_msg("05542d8b2c3e");
209 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
210
211 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100212 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
213 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100214 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
215
216 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200217 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100218 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200219 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100220
221 btw("LU was successful, and the conn has already been closed");
222 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100223 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100224 EXPECT_CONN_COUNT(0);
225
226
227 BTW("Now one auth tuple is available, but used.");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100228 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100229 OSMO_ASSERT(vsub);
230 OSMO_ASSERT(vsub->last_tuple);
231 VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d");
232 /* no need to look at all auth tuples, the ongoing test would take an
233 * unexpected course if there were more. */
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100234 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100235
236 BTW("Another LU wants to get new tuples; HLR sends IMSI Unknown. Even though we would re-use an old tuple, reject the unknown IMSI.");
237 VERBOSE_ASSERT(net->vlr->cfg.auth_reuse_old_sets_on_error, == true, "%d");
238
239 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
240 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100241 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100242 ms_sends_msg("050802008168000130089910070000006402");
243 OSMO_ASSERT(gsup_tx_confirmed);
244 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
245
246 btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI");
247 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +0200248 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100249 gsup_rx("09" "010809710000004026f0" "020102" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100250 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
251 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200252 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100253
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100254 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100255 EXPECT_CONN_COUNT(0);
256 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100257 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100258}
259
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100260static void test_hlr_acc_but_no_auth_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100261{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100262 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100263
264 net->authentication_required = true;
265 net->vlr->cfg.auth_reuse_old_sets_on_error = true;
Neels Hofmeyr33f53412017-10-29 02:11:18 +0100266 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100267
268 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
269 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100270 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100271 ms_sends_msg("050802008168000130089910070000006402");
272 OSMO_ASSERT(gsup_tx_confirmed);
273 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
274
275 btw("from HLR, rx _SEND_AUTH_INFO_RESULT but it lacks auth tuples");
276 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +0200277 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100278 gsup_rx("0a"
279 /* imsi */
280 "0108" "09710000004026f0"
281 /* NO auth vectors */
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100282 HLR_TO_VLR,
283 NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100284 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
285 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200286 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100287
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100288 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100289 EXPECT_CONN_COUNT(0);
290 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100291 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100292}
293
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100294static void test_hlr_rej_auth_info_net_fail_reuse_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100295{
296 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100297 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100298
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100299 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100300
301 net->authentication_required = true;
302 net->vlr->cfg.auth_reuse_old_sets_on_error = true;
Neels Hofmeyr33f53412017-10-29 02:11:18 +0100303 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100304
305 BTW("Submit a used auth tuple in the VLR");
306 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
307 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100308 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100309 ms_sends_msg("050802008168000130089910070000006402");
310 OSMO_ASSERT(gsup_tx_confirmed);
311 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
312
313 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
314 auth_request_sent = false;
315 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
316 auth_request_expect_autn = NULL;
317 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
318 gsup_rx("0a"
319 /* imsi */
320 "0108" "09710000004026f0"
321 /* auth vectors... */
322 /* TL TL rand */
323 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
324 /* TL sres TL kc */
325 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100326 HLR_TO_VLR,
327 NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100328 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
329 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
330
331 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100332 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100333 ms_sends_msg("05542d8b2c3e");
334 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
335
336 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100337 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
338 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100339 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
340
341 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200342 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100343 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200344 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100345
346 btw("LU was successful, and the conn has already been closed");
347 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100348 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100349 EXPECT_CONN_COUNT(0);
350
351
352 BTW("Now one auth tuple is available, but used.");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100353 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100354 OSMO_ASSERT(vsub);
355 OSMO_ASSERT(vsub->last_tuple);
356 VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d");
357 /* no need to look at all auth tuples, the ongoing test would take an
358 * unexpected course if there were more. */
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100359 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100360
361 BTW("Another LU wants to get new tuples; even though HLR sends Network Failure, we are reusing the old tuples.");
362
363 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
364 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100365 gsup_expect_tx("08010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100366 ms_sends_msg("050802008168000130089910070000006402");
367 OSMO_ASSERT(gsup_tx_confirmed);
368 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
369
370 btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail");
371 auth_request_sent = false;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100372 gsup_rx("09" "010809710000004026f0" "020111" HLR_TO_VLR, NULL);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100373 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
374 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
375
376 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100377 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100378 ms_sends_msg("05542d8b2c3e");
379 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
380
381 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100382 gsup_rx("10010809710000004026f00804036470f1" HLR_TO_VLR,
383 "12010809710000004026f0" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100384 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
385
386 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200387 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100388 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200389 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100390
391 btw("LU was successful, and the conn has already been closed");
392 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100393 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100394 EXPECT_CONN_COUNT(0);
395
396 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100397 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100398}
399
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100400static void test_hlr_rej_lu()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100401{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100402 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100403
404 btw("Location Update request causes a GSUP LU request to HLR");
405 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100406 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100407 ms_sends_msg("050802008168000130089910070000006402");
408 OSMO_ASSERT(gsup_tx_confirmed);
409 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
410
411 btw("HLR sends UPDATE_LOCATION_ERROR");
Philipp Maierfbf66102017-04-09 12:32:51 +0200412 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100413 gsup_rx("05" "010809710000004026f0" "020102" HLR_TO_VLR,
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100414 NULL);
415 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200416 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100417 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100418 EXPECT_CONN_COUNT(0);
419
420 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100421 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100422}
423
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100424static void test_hlr_no_insert_data()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100425{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100426 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100427
428 btw("Location Update request causes a GSUP LU request to HLR");
429 lu_result_sent = RES_NONE;
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100430 gsup_expect_tx("04010809710000004026f0280102" VLR_TO_HLR);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100431 ms_sends_msg("050802008168000130089910070000006402");
432 OSMO_ASSERT(gsup_tx_confirmed);
433 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
434
435 btw("HLR sends only _UPDATE_LOCATION_RESULT, no INSERT DATA");
Philipp Maierfbf66102017-04-09 12:32:51 +0200436 expect_bssap_clear();
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100437 gsup_rx("06010809710000004026f0" HLR_TO_VLR, NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200438 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100439
440 /* TODO should we wait for OSMO_GSUP_MSGT_INSERT_DATA_REQUEST? */
441
442 btw("LU was successful, and the conn has already been closed");
443 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
444
Neels Hofmeyrc4628a32018-12-07 14:47:34 +0100445 ran_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100446 EXPECT_CONN_COUNT(0);
447 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100448 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100449}
450
451msc_vlr_test_func_t msc_vlr_tests[] = {
452 test_hlr_rej_auth_info_unknown_imsi,
453 test_hlr_rej_auth_info_net_fail,
454 test_hlr_rej_auth_info_net_fail_reuse_tuples,
455 test_hlr_rej_auth_info_net_fail_no_reuse_tuples,
456 test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples,
457 test_hlr_acc_but_no_auth_tuples,
458 test_hlr_rej_lu,
459 test_hlr_no_insert_data,
460 NULL
461};