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 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 26 | static void test_hlr_rej_auth_info_unknown_imsi() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 27 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 28 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 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 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 47 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 48 | EXPECT_CONN_COUNT(0); |
| 49 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 50 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 53 | static void test_hlr_rej_auth_info_net_fail() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 54 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 55 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 56 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 68 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 69 | gsup_rx("09" "010809710000004026f0" "020111", NULL); |
| 70 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 71 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 72 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 73 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 74 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 75 | EXPECT_CONN_COUNT(0); |
| 76 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 77 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 80 | static void test_hlr_rej_auth_info_net_fail_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 81 | { |
| 82 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 83 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 84 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 85 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 86 | |
| 87 | net->authentication_required = true; |
| 88 | net->vlr->cfg.auth_reuse_old_sets_on_error = false; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 89 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 90 | |
| 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 117 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 118 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 127 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 128 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 129 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 130 | |
| 131 | btw("LU was successful, and the conn has already been closed"); |
| 132 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 133 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 134 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 157 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 158 | gsup_rx("09" "010809710000004026f0" "020111", NULL); |
| 159 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 160 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 161 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 162 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 163 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 164 | EXPECT_CONN_COUNT(0); |
| 165 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 166 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 167 | } |
| 168 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 169 | static void test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 170 | { |
| 171 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 172 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 173 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 174 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 175 | |
| 176 | net->authentication_required = true; |
| 177 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 178 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 179 | |
| 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 206 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 207 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 216 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 217 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 218 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 219 | |
| 220 | btw("LU was successful, and the conn has already been closed"); |
| 221 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 222 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 223 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 247 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 248 | gsup_rx("09" "010809710000004026f0" "020102", NULL); |
| 249 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 250 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 251 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 252 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 253 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 254 | EXPECT_CONN_COUNT(0); |
| 255 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 256 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 257 | } |
| 258 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 259 | static void test_hlr_acc_but_no_auth_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 260 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 261 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 262 | |
| 263 | net->authentication_required = true; |
| 264 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 265 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 266 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 276 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 277 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 284 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 285 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 286 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 287 | EXPECT_CONN_COUNT(0); |
| 288 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 289 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 290 | } |
| 291 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 292 | static void test_hlr_rej_auth_info_net_fail_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 293 | { |
| 294 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 295 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 296 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 297 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 298 | |
| 299 | net->authentication_required = true; |
| 300 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 301 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 302 | |
| 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 329 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 330 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 339 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 340 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 341 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 342 | |
| 343 | btw("LU was successful, and the conn has already been closed"); |
| 344 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 345 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 346 | 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 374 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 375 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 384 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 385 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 386 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 387 | |
| 388 | btw("LU was successful, and the conn has already been closed"); |
| 389 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 390 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 391 | EXPECT_CONN_COUNT(0); |
| 392 | |
| 393 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 394 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 395 | } |
| 396 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 397 | static void test_hlr_rej_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 398 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 399 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 400 | |
| 401 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 402 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 403 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 404 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 409 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 410 | gsup_rx("05" "010809710000004026f0" "020102", |
| 411 | NULL); |
| 412 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 413 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 414 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 415 | EXPECT_CONN_COUNT(0); |
| 416 | |
| 417 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 418 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 419 | } |
| 420 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 421 | static void test_hlr_no_insert_data() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 422 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 423 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 424 | |
| 425 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 426 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 427 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 428 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 433 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 434 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 435 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 436 | |
| 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 Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 442 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 443 | EXPECT_CONN_COUNT(0); |
| 444 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 445 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 446 | } |
| 447 | |
| 448 | msc_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 | }; |