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" |
Harald Welte | 0df904d | 2018-12-03 11:00:04 +0100 | [diff] [blame^] | 25 | #include "stubs.h" |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 26 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 27 | static void test_hlr_rej_auth_info_unknown_imsi() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 28 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 29 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 30 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 42 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 43 | gsup_rx("09" "010809710000004026f0" "020102", NULL); |
| 44 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 45 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 46 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 47 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 48 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 49 | EXPECT_CONN_COUNT(0); |
| 50 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 51 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 52 | } |
| 53 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 54 | static void test_hlr_rej_auth_info_net_fail() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 55 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 56 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 57 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 69 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 70 | gsup_rx("09" "010809710000004026f0" "020111", NULL); |
| 71 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 72 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 73 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 74 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 75 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 76 | EXPECT_CONN_COUNT(0); |
| 77 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 78 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 79 | } |
| 80 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 81 | static void test_hlr_rej_auth_info_net_fail_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 82 | { |
| 83 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 84 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 85 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 86 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 87 | |
| 88 | net->authentication_required = true; |
| 89 | net->vlr->cfg.auth_reuse_old_sets_on_error = false; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 90 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 91 | |
| 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 118 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 119 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 128 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 129 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 130 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 131 | |
| 132 | btw("LU was successful, and the conn has already been closed"); |
| 133 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 134 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 135 | EXPECT_CONN_COUNT(0); |
| 136 | |
| 137 | |
| 138 | BTW("Now one auth tuple is available, but used."); |
| 139 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 140 | 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. */ |
| 145 | vlr_subscr_put(vsub); |
| 146 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 158 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 159 | gsup_rx("09" "010809710000004026f0" "020111", NULL); |
| 160 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 161 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 162 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 163 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 164 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 165 | EXPECT_CONN_COUNT(0); |
| 166 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 167 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 170 | static void test_hlr_rej_auth_info_unkown_imsi_no_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 171 | { |
| 172 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 173 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 174 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 175 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 176 | |
| 177 | net->authentication_required = true; |
| 178 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 179 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 180 | |
| 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 207 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 208 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 217 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 218 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 219 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 220 | |
| 221 | btw("LU was successful, and the conn has already been closed"); |
| 222 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 223 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 224 | EXPECT_CONN_COUNT(0); |
| 225 | |
| 226 | |
| 227 | BTW("Now one auth tuple is available, but used."); |
| 228 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 229 | 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. */ |
| 234 | vlr_subscr_put(vsub); |
| 235 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 248 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 249 | gsup_rx("09" "010809710000004026f0" "020102", NULL); |
| 250 | VERBOSE_ASSERT(auth_request_sent, == false, "%d"); |
| 251 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 252 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 253 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 254 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 255 | EXPECT_CONN_COUNT(0); |
| 256 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 257 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 258 | } |
| 259 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 260 | static void test_hlr_acc_but_no_auth_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 261 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 262 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 263 | |
| 264 | net->authentication_required = true; |
| 265 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 266 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 267 | |
| 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 277 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 278 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 285 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 286 | |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 287 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 288 | EXPECT_CONN_COUNT(0); |
| 289 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 290 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 291 | } |
| 292 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 293 | static void test_hlr_rej_auth_info_net_fail_reuse_tuples() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 294 | { |
| 295 | struct vlr_subscr *vsub; |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 296 | const char *imsi = "901700000004620"; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 297 | |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 298 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 299 | |
| 300 | net->authentication_required = true; |
| 301 | net->vlr->cfg.auth_reuse_old_sets_on_error = true; |
Neels Hofmeyr | 33f5341 | 2017-10-29 02:11:18 +0100 | [diff] [blame] | 302 | net->vlr->cfg.auth_tuple_max_reuse_count = 0; |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 303 | |
| 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 330 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 331 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 340 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 341 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 342 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 343 | |
| 344 | btw("LU was successful, and the conn has already been closed"); |
| 345 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 346 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 347 | EXPECT_CONN_COUNT(0); |
| 348 | |
| 349 | |
| 350 | BTW("Now one auth tuple is available, but used."); |
| 351 | vsub = vlr_subscr_find_by_imsi(net->vlr, imsi); |
| 352 | 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. */ |
| 357 | vlr_subscr_put(vsub); |
| 358 | |
| 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 Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 375 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 376 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 385 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 386 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 387 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 388 | |
| 389 | btw("LU was successful, and the conn has already been closed"); |
| 390 | VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 391 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 392 | EXPECT_CONN_COUNT(0); |
| 393 | |
| 394 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 395 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 396 | } |
| 397 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 398 | static void test_hlr_rej_lu() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 399 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 400 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 401 | |
| 402 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 403 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 404 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 405 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 410 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 411 | gsup_rx("05" "010809710000004026f0" "020102", |
| 412 | NULL); |
| 413 | VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d"); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 414 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 415 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 416 | EXPECT_CONN_COUNT(0); |
| 417 | |
| 418 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 419 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 420 | } |
| 421 | |
Neels Hofmeyr | f3d81f6 | 2018-03-02 01:05:38 +0100 | [diff] [blame] | 422 | static void test_hlr_no_insert_data() |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 423 | { |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 424 | comment_start(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 425 | |
| 426 | btw("Location Update request causes a GSUP LU request to HLR"); |
| 427 | lu_result_sent = RES_NONE; |
Neels Hofmeyr | d0756b1 | 2018-09-28 02:41:39 +0200 | [diff] [blame] | 428 | gsup_expect_tx("04010809710000004026f0280102"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 429 | 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 Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 434 | expect_bssap_clear(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 435 | gsup_rx("06010809710000004026f0", NULL); |
Philipp Maier | fbf6610 | 2017-04-09 12:32:51 +0200 | [diff] [blame] | 436 | VERBOSE_ASSERT(bssap_clear_sent, == true, "%d"); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 437 | |
| 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 Hofmeyr | 4068ab2 | 2018-04-01 20:55:54 +0200 | [diff] [blame] | 443 | bss_sends_clear_complete(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 444 | EXPECT_CONN_COUNT(0); |
| 445 | clear_vlr(); |
Neels Hofmeyr | dfdc61d | 2018-03-02 00:40:58 +0100 | [diff] [blame] | 446 | comment_end(); |
Neels Hofmeyr | 6a29d32 | 2017-01-25 15:04:16 +0100 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | msc_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 | }; |