blob: 47ca9678f358293462f51b66068eb8dc2c15dbdc [file] [log] [blame]
Neels Hofmeyrf8178142017-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");
76 fake_time_passes(1, 235);
77 btw("SUBSCR_CONN_TIMEOUT has passed, conn is gone.");
78 EXPECT_CONN_COUNT(0);
79 VERBOSE_ASSERT(lu_result_sent, == RES_REJECT, "%d");
80
81 comment_end();
82}
83
84void test_ms_timeout_cm_auth_resp()
85{
86 comment_start();
87
88 net->authentication_required = true;
89
90 fake_time_start();
91
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 /* 5 auth vectors... */
108 /* TL TL rand */
109 "0322" "2010" "585df1ae287f6e273dce07090d61320b"
110 /* TL sres TL kc */
111 "2104" "2d8b2c3e" "2208" "61855fb81fc2a800"
112 "0322" "2010" "12aca96fb4ffdea5c985cbafa9b6e18b"
113 "2104" "20bde240" "2208" "07fa7502e07e1c00"
114 "0322" "2010" "e7c03ba7cf0e2fde82b2dc4d63077d42"
115 "2104" "a29514ae" "2208" "e2b234f807886400"
116 "0322" "2010" "fa8f20b781b5881329d4fea26b1a3c51"
117 "2104" "5afc8d72" "2208" "2392f14f709ae000"
118 "0322" "2010" "0fd4cc8dbe8715d1f439e304edfd68dc"
119 "2104" "bc8d1c5b" "2208" "da7cdd6bfe2d7000",
120 NULL);
121 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
122 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
123
124 btw("MS sends Authen Response, VLR accepts and sends GSUP LU Req to HLR");
125 gsup_expect_tx("04010809710000004026f0");
126 ms_sends_msg("05542d8b2c3e");
127 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
128
129 btw("HLR sends _INSERT_DATA_REQUEST, VLR responds with _INSERT_DATA_RESULT");
130 gsup_rx("10010809710000004026f00804036470f1",
131 "12010809710000004026f0");
132 VERBOSE_ASSERT(lu_result_sent, == RES_NONE, "%d");
133
134 btw("HLR also sends GSUP _UPDATE_LOCATION_RESULT");
135 gsup_rx("06010809710000004026f0", NULL);
136
137 btw("LU was successful, and the conn has already been closed");
138 VERBOSE_ASSERT(lu_result_sent, == RES_ACCEPT, "%d");
139 EXPECT_CONN_COUNT(0);
140
141 BTW("after a while, a new conn sends a CM Service Request. VLR responds with Auth Req, 2nd auth vector");
142 auth_request_sent = false;
143 auth_request_expect_rand = "12aca96fb4ffdea5c985cbafa9b6e18b";
144 cm_service_result_sent = RES_NONE;
145 ms_sends_msg("05247803305886089910070000006402");
146 OSMO_ASSERT(g_conn);
147 OSMO_ASSERT(g_conn->conn_fsm);
148 OSMO_ASSERT(g_conn->vsub);
149 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
150 VERBOSE_ASSERT(auth_request_sent, == true, "%d");
151
152 BTW("MS fails to send an Authentication Response");
153
154 btw("At first, we're still waiting");
155 fake_time_passes(0, 423);
156 EXPECT_CONN_COUNT(1);
157 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
158 fake_time_passes(1, 235);
159 EXPECT_CONN_COUNT(1);
160 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
161 fake_time_passes(1, 235);
162 EXPECT_CONN_COUNT(1);
163 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
164 fake_time_passes(1, 235);
165 EXPECT_CONN_COUNT(1);
166 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
167 fake_time_passes(1, 235);
168 EXPECT_CONN_COUNT(1);
169 VERBOSE_ASSERT(cm_service_result_sent, == RES_NONE, "%d");
170 fake_time_passes(1, 235);
171 btw("SUBSCR_CONN_TIMEOUT has passed, conn is gone.");
172 EXPECT_CONN_COUNT(0);
173 VERBOSE_ASSERT(cm_service_result_sent, == RES_REJECT, "%d");
174
175 clear_vlr();
176 comment_end();
177}
178
179msc_vlr_test_func_t msc_vlr_tests[] = {
180 test_ms_timeout_lu_auth_resp,
181 test_ms_timeout_cm_auth_resp,
182 NULL
183};