Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 1 | /* 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 | |
| 26 | void test_hlr_rej_auth_info_unknown_imsi() |
| 27 | { |
| 28 | comment_start(); |
| 29 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 41 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 42 | gsup_rx("09" "010809710000004026f0" "020102", NULL); |
| 43 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 44 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 45 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 46 | |
| 47 | EXPECT_CONN_COUNT(0); |
| 48 | clear_vlr(); |
| 49 | comment_end(); |
| 50 | } |
| 51 | |
| 52 | void test_hlr_rej_auth_info_net_fail() |
| 53 | { |
| 54 | comment_start(); |
| 55 | |
| 56 | net->authentication_required = true; |
| 57 | |
| 58 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 59 | lu_result_sent = RES_NONE; |
| 60 | gsup_expect_tx("08010809710000004026f0"); |
| 61 | ms_sends_msg("050802008168000130089910070000006402"); |
| 62 | OSMO_ASSERT(gsup_tx_confirmed); |
| 63 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 64 | |
| 65 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 66 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 67 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 68 | gsup_rx("09" "010809710000004026f0" "020111", NULL); |
| 69 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 70 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 71 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 72 | |
| 73 | EXPECT_CONN_COUNT(0); |
| 74 | clear_vlr(); |
| 75 | comment_end(); |
| 76 | } |
| 77 | |
Max | 093300d | 2018-02-07 12:06:03 +0100 | [diff] [blame^] | 78 | void test_hlr_rej_auth_info_net_fail_no_reuse_tuples(const char *imsi) |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 79 | { |
| 80 | struct vlr_subscr *vsub; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 81 | |
| 82 | comment_start(); |
| 83 | |
| 84 | net->authentication_required = true; |
| 85 | net->vlr->cfg.auth_reuse_old_sets_on_error = false; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 86 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 87 | |
| 88 | BTW("Submit a used auth tuple in the VLR"); |
| 89 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 90 | lu_result_sent = RES_NONE; |
| 91 | gsup_expect_tx("08010809710000004026f0"); |
| 92 | ms_sends_msg("050802008168000130089910070000006402"); |
| 93 | OSMO_ASSERT(gsup_tx_confirmed); |
| 94 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 95 | |
| 96 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 97 | auth_request_sent = false; |
| 98 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 99 | auth_request_expect_autn = NULL; |
| 100 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 101 | gsup_rx("0a" |
| 102 | /* imsi */ |
| 103 | "0108" "09710000004026f0" |
| 104 | /* auth vectors... */ |
| 105 | /* TL TL rand */ |
| 106 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 107 | /* TL sres TL kc */ |
| 108 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
| 109 | ,NULL); |
| 110 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 111 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 112 | |
| 113 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
| 114 | gsup_expect_tx("04010809710000004026f0"); |
| 115 | ms_sends_msg("05542d8b2c3e"); |
| 116 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 117 | |
| 118 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 119 | gsup_rx("10010809710000004026f00804036470f1", |
| 120 | "12010809710000004026f0"); |
| 121 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 122 | |
| 123 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 124 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 125 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 126 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 127 | |
| 128 | btw("LU was successful, and the conn has already been closed"); |
| 129 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 130 | EXPECT_CONN_COUNT(0); |
| 131 | |
| 132 | |
| 133 | BTW("Now one auth tuple is available, but used."); |
| 134 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 135 | OSMO_ASSERT(vsub); |
| 136 | OSMO_ASSERT(vsub->last_tuple); |
| 137 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 138 | /* no need to look at all auth tuples, the ongoing test would take an |
| 139 | * unexpected course if there were more. */ |
| 140 | vlr_subscr_put(vsub); |
| 141 | |
| 142 | BTW("Another LU wants to get new tuples; HLR sends Network Failure, we reject."); |
| 143 | |
| 144 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 145 | lu_result_sent = RES_NONE; |
| 146 | gsup_expect_tx("08010809710000004026f0"); |
| 147 | ms_sends_msg("050802008168000130089910070000006402"); |
| 148 | OSMO_ASSERT(gsup_tx_confirmed); |
| 149 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 150 | |
| 151 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 152 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 153 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 154 | gsup_rx("09" "010809710000004026f0" "020111", NULL); |
| 155 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 156 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 157 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 158 | |
| 159 | EXPECT_CONN_COUNT(0); |
| 160 | clear_vlr(); |
| 161 | comment_end(); |
| 162 | } |
| 163 | |
Max | 093300d | 2018-02-07 12:06:03 +0100 | [diff] [blame^] | 164 | void test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples(const char *imsi) |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 165 | { |
| 166 | struct vlr_subscr *vsub; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 167 | |
| 168 | comment_start(); |
| 169 | |
| 170 | net->authentication_required = true; |
| 171 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 172 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 173 | |
| 174 | BTW("Submit a used auth tuple in the VLR"); |
| 175 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 176 | lu_result_sent = RES_NONE; |
| 177 | gsup_expect_tx("08010809710000004026f0"); |
| 178 | ms_sends_msg("050802008168000130089910070000006402"); |
| 179 | OSMO_ASSERT(gsup_tx_confirmed); |
| 180 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 181 | |
| 182 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 183 | auth_request_sent = false; |
| 184 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 185 | auth_request_expect_autn = NULL; |
| 186 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 187 | gsup_rx("0a" |
| 188 | /* imsi */ |
| 189 | "0108" "09710000004026f0" |
| 190 | /* auth vectors... */ |
| 191 | /* TL TL rand */ |
| 192 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 193 | /* TL sres TL kc */ |
| 194 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
| 195 | ,NULL); |
| 196 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 197 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 198 | |
| 199 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
| 200 | gsup_expect_tx("04010809710000004026f0"); |
| 201 | ms_sends_msg("05542d8b2c3e"); |
| 202 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 203 | |
| 204 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 205 | gsup_rx("10010809710000004026f00804036470f1", |
| 206 | "12010809710000004026f0"); |
| 207 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 208 | |
| 209 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 210 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 211 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 212 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 213 | |
| 214 | btw("LU was successful, and the conn has already been closed"); |
| 215 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 216 | EXPECT_CONN_COUNT(0); |
| 217 | |
| 218 | |
| 219 | BTW("Now one auth tuple is available, but used."); |
| 220 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 221 | OSMO_ASSERT(vsub); |
| 222 | OSMO_ASSERT(vsub->last_tuple); |
| 223 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 224 | /* no need to look at all auth tuples, the ongoing test would take an |
| 225 | * unexpected course if there were more. */ |
| 226 | vlr_subscr_put(vsub); |
| 227 | |
| 228 | 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."); |
| 229 | VERBOSE_ASSERT(net->vlr->cfg.auth_reuse_old_sets_on_error, == true, "%d"); |
| 230 | |
| 231 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 232 | lu_result_sent = RES_NONE; |
| 233 | gsup_expect_tx("08010809710000004026f0"); |
| 234 | ms_sends_msg("050802008168000130089910070000006402"); |
| 235 | OSMO_ASSERT(gsup_tx_confirmed); |
| 236 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 237 | |
| 238 | btw("HLR sends _SEND_AUTH_INFO_ERROR = unknown IMSI"); |
| 239 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 240 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 241 | gsup_rx("09" "010809710000004026f0" "020102", NULL); |
| 242 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 243 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 244 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 245 | |
| 246 | EXPECT_CONN_COUNT(0); |
| 247 | clear_vlr(); |
| 248 | comment_end(); |
| 249 | } |
| 250 | |
| 251 | void test_hlr_acc_but_no_auth_tuples() |
| 252 | { |
| 253 | comment_start(); |
| 254 | |
| 255 | net->authentication_required = true; |
| 256 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 257 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 258 | |
| 259 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 260 | lu_result_sent = RES_NONE; |
| 261 | gsup_expect_tx("08010809710000004026f0"); |
| 262 | ms_sends_msg("050802008168000130089910070000006402"); |
| 263 | OSMO_ASSERT(gsup_tx_confirmed); |
| 264 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 265 | |
| 266 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT but it lacks auth tuples"); |
| 267 | auth_request_sent = false; |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 268 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 269 | gsup_rx("0a" |
| 270 | /* imsi */ |
| 271 | "0108" "09710000004026f0" |
| 272 | /* NO auth vectors */ |
| 273 | ,NULL); |
| 274 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 275 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 276 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 277 | |
| 278 | EXPECT_CONN_COUNT(0); |
| 279 | clear_vlr(); |
| 280 | comment_end(); |
| 281 | } |
| 282 | |
Max | 093300d | 2018-02-07 12:06:03 +0100 | [diff] [blame^] | 283 | void test_hlr_rej_auth_info_net_fail_reuse_tuples(const char *imsi) |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 284 | { |
| 285 | struct vlr_subscr *vsub; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 286 | |
| 287 | comment_start(); |
| 288 | |
| 289 | net->authentication_required = true; |
| 290 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 291 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 292 | |
| 293 | BTW("Submit a used auth tuple in the VLR"); |
| 294 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 295 | lu_result_sent = RES_NONE; |
| 296 | gsup_expect_tx("08010809710000004026f0"); |
| 297 | ms_sends_msg("050802008168000130089910070000006402"); |
| 298 | OSMO_ASSERT(gsup_tx_confirmed); |
| 299 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 300 | |
| 301 | btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS"); |
| 302 | auth_request_sent = false; |
| 303 | auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b"; |
| 304 | auth_request_expect_autn = NULL; |
| 305 | /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */ |
| 306 | gsup_rx("0a" |
| 307 | /* imsi */ |
| 308 | "0108" "09710000004026f0" |
| 309 | /* auth vectors... */ |
| 310 | /* TL TL rand */ |
| 311 | "0322" "2010" "585df1ae287f6e273dce07090d61320b" |
| 312 | /* TL sres TL kc */ |
| 313 | "2104" "2d8b2c3e" "2208" "61855fb81fc2a800" |
| 314 | ,NULL); |
| 315 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 316 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 317 | |
| 318 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
| 319 | gsup_expect_tx("04010809710000004026f0"); |
| 320 | ms_sends_msg("05542d8b2c3e"); |
| 321 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 322 | |
| 323 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 324 | gsup_rx("10010809710000004026f00804036470f1", |
| 325 | "12010809710000004026f0"); |
| 326 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 327 | |
| 328 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 329 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 330 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 331 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 332 | |
| 333 | btw("LU was successful, and the conn has already been closed"); |
| 334 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 335 | EXPECT_CONN_COUNT(0); |
| 336 | |
| 337 | |
| 338 | BTW("Now one auth tuple is available, but used."); |
| 339 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 340 | OSMO_ASSERT(vsub); |
| 341 | OSMO_ASSERT(vsub->last_tuple); |
| 342 | VERBOSE_ASSERT(vsub->last_tuple->use_count, == 1, "%d"); |
| 343 | /* no need to look at all auth tuples, the ongoing test would take an |
| 344 | * unexpected course if there were more. */ |
| 345 | vlr_subscr_put(vsub); |
| 346 | |
| 347 | BTW("Another LU wants to get new tuples; even though HLR sends Network Failure, we are reusing the old tuples."); |
| 348 | |
| 349 | btw("Location Update request causes a GSUP Send Auth Info request to HLR"); |
| 350 | lu_result_sent = RES_NONE; |
| 351 | gsup_expect_tx("08010809710000004026f0"); |
| 352 | ms_sends_msg("050802008168000130089910070000006402"); |
| 353 | OSMO_ASSERT(gsup_tx_confirmed); |
| 354 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 355 | |
| 356 | btw("HLR sends _SEND_AUTH_INFO_ERROR = net fail"); |
| 357 | auth_request_sent = false; |
| 358 | gsup_rx("09" "010809710000004026f0" "020111", NULL); |
| 359 | VERBOSE_ASSERT(auth_request_sent, == true, "%d"); |
| 360 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 361 | |
| 362 | btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR"); |
| 363 | gsup_expect_tx("04010809710000004026f0"); |
| 364 | ms_sends_msg("05542d8b2c3e"); |
| 365 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 366 | |
| 367 | btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT"); |
| 368 | gsup_rx("10010809710000004026f00804036470f1", |
| 369 | "12010809710000004026f0"); |
| 370 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 371 | |
| 372 | btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 373 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 374 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 375 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 376 | |
| 377 | btw("LU was successful, and the conn has already been closed"); |
| 378 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 379 | EXPECT_CONN_COUNT(0); |
| 380 | |
| 381 | clear_vlr(); |
| 382 | comment_end(); |
| 383 | } |
| 384 | |
| 385 | void test_hlr_rej_lu() |
| 386 | { |
| 387 | comment_start(); |
| 388 | |
| 389 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 390 | lu_result_sent = RES_NONE; |
| 391 | gsup_expect_tx("04010809710000004026f0"); |
| 392 | ms_sends_msg("050802008168000130089910070000006402"); |
| 393 | OSMO_ASSERT(gsup_tx_confirmed); |
| 394 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 395 | |
| 396 | btw("HLR sends UPDATE_LOCATION_ERROR"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 397 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 398 | gsup_rx("05" "010809710000004026f0" "020102", |
| 399 | NULL); |
| 400 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 401 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 402 | EXPECT_CONN_COUNT(0); |
| 403 | |
| 404 | clear_vlr(); |
| 405 | comment_end(); |
| 406 | } |
| 407 | |
| 408 | void test_hlr_no_insert_data() |
| 409 | { |
| 410 | comment_start(); |
| 411 | |
| 412 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 413 | lu_result_sent = RES_NONE; |
| 414 | gsup_expect_tx("04010809710000004026f0"); |
| 415 | ms_sends_msg("050802008168000130089910070000006402"); |
| 416 | OSMO_ASSERT(gsup_tx_confirmed); |
| 417 | VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d"); |
| 418 | |
| 419 | btw("HLR sends only _UPDATE_LOCATION_RESULT, no INSERT DATA"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 420 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 421 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 422 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 423 | |
| 424 | /* TODO should we wait for OSMO_GSUP_MSGT_INSERT_DATA_REQUEST? */ |
| 425 | |
| 426 | btw("LU was successful, and the conn has already been closed"); |
| 427 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
| 428 | |
| 429 | EXPECT_CONN_COUNT(0); |
| 430 | clear_vlr(); |
| 431 | comment_end(); |
| 432 | } |
| 433 | |
| 434 | msc_vlr_test_func_t msc_vlr_tests[] = { |
| 435 | test_hlr_rej_auth_info_unknown_imsi, |
| 436 | test_hlr_rej_auth_info_net_fail, |
| 437 | test_hlr_rej_auth_info_net_fail_reuse_tuples, |
| 438 | test_hlr_rej_auth_info_net_fail_no_reuse_tuples, |
| 439 | test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples, |
| 440 | test_hlr_acc_but_no_auth_tuples, |
| 441 | test_hlr_rej_lu, |
| 442 | test_hlr_no_insert_data, |
| 443 | NULL |
| 444 | }; |