blob: 3a1dffae74b36ee888ac12f0fa30c913f7ccfbe4 [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;
35 gsup_expect_tx("08010809710000004026f0");
36 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 Hofmeyr6a29d322017-01-25 15:04:16 +010043 gsup_rx("09" "010809710000004026f0" "020102", NULL);
44 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 Hofmeyr4068ab22018-04-01 20:55:54 +020048 bss_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;
62 gsup_expect_tx("08010809710000004026f0");
63 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 Hofmeyr6a29d322017-01-25 15:04:16 +010070 gsup_rx("09" "010809710000004026f0" "020111", NULL);
71 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 Hofmeyr4068ab22018-04-01 20:55:54 +020075 bss_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;
95 gsup_expect_tx("08010809710000004026f0");
96 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 */
112 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
113 ,NULL);
114 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 Hofmeyrd0756b12018-09-28 02:41:39 +0200118 gsup_expect_tx("04010809710000004026f0280102");
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");
123 gsup_rx("10010809710000004026f00804036470f1",
124 "12010809710000004026f0");
125 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 Hofmeyr6a29d322017-01-25 15:04:16 +0100129 gsup_rx("06010809710000004026f0", 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 Hofmeyr4068ab22018-04-01 20:55:54 +0200134 bss_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;
151 gsup_expect_tx("08010809710000004026f0");
152 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 Hofmeyr6a29d322017-01-25 15:04:16 +0100159 gsup_rx("09" "010809710000004026f0" "020111", NULL);
160 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 Hofmeyr4068ab22018-04-01 20:55:54 +0200164 bss_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;
184 gsup_expect_tx("08010809710000004026f0");
185 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 */
201 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
202 ,NULL);
203 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 Hofmeyrd0756b12018-09-28 02:41:39 +0200207 gsup_expect_tx("04010809710000004026f0280102");
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");
212 gsup_rx("10010809710000004026f00804036470f1",
213 "12010809710000004026f0");
214 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 Hofmeyr6a29d322017-01-25 15:04:16 +0100218 gsup_rx("06010809710000004026f0", 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 Hofmeyr4068ab22018-04-01 20:55:54 +0200223 bss_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;
241 gsup_expect_tx("08010809710000004026f0");
242 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 Hofmeyr6a29d322017-01-25 15:04:16 +0100249 gsup_rx("09" "010809710000004026f0" "020102", NULL);
250 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 Hofmeyr4068ab22018-04-01 20:55:54 +0200254 bss_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;
270 gsup_expect_tx("08010809710000004026f0");
271 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 */
282 ,NULL);
283 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
284 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200285 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100286
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200287 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100288 EXPECT_CONN_COUNT(0);
289 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100290 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100291}
292
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100293static void test_hlr_rej_auth_info_net_fail_reuse_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100294{
295 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100296 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100297
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100298 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100299
300 net->authentication_required = true;
301 net->vlr->cfg.auth_reuse_old_sets_on_error = true;
Neels Hofmeyr33f53412017-10-29 02:11:18 +0100302 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100303
304 BTW("Submit a used auth tuple in the VLR");
305 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
306 lu_result_sent = RES_NONE;
307 gsup_expect_tx("08010809710000004026f0");
308 ms_sends_msg("050802008168000130089910070000006402");
309 OSMO_ASSERT(gsup_tx_confirmed);
310 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
311
312 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
313 auth_request_sent = false;
314 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
315 auth_request_expect_autn = NULL;
316 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
317 gsup_rx("0a"
318 /* imsi */
319 "0108" "09710000004026f0"
320 /* auth vectors... */
321 /* TL TL rand */
322 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
323 /* TL sres TL kc */
324 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
325 ,NULL);
326 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
327 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
328
329 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200330 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100331 ms_sends_msg("05542d8b2c3e");
332 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
333
334 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
335 gsup_rx("10010809710000004026f00804036470f1",
336 "12010809710000004026f0");
337 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
338
339 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200340 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100341 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200342 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100343
344 btw("LU was successful, and the conn has already been closed");
345 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200346 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100347 EXPECT_CONN_COUNT(0);
348
349
350 BTW("Now one auth tuple is available, but used.");
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100351 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100352 OSMO_ASSERT(vsub);
353 OSMO_ASSERT(vsub->last_tuple);
354 VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d");
355 /* no need to look at all auth tuples, the ongoing test would take an
356 * unexpected course if there were more. */
Neels Hofmeyr7c5346c2019-02-19 02:36:35 +0100357 vlr_subscr_put(vsub, __func__);
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100358
359 BTW("Another LU wants to get new tuples; even though HLR sends Network Failure, we are reusing the old tuples.");
360
361 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
362 lu_result_sent = RES_NONE;
363 gsup_expect_tx("08010809710000004026f0");
364 ms_sends_msg("050802008168000130089910070000006402");
365 OSMO_ASSERT(gsup_tx_confirmed);
366 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
367
368 btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail");
369 auth_request_sent = false;
370 gsup_rx("09" "010809710000004026f0" "020111", NULL);
371 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
372 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
373
374 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200375 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100376 ms_sends_msg("05542d8b2c3e");
377 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
378
379 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
380 gsup_rx("10010809710000004026f00804036470f1",
381 "12010809710000004026f0");
382 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
383
384 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200385 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100386 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200387 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100388
389 btw("LU was successful, and the conn has already been closed");
390 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200391 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100392 EXPECT_CONN_COUNT(0);
393
394 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100395 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100396}
397
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100398static void test_hlr_rej_lu()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100399{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100400 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100401
402 btw("Location Update request causes a GSUP LU request to HLR");
403 lu_result_sent = RES_NONE;
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200404 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100405 ms_sends_msg("050802008168000130089910070000006402");
406 OSMO_ASSERT(gsup_tx_confirmed);
407 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
408
409 btw("HLR sends UPDATE_LOCATION_ERROR");
Philipp Maierfbf66102017-04-09 12:32:51 +0200410 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100411 gsup_rx("05" "010809710000004026f0" "020102",
412 NULL);
413 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200414 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200415 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100416 EXPECT_CONN_COUNT(0);
417
418 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100419 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100420}
421
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100422static void test_hlr_no_insert_data()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100423{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100424 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100425
426 btw("Location Update request causes a GSUP LU request to HLR");
427 lu_result_sent = RES_NONE;
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200428 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100429 ms_sends_msg("050802008168000130089910070000006402");
430 OSMO_ASSERT(gsup_tx_confirmed);
431 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
432
433 btw("HLR sends only _UPDATE_LOCATION_RESULT, no INSERT DATA");
Philipp Maierfbf66102017-04-09 12:32:51 +0200434 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100435 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200436 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100437
438 /* TODO should we wait for OSMO_GSUP_MSGT_INSERT_DATA_REQUEST? */
439
440 btw("LU was successful, and the conn has already been closed");
441 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
442
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200443 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100444 EXPECT_CONN_COUNT(0);
445 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100446 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100447}
448
449msc_vlr_test_func_t msc_vlr_tests[] = {
450 test_hlr_rej_auth_info_unknown_imsi,
451 test_hlr_rej_auth_info_net_fail,
452 test_hlr_rej_auth_info_net_fail_reuse_tuples,
453 test_hlr_rej_auth_info_net_fail_no_reuse_tuples,
454 test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples,
455 test_hlr_acc_but_no_auth_tuples,
456 test_hlr_rej_lu,
457 test_hlr_no_insert_data,
458 NULL
459};