blob: d8a3a314eef747d42f03473277bbf11441cfd94d [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
26void test_ms_timeout_lu_auth_resp()
27{
28 comment_start();
29
30 net->authentication_required = true;
31
32 fake_time_start();
33
34 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
35 lu_result_sent = RES_NONE;
36 gsup_expect_tx("08010809710000004026f0");
37 ms_sends_msg("050802008168000130089910070000006402");
38 OSMO_ASSERT(gsup_tx_confirmed);
39 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
40
41 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
42 auth_request_sent = false;
43 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
44 auth_request_expect_autn = NULL;
45 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
46 gsup_rx("0a"
47 /* imsi */
48 "0108" "09710000004026f0"
49 /* auth vectors... */
50 /* TL TL rand */
51 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
52 /* TL sres TL kc */
53 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
54 ,NULL);
55 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
56 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
57
58 BTW("MS fails to send an Authentication Response");
59
60 btw("At first, we're still waiting");
61 fake_time_passes(0, 423);
62 EXPECT_CONN_COUNT(1);
63 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
64 fake_time_passes(1, 235);
65 EXPECT_CONN_COUNT(1);
66 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
67 fake_time_passes(1, 235);
68 EXPECT_CONN_COUNT(1);
69 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
70 fake_time_passes(1, 235);
71 EXPECT_CONN_COUNT(1);
72 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
73 fake_time_passes(1, 235);
74 EXPECT_CONN_COUNT(1);
75 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +020076 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010077 fake_time_passes(1, 235);
78 btw("SUBSCR_CONN_TIMEOUT has passed, conn is gone.");
Philipp Maierfbf66102017-04-09 12:32:51 +020079 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +010080 EXPECT_CONN_COUNT(0);
81 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
82
83 comment_end();
84}
85
86void test_ms_timeout_cm_auth_resp()
87{
88 comment_start();
89
90 net->authentication_required = true;
91
92 fake_time_start();
93
94 btw("Location Update request causes a GSUP Send Auth Info request to HLR");
95 lu_result_sent = RES_NONE;
96 gsup_expect_tx("08010809710000004026f0");
97 ms_sends_msg("050802008168000130089910070000006402");
98 OSMO_ASSERT(gsup_tx_confirmed);
99 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
100
101 btw("from HLR, rx _SEND_AUTH_INFO_RESULT; VLR sends Auth Req to MS");
102 auth_request_sent = false;
103 auth_request_expect_rand = "585df1ae287f6e273dce07090d61320b";
104 auth_request_expect_autn = NULL;
105 /* Based on a Ki of 000102030405060708090a0b0c0d0e0f */
106 gsup_rx("0a"
107 /* imsi */
108 "0108" "09710000004026f0"
109 /* 5 auth vectors... */
110 /* TL TL rand */
111 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
112 /* TL sres TL kc */
113 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
114 "0322" "2010" "12aca96fb4ffdea5c985cbafa9b6e18b"
115 "2104" "20bde240" "2208" "07fa7502e07e1c00"
116 "0322" "2010" "e7c03ba7cf0e2fde82b2dc4d63077d42"
117 "2104" "a29514ae" "2208" "e2b234f807886400"
118 "0322" "2010" "fa8f20b781b5881329d4fea26b1a3c51"
119 "2104" "5afc8d72" "2208" "2392f14f709ae000"
120 "0322" "2010" "0fd4cc8dbe8715d1f439e304edfd68dc"
121 "2104" "bc8d1c5b" "2208" "da7cdd6bfe2d7000",
122 NULL);
123 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
124 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
125
126 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
127 gsup_expect_tx("04010809710000004026f0");
128 ms_sends_msg("05542d8b2c3e");
129 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
130
131 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
132 gsup_rx("10010809710000004026f00804036470f1",
133 "12010809710000004026f0");
134 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
135
136 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
Philipp Maierfbf66102017-04-09 12:32:51 +0200137 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100138 gsup_rx("06010809710000004026f0", NULL);
Philipp Maierfbf66102017-04-09 12:32:51 +0200139 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100140
141 btw("LU was successful, and the conn has already been closed");
142 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
143 EXPECT_CONN_COUNT(0);
144
145 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
146 auth_request_sent = false;
147 auth_request_expect_rand = "12aca96fb4ffdea5c985cbafa9b6e18b";
148 cm_service_result_sent = RES_NONE;
149 ms_sends_msg("05247803305886089910070000006402");
150 OSMO_ASSERT(g_conn);
151 OSMO_ASSERT(g_conn->conn_fsm);
152 OSMO_ASSERT(g_conn->vsub);
153 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
154 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
155
156 BTW("MS fails to send an Authentication Response");
157
158 btw("At first, we're still waiting");
159 fake_time_passes(0, 423);
160 EXPECT_CONN_COUNT(1);
161 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
162 fake_time_passes(1, 235);
163 EXPECT_CONN_COUNT(1);
164 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
165 fake_time_passes(1, 235);
166 EXPECT_CONN_COUNT(1);
167 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
168 fake_time_passes(1, 235);
169 EXPECT_CONN_COUNT(1);
170 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
171 fake_time_passes(1, 235);
172 EXPECT_CONN_COUNT(1);
173 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
Philipp Maierfbf66102017-04-09 12:32:51 +0200174 expect_bssap_clear();
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100175 fake_time_passes(1, 235);
176 btw("SUBSCR_CONN_TIMEOUT has passed, conn is gone.");
Philipp Maierfbf66102017-04-09 12:32:51 +0200177 VERBOSE_ASSERT(bssap_clear_sent, == true, "%d");
Neels Hofmeyr6a29d322017-01-25 15:04:16 +0100178 EXPECT_CONN_COUNT(0);
179 VERBOSE_ASSERT(cm_service_result_sent, == RES_REJECT, "%d");
180
181 clear_vlr();
182 comment_end();
183}
184
185msc_vlr_test_func_t msc_vlr_tests[] = {
186 test_ms_timeout_lu_auth_resp,
187 test_ms_timeout_cm_auth_resp,
188 NULL
189};