blob: 13bed42996dec84e9932cef62334023a532ab8a7 [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"
25
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010026static void test_hlr_rej_auth_info_unknown_imsi()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010027{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010028 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010029
30 net->authentication_required = true;
31
32 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
33 lu_result_sent = RES_NONE;
34 gsup_expect_tx("08010809710000004026f0");
35 ms_sends_msg("050802008168000130089910070000006402");
36 OSMO_ASSERT(gsup_tx_confirmed);
37 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
38
39 btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI");
40 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +020041 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010042 gsup_rx("09" "010809710000004026f0" "020102", NULL);
43 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
44 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +020045 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010046
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020047 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010048 EXPECT_CONN_COUNT(0);
49 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010050 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010051}
52
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010053static void test_hlr_rej_auth_info_net_fail()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010054{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010055 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010056
57 net->authentication_required = true;
58
59 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
60 lu_result_sent = RES_NONE;
61 gsup_expect_tx("08010809710000004026f0");
62 ms_sends_msg("050802008168000130089910070000006402");
63 OSMO_ASSERT(gsup_tx_confirmed);
64 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
65
66 btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail");
67 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +020068 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010069 gsup_rx("09" "010809710000004026f0" "020111", NULL);
70 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
71 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +020072 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010073
Neels Hofmeyr4068ab22018-04-01 20:55:54 +020074 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010075 EXPECT_CONN_COUNT(0);
76 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010077 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010078}
79
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +010080static void test_hlr_rej_auth_info_net_fail_no_reuse_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010081{
82 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010083 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010084
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +010085 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010086
87 net->authentication_required = true;
88 net->vlr->cfg.auth_reuse_old_sets_on_error = false;
Neels Hofmeyr33f53412017-10-29 02:11:18 +010089 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010090
91 BTW("Submit a used auth tuple in the VLR");
92 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
93 lu_result_sent = RES_NONE;
94 gsup_expect_tx("08010809710000004026f0");
95 ms_sends_msg("050802008168000130089910070000006402");
96 OSMO_ASSERT(gsup_tx_confirmed);
97 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
98
99 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
100 auth_request_sent = false;
101 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
102 auth_request_expect_autn = NULL;
103 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
104 gsup_rx("0a"
105 /* imsi */
106 "0108" "09710000004026f0"
107 /* auth vectors... */
108 /* TL TL rand */
109 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
110 /* TL sres TL kc */
111 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
112 ,NULL);
113 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
114 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
115
116 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200117 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100118 ms_sends_msg("05542d8b2c3e");
119 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
120
121 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
122 gsup_rx("10010809710000004026f00804036470f1",
123 "12010809710000004026f0");
124 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
125
126 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200127 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100128 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200129 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100130
131 btw("LU was successful, and the conn has already been closed");
132 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200133 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100134 EXPECT_CONN_COUNT(0);
135
136
137 BTW("Now one auth tuple is available, but used.");
138 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
139 OSMO_ASSERT(vsub);
140 OSMO_ASSERT(vsub->last_tuple);
141 VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d");
142 /* no need to look at all auth tuples, the ongoing test would take an
143 * unexpected course if there were more. */
144 vlr_subscr_put(vsub);
145
146 BTW("Another LU wants to get new tuples; HLR sends Network Failure, we reject.");
147
148 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
149 lu_result_sent = RES_NONE;
150 gsup_expect_tx("08010809710000004026f0");
151 ms_sends_msg("050802008168000130089910070000006402");
152 OSMO_ASSERT(gsup_tx_confirmed);
153 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
154
155 btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail");
156 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +0200157 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100158 gsup_rx("09" "010809710000004026f0" "020111", NULL);
159 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
160 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200161 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100162
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200163 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100164 EXPECT_CONN_COUNT(0);
165 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100166 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100167}
168
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100169static void test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100170{
171 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100172 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100173
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100174 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100175
176 net->authentication_required = true;
177 net->vlr->cfg.auth_reuse_old_sets_on_error = true;
Neels Hofmeyr33f53412017-10-29 02:11:18 +0100178 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100179
180 BTW("Submit a used auth tuple in the VLR");
181 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
182 lu_result_sent = RES_NONE;
183 gsup_expect_tx("08010809710000004026f0");
184 ms_sends_msg("050802008168000130089910070000006402");
185 OSMO_ASSERT(gsup_tx_confirmed);
186 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
187
188 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
189 auth_request_sent = false;
190 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
191 auth_request_expect_autn = NULL;
192 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
193 gsup_rx("0a"
194 /* imsi */
195 "0108" "09710000004026f0"
196 /* auth vectors... */
197 /* TL TL rand */
198 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
199 /* TL sres TL kc */
200 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
201 ,NULL);
202 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
203 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
204
205 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200206 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100207 ms_sends_msg("05542d8b2c3e");
208 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
209
210 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
211 gsup_rx("10010809710000004026f00804036470f1",
212 "12010809710000004026f0");
213 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
214
215 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200216 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100217 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200218 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100219
220 btw("LU was successful, and the conn has already been closed");
221 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200222 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100223 EXPECT_CONN_COUNT(0);
224
225
226 BTW("Now one auth tuple is available, but used.");
227 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
228 OSMO_ASSERT(vsub);
229 OSMO_ASSERT(vsub->last_tuple);
230 VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d");
231 /* no need to look at all auth tuples, the ongoing test would take an
232 * unexpected course if there were more. */
233 vlr_subscr_put(vsub);
234
235 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.");
236 VERBOSE_ASSERT(net->vlr->cfg.auth_reuse_old_sets_on_error, == true, "%d");
237
238 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
239 lu_result_sent = RES_NONE;
240 gsup_expect_tx("08010809710000004026f0");
241 ms_sends_msg("050802008168000130089910070000006402");
242 OSMO_ASSERT(gsup_tx_confirmed);
243 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
244
245 btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI");
246 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +0200247 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100248 gsup_rx("09" "010809710000004026f0" "020102", NULL);
249 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
250 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200251 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100252
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200253 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100254 EXPECT_CONN_COUNT(0);
255 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100256 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100257}
258
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100259static void test_hlr_acc_but_no_auth_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100260{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100261 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100262
263 net->authentication_required = true;
264 net->vlr->cfg.auth_reuse_old_sets_on_error = true;
Neels Hofmeyr33f53412017-10-29 02:11:18 +0100265 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100266
267 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
268 lu_result_sent = RES_NONE;
269 gsup_expect_tx("08010809710000004026f0");
270 ms_sends_msg("050802008168000130089910070000006402");
271 OSMO_ASSERT(gsup_tx_confirmed);
272 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
273
274 btw("from HLR, rx _SEND_AUTH_INFO_RESULT but it lacks auth tuples");
275 auth_request_sent = false;
Philipp Maierfbf66102017-04-09 12:32:51 +0200276 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100277 gsup_rx("0a"
278 /* imsi */
279 "0108" "09710000004026f0"
280 /* NO auth vectors */
281 ,NULL);
282 VERBOSE_ASSERT(auth_request_sent, == false, "%d");
283 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200284 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100285
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200286 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100287 EXPECT_CONN_COUNT(0);
288 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100289 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100290}
291
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100292static void test_hlr_rej_auth_info_net_fail_reuse_tuples()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100293{
294 struct vlr_subscr *vsub;
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100295 const char *imsi = "901700000004620";
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100296
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100297 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100298
299 net->authentication_required = true;
300 net->vlr->cfg.auth_reuse_old_sets_on_error = true;
Neels Hofmeyr33f53412017-10-29 02:11:18 +0100301 net->vlr->cfg.auth_tuple_max_reuse_count = 0;
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100302
303 BTW("Submit a used auth tuple in the VLR");
304 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
305 lu_result_sent = RES_NONE;
306 gsup_expect_tx("08010809710000004026f0");
307 ms_sends_msg("050802008168000130089910070000006402");
308 OSMO_ASSERT(gsup_tx_confirmed);
309 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
310
311 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
312 auth_request_sent = false;
313 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
314 auth_request_expect_autn = NULL;
315 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
316 gsup_rx("0a"
317 /* imsi */
318 "0108" "09710000004026f0"
319 /* auth vectors... */
320 /* TL TL rand */
321 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
322 /* TL sres TL kc */
323 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
324 ,NULL);
325 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
326 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
327
328 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200329 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100330 ms_sends_msg("05542d8b2c3e");
331 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
332
333 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
334 gsup_rx("10010809710000004026f00804036470f1",
335 "12010809710000004026f0");
336 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
337
338 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200339 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100340 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200341 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100342
343 btw("LU was successful, and the conn has already been closed");
344 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200345 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100346 EXPECT_CONN_COUNT(0);
347
348
349 BTW("Now one auth tuple is available, but used.");
350 vsub = vlr_subscr_find_by_imsi(net->vlr, imsi);
351 OSMO_ASSERT(vsub);
352 OSMO_ASSERT(vsub->last_tuple);
353 VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d");
354 /* no need to look at all auth tuples, the ongoing test would take an
355 * unexpected course if there were more. */
356 vlr_subscr_put(vsub);
357
358 BTW("Another LU wants to get new tuples; even though HLR sends Network Failure, we are reusing the old tuples.");
359
360 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
361 lu_result_sent = RES_NONE;
362 gsup_expect_tx("08010809710000004026f0");
363 ms_sends_msg("050802008168000130089910070000006402");
364 OSMO_ASSERT(gsup_tx_confirmed);
365 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
366
367 btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail");
368 auth_request_sent = false;
369 gsup_rx("09" "010809710000004026f0" "020111", NULL);
370 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
371 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
372
373 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200374 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100375 ms_sends_msg("05542d8b2c3e");
376 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
377
378 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
379 gsup_rx("10010809710000004026f00804036470f1",
380 "12010809710000004026f0");
381 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
382
383 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200384 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100385 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200386 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100387
388 btw("LU was successful, and the conn has already been closed");
389 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200390 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100391 EXPECT_CONN_COUNT(0);
392
393 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100394 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100395}
396
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100397static void test_hlr_rej_lu()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100398{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100399 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100400
401 btw("Location Update request causes a GSUP LU request to HLR");
402 lu_result_sent = RES_NONE;
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200403 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100404 ms_sends_msg("050802008168000130089910070000006402");
405 OSMO_ASSERT(gsup_tx_confirmed);
406 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
407
408 btw("HLR sends UPDATE_LOCATION_ERROR");
Philipp Maierfbf66102017-04-09 12:32:51 +0200409 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100410 gsup_rx("05" "010809710000004026f0" "020102",
411 NULL);
412 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200413 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200414 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100415 EXPECT_CONN_COUNT(0);
416
417 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100418 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100419}
420
Neels Hofmeyrf3d81f62018-03-02 01:05:38 +0100421static void test_hlr_no_insert_data()
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100422{
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100423 comment_start();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100424
425 btw("Location Update request causes a GSUP LU request to HLR");
426 lu_result_sent = RES_NONE;
Neels Hofmeyrd0756b12018-09-28 02:41:39 +0200427 gsup_expect_tx("04010809710000004026f0280102");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100428 ms_sends_msg("050802008168000130089910070000006402");
429 OSMO_ASSERT(gsup_tx_confirmed);
430 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
431
432 btw("HLR sends only _UPDATE_LOCATION_RESULT, no INSERT DATA");
Philipp Maierfbf66102017-04-09 12:32:51 +0200433 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100434 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200435 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100436
437 /* TODO should we wait for OSMO_GSUP_MSGT_INSERT_DATA_REQUEST? */
438
439 btw("LU was successful, and the conn has already been closed");
440 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
441
Neels Hofmeyr4068ab22018-04-01 20:55:54 +0200442 bss_sends_clear_complete();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100443 EXPECT_CONN_COUNT(0);
444 clear_vlr();
Neels Hofmeyrdfdc61d2018-03-02 00:40:58 +0100445 comment_end();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100446}
447
448msc_vlr_test_func_t msc_vlr_tests[] = {
449 test_hlr_rej_auth_info_unknown_imsi,
450 test_hlr_rej_auth_info_net_fail,
451 test_hlr_rej_auth_info_net_fail_reuse_tuples,
452 test_hlr_rej_auth_info_net_fail_no_reuse_tuples,
453 test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples,
454 test_hlr_acc_but_no_auth_tuples,
455 test_hlr_rej_lu,
456 test_hlr_no_insert_data,
457 NULL
458};