Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 1 | |
| 2 | ===== test_subscr_create_update_sel_delete |
| 3 | |
| 4 | --- Create with valid / invalid IMSI |
| 5 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 6 | db_subscr_create(dbc, imsi0, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 7 | |
| 8 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 9 | struct hlr_subscriber { |
| 10 | .id = 1, |
| 11 | .imsi = '123456789000000', |
| 12 | } |
| 13 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 14 | db_subscr_create(dbc, imsi1, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 15 | |
| 16 | db_subscr_get_by_imsi(dbc, imsi1, &g_subscr) --> 0 |
| 17 | struct hlr_subscriber { |
| 18 | .id = 2, |
| 19 | .imsi = '123456789000001', |
| 20 | } |
| 21 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 22 | db_subscr_create(dbc, imsi2, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 23 | |
| 24 | db_subscr_get_by_imsi(dbc, imsi2, &g_subscr) --> 0 |
| 25 | struct hlr_subscriber { |
| 26 | .id = 3, |
| 27 | .imsi = '123456789000002', |
| 28 | } |
| 29 | |
Pau Espin Pedrol | d456fce | 2022-06-17 17:56:56 +0200 | [diff] [blame] | 30 | db_subscr_create(dbc, imsi0, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EEXIST |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 31 | DAUC IMSI='123456789000000': Cannot create subscriber: SQL error: (2067) UNIQUE constraint failed: subscriber.imsi |
| 32 | |
| 33 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 34 | struct hlr_subscriber { |
| 35 | .id = 1, |
| 36 | .imsi = '123456789000000', |
| 37 | } |
| 38 | |
Pau Espin Pedrol | d456fce | 2022-06-17 17:56:56 +0200 | [diff] [blame] | 39 | db_subscr_create(dbc, imsi1, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EEXIST |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 40 | DAUC IMSI='123456789000001': Cannot create subscriber: SQL error: (2067) UNIQUE constraint failed: subscriber.imsi |
| 41 | |
Pau Espin Pedrol | d456fce | 2022-06-17 17:56:56 +0200 | [diff] [blame] | 42 | db_subscr_create(dbc, imsi1, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EEXIST |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 43 | DAUC IMSI='123456789000001': Cannot create subscriber: SQL error: (2067) UNIQUE constraint failed: subscriber.imsi |
| 44 | |
| 45 | db_subscr_get_by_imsi(dbc, imsi1, &g_subscr) --> 0 |
| 46 | struct hlr_subscriber { |
| 47 | .id = 2, |
| 48 | .imsi = '123456789000001', |
| 49 | } |
| 50 | |
Pau Espin Pedrol | d456fce | 2022-06-17 17:56:56 +0200 | [diff] [blame] | 51 | db_subscr_create(dbc, imsi2, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EEXIST |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 52 | DAUC IMSI='123456789000002': Cannot create subscriber: SQL error: (2067) UNIQUE constraint failed: subscriber.imsi |
| 53 | |
Pau Espin Pedrol | d456fce | 2022-06-17 17:56:56 +0200 | [diff] [blame] | 54 | db_subscr_create(dbc, imsi2, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EEXIST |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 55 | DAUC IMSI='123456789000002': Cannot create subscriber: SQL error: (2067) UNIQUE constraint failed: subscriber.imsi |
| 56 | |
| 57 | db_subscr_get_by_imsi(dbc, imsi2, &g_subscr) --> 0 |
| 58 | struct hlr_subscriber { |
| 59 | .id = 3, |
| 60 | .imsi = '123456789000002', |
| 61 | } |
| 62 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 63 | db_subscr_create(dbc, "123456789 000003", DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EINVAL |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 64 | DAUC Cannot create subscriber: invalid IMSI: '123456789 000003' |
| 65 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 66 | db_subscr_get_by_imsi(dbc, "123456789000003", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 67 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 68 | db_subscr_create(dbc, "123456789000002123456", DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EINVAL |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 69 | DAUC Cannot create subscriber: invalid IMSI: '123456789000002123456' |
| 70 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 71 | db_subscr_get_by_imsi(dbc, "123456789000002123456", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 72 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 73 | db_subscr_create(dbc, "foobar123", DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EINVAL |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 74 | DAUC Cannot create subscriber: invalid IMSI: 'foobar123' |
| 75 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 76 | db_subscr_get_by_imsi(dbc, "foobar123", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 77 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 78 | db_subscr_create(dbc, "123", DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> -EINVAL |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 79 | DAUC Cannot create subscriber: invalid IMSI: '123' |
| 80 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 81 | db_subscr_get_by_imsi(dbc, "123", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 82 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 83 | db_subscr_create(dbc, short_imsi, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 84 | |
| 85 | db_subscr_get_by_imsi(dbc, short_imsi, &g_subscr) --> 0 |
| 86 | struct hlr_subscriber { |
| 87 | .id = 4, |
| 88 | .imsi = '123456', |
| 89 | } |
| 90 | |
| 91 | |
Oliver Smith | 6b73fd9 | 2019-03-06 13:49:05 +0100 | [diff] [blame] | 92 | --- Check if subscriber exists (by IMSI) |
| 93 | |
| 94 | db_subscr_exists_by_imsi(dbc, imsi0) --> 0 |
| 95 | |
| 96 | db_subscr_exists_by_imsi(dbc, unknown_imsi) --> -ENOENT |
| 97 | |
| 98 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 99 | --- Set valid / invalid MSISDN |
| 100 | |
| 101 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 102 | struct hlr_subscriber { |
| 103 | .id = 1, |
| 104 | .imsi = '123456789000000', |
| 105 | } |
| 106 | |
| 107 | db_subscr_update_msisdn_by_imsi(dbc, imsi0, "54321") --> 0 |
| 108 | |
| 109 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 110 | struct hlr_subscriber { |
| 111 | .id = 1, |
| 112 | .imsi = '123456789000000', |
| 113 | .msisdn = '54321', |
| 114 | } |
| 115 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 116 | db_subscr_get_by_msisdn(dbc, "54321", &g_subscr) --> 0 |
| 117 | struct hlr_subscriber { |
| 118 | .id = 1, |
| 119 | .imsi = '123456789000000', |
| 120 | .msisdn = '54321', |
| 121 | } |
| 122 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 123 | db_subscr_update_msisdn_by_imsi(dbc, imsi0, "54321012345678912345678") --> -EINVAL |
| 124 | DAUC IMSI='123456789000000': Cannot update subscriber: invalid MSISDN: '54321012345678912345678' |
| 125 | |
| 126 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 127 | struct hlr_subscriber { |
| 128 | .id = 1, |
| 129 | .imsi = '123456789000000', |
| 130 | .msisdn = '54321', |
| 131 | } |
| 132 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 133 | db_subscr_get_by_msisdn(dbc, "54321", &g_subscr) --> 0 |
| 134 | struct hlr_subscriber { |
| 135 | .id = 1, |
| 136 | .imsi = '123456789000000', |
| 137 | .msisdn = '54321', |
| 138 | } |
| 139 | |
| 140 | db_subscr_get_by_msisdn(dbc, "54321012345678912345678", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 141 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 142 | db_subscr_update_msisdn_by_imsi(dbc, imsi0, "543 21") --> -EINVAL |
| 143 | DAUC IMSI='123456789000000': Cannot update subscriber: invalid MSISDN: '543 21' |
| 144 | |
| 145 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 146 | struct hlr_subscriber { |
| 147 | .id = 1, |
| 148 | .imsi = '123456789000000', |
| 149 | .msisdn = '54321', |
| 150 | } |
| 151 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 152 | db_subscr_get_by_msisdn(dbc, "543 21", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 153 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 154 | db_subscr_update_msisdn_by_imsi(dbc, imsi0, "foobar123") --> -EINVAL |
| 155 | DAUC IMSI='123456789000000': Cannot update subscriber: invalid MSISDN: 'foobar123' |
| 156 | |
| 157 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 158 | struct hlr_subscriber { |
| 159 | .id = 1, |
| 160 | .imsi = '123456789000000', |
| 161 | .msisdn = '54321', |
| 162 | } |
| 163 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 164 | db_subscr_get_by_msisdn(dbc, "foobar123", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 165 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 166 | db_subscr_update_msisdn_by_imsi(dbc, imsi0, "5") --> 0 |
| 167 | |
| 168 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 169 | struct hlr_subscriber { |
| 170 | .id = 1, |
| 171 | .imsi = '123456789000000', |
| 172 | .msisdn = '5', |
| 173 | } |
| 174 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 175 | db_subscr_get_by_msisdn(dbc, "5", &g_subscr) --> 0 |
| 176 | struct hlr_subscriber { |
| 177 | .id = 1, |
| 178 | .imsi = '123456789000000', |
| 179 | .msisdn = '5', |
| 180 | } |
| 181 | |
| 182 | db_subscr_get_by_msisdn(dbc, "54321", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 183 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 184 | db_subscr_update_msisdn_by_imsi(dbc, imsi0, "543210123456789") --> 0 |
| 185 | |
| 186 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 187 | struct hlr_subscriber { |
| 188 | .id = 1, |
| 189 | .imsi = '123456789000000', |
| 190 | .msisdn = '543210123456789', |
| 191 | } |
| 192 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 193 | db_subscr_get_by_msisdn(dbc, "543210123456789", &g_subscr) --> 0 |
| 194 | struct hlr_subscriber { |
| 195 | .id = 1, |
| 196 | .imsi = '123456789000000', |
| 197 | .msisdn = '543210123456789', |
| 198 | } |
| 199 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 200 | db_subscr_update_msisdn_by_imsi(dbc, imsi0, "5432101234567891") --> -EINVAL |
| 201 | DAUC IMSI='123456789000000': Cannot update subscriber: invalid MSISDN: '5432101234567891' |
| 202 | |
| 203 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 204 | struct hlr_subscriber { |
| 205 | .id = 1, |
| 206 | .imsi = '123456789000000', |
| 207 | .msisdn = '543210123456789', |
| 208 | } |
| 209 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 210 | db_subscr_get_by_msisdn(dbc, "5432101234567891", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 211 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 212 | |
Vadim Yanitskiy | c13599d | 2019-03-30 17:03:42 +0700 | [diff] [blame] | 213 | --- Check if subscriber exists (by MSISDN) |
| 214 | |
| 215 | db_subscr_exists_by_msisdn(dbc, "543210123456789") --> 0 |
| 216 | |
| 217 | db_subscr_exists_by_msisdn(dbc, "5432101234567891") --> -ENOENT |
| 218 | |
| 219 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 220 | --- Set MSISDN on non-existent / invalid IMSI |
| 221 | |
| 222 | db_subscr_update_msisdn_by_imsi(dbc, unknown_imsi, "99") --> -ENOENT |
| 223 | DAUC Cannot update MSISDN: no such subscriber: IMSI='999999999' |
| 224 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 225 | db_subscr_get_by_msisdn(dbc, "99", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 226 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 227 | db_subscr_update_msisdn_by_imsi(dbc, "foobar", "99") --> -ENOENT |
| 228 | DAUC Cannot update MSISDN: no such subscriber: IMSI='foobar' |
| 229 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 230 | db_subscr_get_by_msisdn(dbc, "99", &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 231 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 232 | |
Oliver Smith | 81db389 | 2019-01-09 12:03:51 +0100 | [diff] [blame] | 233 | --- Set valid / invalid IMEI |
| 234 | |
| 235 | db_subscr_update_imei_by_imsi(dbc, imsi0, "12345678901234") --> 0 |
| 236 | |
| 237 | db_subscr_get_by_imei(dbc, "12345678901234", &g_subscr) --> 0 |
| 238 | struct hlr_subscriber { |
| 239 | .id = 1, |
| 240 | .imsi = '123456789000000', |
| 241 | .msisdn = '543210123456789', |
| 242 | .imei = '12345678901234', |
| 243 | } |
| 244 | |
| 245 | db_subscr_update_imei_by_imsi(dbc, imsi0, "123456789012345") --> -EINVAL |
| 246 | DAUC Cannot update subscriber IMSI='123456789000000': invalid IMEI: '123456789012345' |
| 247 | |
| 248 | db_subscr_get_by_imei(dbc, "12345678901234", &g_subscr) --> 0 |
| 249 | struct hlr_subscriber { |
| 250 | .id = 1, |
| 251 | .imsi = '123456789000000', |
| 252 | .msisdn = '543210123456789', |
| 253 | .imei = '12345678901234', |
| 254 | } |
| 255 | |
| 256 | db_subscr_get_by_imei(dbc, "123456789012345", &g_subscr) --> -ENOENT |
Oliver Smith | 81db389 | 2019-01-09 12:03:51 +0100 | [diff] [blame] | 257 | |
| 258 | |
| 259 | --- Set the same IMEI again |
| 260 | |
| 261 | db_subscr_update_imei_by_imsi(dbc, imsi0, "12345678901234") --> 0 |
| 262 | |
| 263 | db_subscr_get_by_imei(dbc, "12345678901234", &g_subscr) --> 0 |
| 264 | struct hlr_subscriber { |
| 265 | .id = 1, |
| 266 | .imsi = '123456789000000', |
| 267 | .msisdn = '543210123456789', |
| 268 | .imei = '12345678901234', |
| 269 | } |
| 270 | |
| 271 | |
| 272 | --- Remove IMEI |
| 273 | |
| 274 | db_subscr_update_imei_by_imsi(dbc, imsi0, NULL) --> 0 |
| 275 | |
| 276 | db_subscr_get_by_imei(dbc, "12345678901234", &g_subscr) --> -ENOENT |
Oliver Smith | 81db389 | 2019-01-09 12:03:51 +0100 | [diff] [blame] | 277 | |
| 278 | |
Neels Hofmeyr | e8ccd50 | 2017-10-06 04:10:06 +0200 | [diff] [blame] | 279 | --- Set / unset nam_cs and nam_ps |
| 280 | |
| 281 | db_subscr_nam(dbc, imsi0, false, true) --> 0 |
| 282 | |
| 283 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 284 | struct hlr_subscriber { |
| 285 | .id = 1, |
| 286 | .imsi = '123456789000000', |
| 287 | .msisdn = '543210123456789', |
| 288 | .nam_ps = false, |
| 289 | } |
| 290 | |
| 291 | db_subscr_nam(dbc, imsi0, false, false) --> 0 |
| 292 | |
| 293 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 294 | struct hlr_subscriber { |
| 295 | .id = 1, |
| 296 | .imsi = '123456789000000', |
| 297 | .msisdn = '543210123456789', |
| 298 | .nam_cs = false, |
| 299 | .nam_ps = false, |
| 300 | } |
| 301 | |
| 302 | db_subscr_nam(dbc, imsi0, true, false) --> 0 |
| 303 | |
| 304 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 305 | struct hlr_subscriber { |
| 306 | .id = 1, |
| 307 | .imsi = '123456789000000', |
| 308 | .msisdn = '543210123456789', |
| 309 | .nam_ps = false, |
| 310 | } |
| 311 | |
| 312 | db_subscr_nam(dbc, imsi0, true, true) --> 0 |
| 313 | |
| 314 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 315 | struct hlr_subscriber { |
| 316 | .id = 1, |
| 317 | .imsi = '123456789000000', |
| 318 | .msisdn = '543210123456789', |
| 319 | } |
| 320 | |
| 321 | |
| 322 | --- Set / unset nam_cs and nam_ps *again* |
| 323 | |
| 324 | db_subscr_nam(dbc, imsi0, false, true) --> 0 |
| 325 | |
| 326 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 327 | struct hlr_subscriber { |
| 328 | .id = 1, |
| 329 | .imsi = '123456789000000', |
| 330 | .msisdn = '543210123456789', |
| 331 | .nam_ps = false, |
| 332 | } |
| 333 | |
| 334 | db_subscr_nam(dbc, imsi0, false, true) --> 0 |
| 335 | |
| 336 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 337 | struct hlr_subscriber { |
| 338 | .id = 1, |
| 339 | .imsi = '123456789000000', |
| 340 | .msisdn = '543210123456789', |
| 341 | .nam_ps = false, |
| 342 | } |
| 343 | |
| 344 | db_subscr_nam(dbc, imsi0, false, false) --> 0 |
| 345 | |
| 346 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 347 | struct hlr_subscriber { |
| 348 | .id = 1, |
| 349 | .imsi = '123456789000000', |
| 350 | .msisdn = '543210123456789', |
| 351 | .nam_cs = false, |
| 352 | .nam_ps = false, |
| 353 | } |
| 354 | |
| 355 | db_subscr_nam(dbc, imsi0, false, false) --> 0 |
| 356 | |
| 357 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 358 | struct hlr_subscriber { |
| 359 | .id = 1, |
| 360 | .imsi = '123456789000000', |
| 361 | .msisdn = '543210123456789', |
| 362 | .nam_cs = false, |
| 363 | .nam_ps = false, |
| 364 | } |
| 365 | |
| 366 | db_subscr_nam(dbc, imsi0, true, true) --> 0 |
| 367 | |
| 368 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 369 | struct hlr_subscriber { |
| 370 | .id = 1, |
| 371 | .imsi = '123456789000000', |
| 372 | .msisdn = '543210123456789', |
| 373 | .nam_cs = false, |
| 374 | } |
| 375 | |
| 376 | db_subscr_nam(dbc, imsi0, true, true) --> 0 |
| 377 | |
| 378 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 379 | struct hlr_subscriber { |
| 380 | .id = 1, |
| 381 | .imsi = '123456789000000', |
| 382 | .msisdn = '543210123456789', |
| 383 | .nam_cs = false, |
| 384 | } |
| 385 | |
| 386 | db_subscr_nam(dbc, imsi0, true, false) --> 0 |
| 387 | |
| 388 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 389 | struct hlr_subscriber { |
| 390 | .id = 1, |
| 391 | .imsi = '123456789000000', |
| 392 | .msisdn = '543210123456789', |
| 393 | } |
| 394 | |
| 395 | db_subscr_nam(dbc, imsi0, true, false) --> 0 |
| 396 | |
| 397 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 398 | struct hlr_subscriber { |
| 399 | .id = 1, |
| 400 | .imsi = '123456789000000', |
| 401 | .msisdn = '543210123456789', |
| 402 | } |
| 403 | |
| 404 | |
| 405 | --- Set nam_cs and nam_ps on non-existent / invalid IMSI |
| 406 | |
| 407 | db_subscr_nam(dbc, unknown_imsi, false, true) --> -ENOENT |
| 408 | DAUC Cannot disable PS: no such subscriber: IMSI='999999999' |
| 409 | |
| 410 | db_subscr_nam(dbc, unknown_imsi, false, false) --> -ENOENT |
| 411 | DAUC Cannot disable CS: no such subscriber: IMSI='999999999' |
| 412 | |
| 413 | db_subscr_get_by_imsi(dbc, unknown_imsi, &g_subscr) --> -ENOENT |
Neels Hofmeyr | e8ccd50 | 2017-10-06 04:10:06 +0200 | [diff] [blame] | 414 | |
| 415 | db_subscr_nam(dbc, "foobar", false, true) --> -ENOENT |
| 416 | DAUC Cannot disable PS: no such subscriber: IMSI='foobar' |
| 417 | |
| 418 | db_subscr_nam(dbc, "foobar", false, false) --> -ENOENT |
| 419 | DAUC Cannot disable CS: no such subscriber: IMSI='foobar' |
| 420 | |
| 421 | |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 422 | --- Record LU for PS and CS (SGSN and VLR names) |
| 423 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 424 | db_subscr_lu_str(dbc, id0, "5952", true) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 425 | |
| 426 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 427 | struct hlr_subscriber { |
| 428 | .id = 1, |
| 429 | .imsi = '123456789000000', |
| 430 | .msisdn = '543210123456789', |
| 431 | .sgsn_number = '5952', |
| 432 | } |
| 433 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 434 | db_subscr_lu_str(dbc, id0, "712", false) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 435 | |
| 436 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 437 | struct hlr_subscriber { |
| 438 | .id = 1, |
| 439 | .imsi = '123456789000000', |
| 440 | .msisdn = '543210123456789', |
| 441 | .vlr_number = '712', |
| 442 | .sgsn_number = '5952', |
| 443 | } |
| 444 | |
| 445 | |
| 446 | --- Record LU for PS and CS (SGSN and VLR names) *again* |
| 447 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 448 | db_subscr_lu_str(dbc, id0, "111", true) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 449 | |
| 450 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 451 | struct hlr_subscriber { |
| 452 | .id = 1, |
| 453 | .imsi = '123456789000000', |
| 454 | .msisdn = '543210123456789', |
| 455 | .vlr_number = '712', |
| 456 | .sgsn_number = '111', |
| 457 | } |
| 458 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 459 | db_subscr_lu_str(dbc, id0, "111", true) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 460 | |
| 461 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 462 | struct hlr_subscriber { |
| 463 | .id = 1, |
| 464 | .imsi = '123456789000000', |
| 465 | .msisdn = '543210123456789', |
| 466 | .vlr_number = '712', |
| 467 | .sgsn_number = '111', |
| 468 | } |
| 469 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 470 | db_subscr_lu_str(dbc, id0, "222", false) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 471 | |
| 472 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 473 | struct hlr_subscriber { |
| 474 | .id = 1, |
| 475 | .imsi = '123456789000000', |
| 476 | .msisdn = '543210123456789', |
| 477 | .vlr_number = '222', |
| 478 | .sgsn_number = '111', |
| 479 | } |
| 480 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 481 | db_subscr_lu_str(dbc, id0, "222", false) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 482 | |
| 483 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 484 | struct hlr_subscriber { |
| 485 | .id = 1, |
| 486 | .imsi = '123456789000000', |
| 487 | .msisdn = '543210123456789', |
| 488 | .vlr_number = '222', |
| 489 | .sgsn_number = '111', |
| 490 | } |
| 491 | |
| 492 | |
| 493 | --- Unset LU info for PS and CS (SGSN and VLR names) |
| 494 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 495 | db_subscr_lu_str(dbc, id0, "", true) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 496 | |
| 497 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 498 | struct hlr_subscriber { |
| 499 | .id = 1, |
| 500 | .imsi = '123456789000000', |
| 501 | .msisdn = '543210123456789', |
| 502 | .vlr_number = '222', |
| 503 | } |
| 504 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 505 | db_subscr_lu_str(dbc, id0, "", false) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 506 | |
| 507 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 508 | struct hlr_subscriber { |
| 509 | .id = 1, |
| 510 | .imsi = '123456789000000', |
| 511 | .msisdn = '543210123456789', |
| 512 | } |
| 513 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 514 | db_subscr_lu_str(dbc, id0, "111", true) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 515 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 516 | db_subscr_lu_str(dbc, id0, "222", false) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 517 | |
| 518 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 519 | struct hlr_subscriber { |
| 520 | .id = 1, |
| 521 | .imsi = '123456789000000', |
| 522 | .msisdn = '543210123456789', |
| 523 | .vlr_number = '222', |
| 524 | .sgsn_number = '111', |
| 525 | } |
| 526 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 527 | db_subscr_lu_str(dbc, id0, NULL, true) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 528 | |
| 529 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 530 | struct hlr_subscriber { |
| 531 | .id = 1, |
| 532 | .imsi = '123456789000000', |
| 533 | .msisdn = '543210123456789', |
| 534 | .vlr_number = '222', |
| 535 | } |
| 536 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 537 | db_subscr_lu_str(dbc, id0, NULL, false) --> 0 |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 538 | |
| 539 | db_subscr_get_by_id(dbc, id0, &g_subscr) --> 0 |
| 540 | struct hlr_subscriber { |
| 541 | .id = 1, |
| 542 | .imsi = '123456789000000', |
| 543 | .msisdn = '543210123456789', |
| 544 | } |
| 545 | |
| 546 | |
| 547 | --- Record LU for non-existent ID |
| 548 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 549 | db_subscr_lu_str(dbc, 99999, "5952", true) --> -ENOENT |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 550 | DAUC Cannot update SGSN number for subscriber ID=99999: no such subscriber |
| 551 | |
Neels Hofmeyr | ad868e2 | 2019-11-20 02:36:45 +0100 | [diff] [blame] | 552 | db_subscr_lu_str(dbc, 99999, "712", false) --> -ENOENT |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 553 | DAUC Cannot update VLR number for subscriber ID=99999: no such subscriber |
| 554 | |
| 555 | db_subscr_get_by_id(dbc, 99999, &g_subscr) --> -ENOENT |
Neels Hofmeyr | dd78305 | 2017-10-09 17:36:08 +0200 | [diff] [blame] | 556 | |
| 557 | |
Neels Hofmeyr | e50121e | 2017-10-09 17:48:51 +0200 | [diff] [blame] | 558 | --- Purge and un-purge PS and CS |
| 559 | |
| 560 | db_subscr_purge(dbc, imsi0, true, true) --> 0 |
| 561 | |
| 562 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 563 | struct hlr_subscriber { |
| 564 | .id = 1, |
| 565 | .imsi = '123456789000000', |
| 566 | .msisdn = '543210123456789', |
| 567 | .ms_purged_ps = true, |
| 568 | } |
| 569 | |
| 570 | db_subscr_purge(dbc, imsi0, true, false) --> 0 |
| 571 | |
| 572 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 573 | struct hlr_subscriber { |
| 574 | .id = 1, |
| 575 | .imsi = '123456789000000', |
| 576 | .msisdn = '543210123456789', |
| 577 | .ms_purged_cs = true, |
| 578 | .ms_purged_ps = true, |
| 579 | } |
| 580 | |
| 581 | db_subscr_purge(dbc, imsi0, false, false) --> 0 |
| 582 | |
| 583 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 584 | struct hlr_subscriber { |
| 585 | .id = 1, |
| 586 | .imsi = '123456789000000', |
| 587 | .msisdn = '543210123456789', |
| 588 | .ms_purged_ps = true, |
| 589 | } |
| 590 | |
| 591 | db_subscr_purge(dbc, imsi0, false, true) --> 0 |
| 592 | |
| 593 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 594 | struct hlr_subscriber { |
| 595 | .id = 1, |
| 596 | .imsi = '123456789000000', |
| 597 | .msisdn = '543210123456789', |
| 598 | } |
| 599 | |
| 600 | |
| 601 | --- Purge PS and CS *again* |
| 602 | |
| 603 | db_subscr_purge(dbc, imsi0, true, true) --> 0 |
| 604 | |
| 605 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 606 | struct hlr_subscriber { |
| 607 | .id = 1, |
| 608 | .imsi = '123456789000000', |
| 609 | .msisdn = '543210123456789', |
| 610 | .ms_purged_ps = true, |
| 611 | } |
| 612 | |
| 613 | db_subscr_purge(dbc, imsi0, true, true) --> 0 |
| 614 | |
| 615 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 616 | struct hlr_subscriber { |
| 617 | .id = 1, |
| 618 | .imsi = '123456789000000', |
| 619 | .msisdn = '543210123456789', |
| 620 | .ms_purged_ps = true, |
| 621 | } |
| 622 | |
| 623 | db_subscr_purge(dbc, imsi0, false, true) --> 0 |
| 624 | |
| 625 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 626 | struct hlr_subscriber { |
| 627 | .id = 1, |
| 628 | .imsi = '123456789000000', |
| 629 | .msisdn = '543210123456789', |
| 630 | } |
| 631 | |
| 632 | db_subscr_purge(dbc, imsi0, false, true) --> 0 |
| 633 | |
| 634 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 635 | struct hlr_subscriber { |
| 636 | .id = 1, |
| 637 | .imsi = '123456789000000', |
| 638 | .msisdn = '543210123456789', |
| 639 | } |
| 640 | |
| 641 | db_subscr_purge(dbc, imsi0, true, false) --> 0 |
| 642 | |
| 643 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 644 | struct hlr_subscriber { |
| 645 | .id = 1, |
| 646 | .imsi = '123456789000000', |
| 647 | .msisdn = '543210123456789', |
| 648 | .ms_purged_cs = true, |
| 649 | } |
| 650 | |
| 651 | db_subscr_purge(dbc, imsi0, true, false) --> 0 |
| 652 | |
| 653 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 654 | struct hlr_subscriber { |
| 655 | .id = 1, |
| 656 | .imsi = '123456789000000', |
| 657 | .msisdn = '543210123456789', |
| 658 | .ms_purged_cs = true, |
| 659 | } |
| 660 | |
| 661 | db_subscr_purge(dbc, imsi0, false, false) --> 0 |
| 662 | |
| 663 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 664 | struct hlr_subscriber { |
| 665 | .id = 1, |
| 666 | .imsi = '123456789000000', |
| 667 | .msisdn = '543210123456789', |
| 668 | } |
| 669 | |
| 670 | db_subscr_purge(dbc, imsi0, false, false) --> 0 |
| 671 | |
| 672 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 673 | struct hlr_subscriber { |
| 674 | .id = 1, |
| 675 | .imsi = '123456789000000', |
| 676 | .msisdn = '543210123456789', |
| 677 | } |
| 678 | |
| 679 | |
| 680 | --- Purge on non-existent / invalid IMSI |
| 681 | |
| 682 | db_subscr_purge(dbc, unknown_imsi, true, true) --> -ENOENT |
| 683 | DAUC Cannot purge PS: no such subscriber: IMSI='999999999' |
| 684 | |
| 685 | db_subscr_get_by_imsi(dbc, unknown_imsi, &g_subscr) --> -ENOENT |
Neels Hofmeyr | e50121e | 2017-10-09 17:48:51 +0200 | [diff] [blame] | 686 | |
| 687 | db_subscr_purge(dbc, unknown_imsi, true, false) --> -ENOENT |
| 688 | DAUC Cannot purge CS: no such subscriber: IMSI='999999999' |
| 689 | |
| 690 | db_subscr_get_by_imsi(dbc, unknown_imsi, &g_subscr) --> -ENOENT |
Neels Hofmeyr | e50121e | 2017-10-09 17:48:51 +0200 | [diff] [blame] | 691 | |
| 692 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 693 | --- Delete non-existent / invalid IDs |
| 694 | |
| 695 | db_subscr_delete_by_id(dbc, 999) --> -ENOENT |
| 696 | DAUC Cannot delete: no such subscriber: ID=999 |
| 697 | |
| 698 | db_subscr_delete_by_id(dbc, -10) --> -ENOENT |
| 699 | DAUC Cannot delete: no such subscriber: ID=-10 |
| 700 | |
| 701 | |
| 702 | --- Delete subscribers |
| 703 | |
| 704 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 705 | struct hlr_subscriber { |
| 706 | .id = 1, |
| 707 | .imsi = '123456789000000', |
| 708 | .msisdn = '543210123456789', |
| 709 | } |
| 710 | |
| 711 | db_subscr_delete_by_id(dbc, id0) --> 0 |
| 712 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 713 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 714 | |
| 715 | db_subscr_delete_by_id(dbc, id0) --> -ENOENT |
| 716 | DAUC Cannot delete: no such subscriber: ID=1 |
| 717 | |
| 718 | db_subscr_get_by_imsi(dbc, imsi1, &g_subscr) --> 0 |
| 719 | struct hlr_subscriber { |
| 720 | .id = 2, |
| 721 | .imsi = '123456789000001', |
| 722 | } |
| 723 | |
| 724 | db_subscr_delete_by_id(dbc, id1) --> 0 |
| 725 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 726 | db_subscr_get_by_imsi(dbc, imsi1, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 727 | |
| 728 | db_subscr_get_by_imsi(dbc, imsi2, &g_subscr) --> 0 |
| 729 | struct hlr_subscriber { |
| 730 | .id = 3, |
| 731 | .imsi = '123456789000002', |
| 732 | } |
| 733 | |
| 734 | db_subscr_delete_by_id(dbc, id2) --> 0 |
| 735 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 736 | db_subscr_get_by_imsi(dbc, imsi2, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 737 | |
| 738 | db_subscr_get_by_imsi(dbc, short_imsi, &g_subscr) --> 0 |
| 739 | struct hlr_subscriber { |
| 740 | .id = 4, |
| 741 | .imsi = '123456', |
| 742 | } |
| 743 | |
| 744 | db_subscr_delete_by_id(dbc, id_short) --> 0 |
| 745 | |
Neels Hofmeyr | 9c2bbc8 | 2017-10-09 17:30:32 +0200 | [diff] [blame] | 746 | db_subscr_get_by_imsi(dbc, short_imsi, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 747 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 748 | |
| 749 | --- Create and delete subscribers with non-default nam_cs and nam_ps |
| 750 | |
| 751 | db_subscr_create(dbc, imsi0, 0x00) --> 0 |
| 752 | |
| 753 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 754 | struct hlr_subscriber { |
| 755 | .id = 1, |
| 756 | .imsi = '123456789000000', |
| 757 | .nam_cs = false, |
| 758 | .nam_ps = false, |
| 759 | } |
| 760 | |
| 761 | db_subscr_create(dbc, imsi1, DB_SUBSCR_FLAG_NAM_CS) --> 0 |
| 762 | |
| 763 | db_subscr_get_by_imsi(dbc, imsi1, &g_subscr) --> 0 |
| 764 | struct hlr_subscriber { |
| 765 | .id = 2, |
| 766 | .imsi = '123456789000001', |
| 767 | .nam_ps = false, |
| 768 | } |
| 769 | |
| 770 | db_subscr_create(dbc, imsi2, DB_SUBSCR_FLAG_NAM_PS) --> 0 |
| 771 | |
| 772 | db_subscr_get_by_imsi(dbc, imsi2, &g_subscr) --> 0 |
| 773 | struct hlr_subscriber { |
| 774 | .id = 3, |
| 775 | .imsi = '123456789000002', |
| 776 | .nam_cs = false, |
| 777 | } |
| 778 | |
| 779 | db_subscr_delete_by_id(dbc, id0) --> 0 |
| 780 | |
| 781 | db_subscr_delete_by_id(dbc, id1) --> 0 |
| 782 | |
| 783 | db_subscr_delete_by_id(dbc, id2) --> 0 |
| 784 | |
Neels Hofmeyr | 9850946 | 2017-10-09 17:28:53 +0200 | [diff] [blame] | 785 | ===== test_subscr_create_update_sel_delete: SUCCESS |
| 786 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 787 | |
| 788 | ===== test_subscr_aud |
| 789 | |
| 790 | --- Get auth data for non-existent subscriber |
| 791 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 792 | db_get_auth_data(dbc, unknown_imsi, &g_aud2g, &g_aud3g, &g_id) --> -2 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 793 | DAUC IMSI='999999999': No such subscriber |
| 794 | |
| 795 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 796 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -2 |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 797 | DAUC IMSI='123456789000000': No such subscriber |
| 798 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 799 | |
| 800 | --- Create subscriber |
| 801 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 802 | db_subscr_create(dbc, imsi0, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 803 | |
| 804 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 805 | struct hlr_subscriber { |
| 806 | .id = 1, |
| 807 | .imsi = '123456789000000', |
| 808 | } |
| 809 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 810 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 811 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 812 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 813 | |
| 814 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 815 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -ENOKEY |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 816 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 817 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 818 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 819 | |
| 820 | --- Set auth data, 2G only |
| 821 | |
| 822 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_COMP128v1, "0123456789abcdef0123456789abcdef")) --> 0 |
| 823 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 824 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 825 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 826 | |
| 827 | 2G: struct osmo_sub_auth_data { |
| 828 | .type = GSM, |
| 829 | .algo = COMP128v1, |
| 830 | .u.gsm.ki = '0123456789abcdef0123456789abcdef', |
| 831 | } |
| 832 | 3G: none |
| 833 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 834 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> 3 |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 835 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 836 | DAUC IMSI='123456789000000': Calling to generate 3 vectors |
| 837 | DAUC IMSI='123456789000000': Generated 3 vectors |
| 838 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 839 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_COMP128v1, "0123456789abcdef0123456789abcdef")) --> 0 |
| 840 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 841 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 842 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 843 | |
| 844 | 2G: struct osmo_sub_auth_data { |
| 845 | .type = GSM, |
| 846 | .algo = COMP128v1, |
| 847 | .u.gsm.ki = '0123456789abcdef0123456789abcdef', |
| 848 | } |
| 849 | 3G: none |
| 850 | |
| 851 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_COMP128v2, "BeadedBeeAced1EbbedDefacedFacade")) --> 0 |
| 852 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 853 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 854 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 855 | |
| 856 | 2G: struct osmo_sub_auth_data { |
| 857 | .type = GSM, |
| 858 | .algo = COMP128v2, |
| 859 | .u.gsm.ki = 'beadedbeeaced1ebbeddefacedfacade', |
| 860 | } |
| 861 | 3G: none |
| 862 | |
| 863 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_COMP128v3, "DeafBeddedBabeAcceededFadedDecaf")) --> 0 |
| 864 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 865 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 866 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 867 | |
| 868 | 2G: struct osmo_sub_auth_data { |
| 869 | .type = GSM, |
| 870 | .algo = COMP128v3, |
| 871 | .u.gsm.ki = 'deafbeddedbabeacceededfadeddecaf', |
| 872 | } |
| 873 | 3G: none |
| 874 | |
Harald Welte | 829713a | 2023-05-30 16:57:27 +0200 | [diff] [blame^] | 875 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_XOR_2G, "CededEffacedAceFacedBadFadedBeef")) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 876 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 877 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 878 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 879 | |
| 880 | 2G: struct osmo_sub_auth_data { |
| 881 | .type = GSM, |
Harald Welte | 829713a | 2023-05-30 16:57:27 +0200 | [diff] [blame^] | 882 | .algo = XOR-2G, |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 883 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 884 | } |
| 885 | 3G: none |
| 886 | |
| 887 | |
| 888 | --- Remove 2G auth data |
| 889 | |
| 890 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_NONE, NULL)) --> 0 |
| 891 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 892 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 893 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 894 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 895 | |
| 896 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 897 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -ENOKEY |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 898 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 899 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 900 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 901 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_NONE, NULL)) --> -ENOENT |
| 902 | |
Harald Welte | 829713a | 2023-05-30 16:57:27 +0200 | [diff] [blame^] | 903 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_XOR_2G, "CededEffacedAceFacedBadFadedBeef")) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 904 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 905 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 906 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 907 | |
| 908 | 2G: struct osmo_sub_auth_data { |
| 909 | .type = GSM, |
Harald Welte | 829713a | 2023-05-30 16:57:27 +0200 | [diff] [blame^] | 910 | .algo = XOR-2G, |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 911 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 912 | } |
| 913 | 3G: none |
| 914 | |
| 915 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_NONE, "f000000000000f00000000000f000000")) --> 0 |
| 916 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 917 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 918 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 919 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 920 | |
| 921 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 922 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -ENOKEY |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 923 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 924 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 925 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 926 | |
| 927 | --- Set auth data, 3G only |
| 928 | |
| 929 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", true, "C01ffedC1cadaeAc1d1f1edAcac1aB0a", 5)) --> 0 |
| 930 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 931 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 932 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 933 | |
| 934 | 2G: none |
| 935 | 3G: struct osmo_sub_auth_data { |
| 936 | .type = UMTS, |
| 937 | .algo = MILENAGE, |
| 938 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 939 | .u.umts.opc_is_op = 1, |
| 940 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 941 | .u.umts.amf = '0000', |
| 942 | .u.umts.ind_bitlen = 5, |
| 943 | } |
| 944 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 945 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> 3 |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 946 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 947 | DAUC IMSI='123456789000000': Calling to generate 3 vectors |
| 948 | DAUC IMSI='123456789000000': Generated 3 vectors |
| 949 | DAUC IMSI='123456789000000': Updating SQN=0 in DB |
| 950 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 951 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", true, "C01ffedC1cadaeAc1d1f1edAcac1aB0a", 5)) --> 0 |
| 952 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 953 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 954 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 955 | |
| 956 | 2G: none |
| 957 | 3G: struct osmo_sub_auth_data { |
| 958 | .type = UMTS, |
| 959 | .algo = MILENAGE, |
| 960 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 961 | .u.umts.opc_is_op = 1, |
| 962 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 963 | .u.umts.amf = '0000', |
| 964 | .u.umts.ind_bitlen = 5, |
| 965 | } |
| 966 | |
| 967 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "Deaf0ff1ceD0d0DabbedD1ced1ceF00d", true, "F1bbed0afD0eF0bD0ffed0ddF1fe0b0e", 0)) --> 0 |
| 968 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 969 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 970 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 971 | |
| 972 | 2G: none |
| 973 | 3G: struct osmo_sub_auth_data { |
| 974 | .type = UMTS, |
| 975 | .algo = MILENAGE, |
| 976 | .u.umts.opc = 'deaf0ff1ced0d0dabbedd1ced1cef00d', |
| 977 | .u.umts.opc_is_op = 1, |
| 978 | .u.umts.k = 'f1bbed0afd0ef0bd0ffed0ddf1fe0b0e', |
| 979 | .u.umts.amf = '0000', |
| 980 | } |
| 981 | |
| 982 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", false, "DeafBeddedBabeAcceededFadedDecaf", OSMO_MILENAGE_IND_BITLEN_MAX)) --> 0 |
| 983 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 984 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 985 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 986 | |
| 987 | 2G: none |
| 988 | 3G: struct osmo_sub_auth_data { |
| 989 | .type = UMTS, |
| 990 | .algo = MILENAGE, |
| 991 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 992 | .u.umts.opc_is_op = 0, |
| 993 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 994 | .u.umts.amf = '0000', |
| 995 | .u.umts.ind_bitlen = 28, |
| 996 | } |
| 997 | |
| 998 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "CededEffacedAceFacedBadFadedBeef", false, "BeefedCafeFaceAcedAddedDecadeFee", 5)) --> 0 |
| 999 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1000 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1001 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1002 | |
| 1003 | 2G: none |
| 1004 | 3G: struct osmo_sub_auth_data { |
| 1005 | .type = UMTS, |
| 1006 | .algo = MILENAGE, |
| 1007 | .u.umts.opc = 'cededeffacedacefacedbadfadedbeef', |
| 1008 | .u.umts.opc_is_op = 0, |
| 1009 | .u.umts.k = 'beefedcafefaceacedaddeddecadefee', |
| 1010 | .u.umts.amf = '0000', |
| 1011 | .u.umts.ind_bitlen = 5, |
| 1012 | } |
| 1013 | |
| 1014 | |
| 1015 | --- Remove 3G auth data |
| 1016 | |
| 1017 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_NONE, NULL, false, NULL, 0)) --> 0 |
| 1018 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 1019 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1020 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1021 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1022 | |
| 1023 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 1024 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -ENOKEY |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 1025 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1026 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1027 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1028 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_NONE, NULL, false, NULL, 0)) --> -ENOENT |
| 1029 | |
| 1030 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "CededEffacedAceFacedBadFadedBeef", false, "BeefedCafeFaceAcedAddedDecadeFee", 5)) --> 0 |
| 1031 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1032 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1033 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1034 | |
| 1035 | 2G: none |
| 1036 | 3G: struct osmo_sub_auth_data { |
| 1037 | .type = UMTS, |
| 1038 | .algo = MILENAGE, |
| 1039 | .u.umts.opc = 'cededeffacedacefacedbadfadedbeef', |
| 1040 | .u.umts.opc_is_op = 0, |
| 1041 | .u.umts.k = 'beefedcafefaceacedaddeddecadefee', |
| 1042 | .u.umts.amf = '0000', |
| 1043 | .u.umts.ind_bitlen = 5, |
| 1044 | } |
| 1045 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 1046 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> 3 |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 1047 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1048 | DAUC IMSI='123456789000000': Calling to generate 3 vectors |
| 1049 | DAUC IMSI='123456789000000': Generated 3 vectors |
| 1050 | DAUC IMSI='123456789000000': Updating SQN=0 in DB |
| 1051 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1052 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_NONE, "asdfasdfasd", false, "asdfasdfasdf", 99999)) --> 0 |
| 1053 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 1054 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1055 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1056 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1057 | |
| 1058 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 1059 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -ENOKEY |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 1060 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1061 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1062 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1063 | |
| 1064 | --- Set auth data, 2G and 3G |
| 1065 | |
| 1066 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_COMP128v3, "CededEffacedAceFacedBadFadedBeef")) --> 0 |
| 1067 | |
| 1068 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", false, "DeafBeddedBabeAcceededFadedDecaf", 5)) --> 0 |
| 1069 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1070 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1071 | |
| 1072 | 2G: struct osmo_sub_auth_data { |
| 1073 | .type = GSM, |
| 1074 | .algo = COMP128v3, |
| 1075 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1076 | } |
| 1077 | 3G: struct osmo_sub_auth_data { |
| 1078 | .type = UMTS, |
| 1079 | .algo = MILENAGE, |
| 1080 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1081 | .u.umts.opc_is_op = 0, |
| 1082 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1083 | .u.umts.amf = '0000', |
| 1084 | .u.umts.ind_bitlen = 5, |
| 1085 | } |
| 1086 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 1087 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> 3 |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 1088 | DAUC IMSI='123456789000000': Calling to generate 3 vectors |
| 1089 | DAUC IMSI='123456789000000': Generated 3 vectors |
| 1090 | DAUC IMSI='123456789000000': Updating SQN=0 in DB |
| 1091 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1092 | |
| 1093 | --- Set invalid auth data |
| 1094 | |
| 1095 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(99999, "f000000000000f00000000000f000000")) --> -EINVAL |
| 1096 | DAUC Cannot update auth tokens: Unknown auth algo: 99999 |
| 1097 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1098 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1099 | |
| 1100 | 2G: struct osmo_sub_auth_data { |
| 1101 | .type = GSM, |
| 1102 | .algo = COMP128v3, |
| 1103 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1104 | } |
| 1105 | 3G: struct osmo_sub_auth_data { |
| 1106 | .type = UMTS, |
| 1107 | .algo = MILENAGE, |
| 1108 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1109 | .u.umts.opc_is_op = 0, |
| 1110 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1111 | .u.umts.amf = '0000', |
| 1112 | .u.umts.ind_bitlen = 5, |
| 1113 | } |
| 1114 | |
Harald Welte | 829713a | 2023-05-30 16:57:27 +0200 | [diff] [blame^] | 1115 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_XOR_2G, "f000000000000f00000000000f000000f00000000")) --> -EINVAL |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1116 | DAUC Cannot update auth tokens: Invalid KI: 'f000000000000f00000000000f000000f00000000' |
| 1117 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1118 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1119 | |
| 1120 | 2G: struct osmo_sub_auth_data { |
| 1121 | .type = GSM, |
| 1122 | .algo = COMP128v3, |
| 1123 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1124 | } |
| 1125 | 3G: struct osmo_sub_auth_data { |
| 1126 | .type = UMTS, |
| 1127 | .algo = MILENAGE, |
| 1128 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1129 | .u.umts.opc_is_op = 0, |
| 1130 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1131 | .u.umts.amf = '0000', |
| 1132 | .u.umts.ind_bitlen = 5, |
| 1133 | } |
| 1134 | |
Harald Welte | 829713a | 2023-05-30 16:57:27 +0200 | [diff] [blame^] | 1135 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_XOR_2G, "f00")) --> -EINVAL |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1136 | DAUC Cannot update auth tokens: Invalid KI: 'f00' |
| 1137 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1138 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1139 | |
| 1140 | 2G: struct osmo_sub_auth_data { |
| 1141 | .type = GSM, |
| 1142 | .algo = COMP128v3, |
| 1143 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1144 | } |
| 1145 | 3G: struct osmo_sub_auth_data { |
| 1146 | .type = UMTS, |
| 1147 | .algo = MILENAGE, |
| 1148 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1149 | .u.umts.opc_is_op = 0, |
| 1150 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1151 | .u.umts.amf = '0000', |
| 1152 | .u.umts.ind_bitlen = 5, |
| 1153 | } |
| 1154 | |
| 1155 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_MILENAGE, "0123456789abcdef0123456789abcdef")) --> -EINVAL |
| 1156 | DAUC Cannot update auth tokens: auth algo not suited for 2G: MILENAGE |
| 1157 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1158 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1159 | |
| 1160 | 2G: struct osmo_sub_auth_data { |
| 1161 | .type = GSM, |
| 1162 | .algo = COMP128v3, |
| 1163 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1164 | } |
| 1165 | 3G: struct osmo_sub_auth_data { |
| 1166 | .type = UMTS, |
| 1167 | .algo = MILENAGE, |
| 1168 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1169 | .u.umts.opc_is_op = 0, |
| 1170 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1171 | .u.umts.amf = '0000', |
| 1172 | .u.umts.ind_bitlen = 5, |
| 1173 | } |
| 1174 | |
| 1175 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "0f000000000000f00000000000f000000", false, "f000000000000f00000000000f000000", 5)) --> -EINVAL |
| 1176 | DAUC Cannot update auth tokens: Invalid OP/OPC: '0f000000000000f00000000000f000000' |
| 1177 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1178 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1179 | |
| 1180 | 2G: struct osmo_sub_auth_data { |
| 1181 | .type = GSM, |
| 1182 | .algo = COMP128v3, |
| 1183 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1184 | } |
| 1185 | 3G: struct osmo_sub_auth_data { |
| 1186 | .type = UMTS, |
| 1187 | .algo = MILENAGE, |
| 1188 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1189 | .u.umts.opc_is_op = 0, |
| 1190 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1191 | .u.umts.amf = '0000', |
| 1192 | .u.umts.ind_bitlen = 5, |
| 1193 | } |
| 1194 | |
| 1195 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "f000000000000f00000000000f000000", false, "000000000000f00000000000f000000", 5)) --> -EINVAL |
| 1196 | DAUC Cannot update auth tokens: Invalid K: '000000000000f00000000000f000000' |
| 1197 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1198 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1199 | |
| 1200 | 2G: struct osmo_sub_auth_data { |
| 1201 | .type = GSM, |
| 1202 | .algo = COMP128v3, |
| 1203 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1204 | } |
| 1205 | 3G: struct osmo_sub_auth_data { |
| 1206 | .type = UMTS, |
| 1207 | .algo = MILENAGE, |
| 1208 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1209 | .u.umts.opc_is_op = 0, |
| 1210 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1211 | .u.umts.amf = '0000', |
| 1212 | .u.umts.ind_bitlen = 5, |
| 1213 | } |
| 1214 | |
| 1215 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "f000000000000f00000000000f000000", false, "f000000000000f00000000000f000000", OSMO_MILENAGE_IND_BITLEN_MAX + 1)) --> -EINVAL |
| 1216 | DAUC Cannot update auth tokens: Invalid ind_bitlen: 29 |
| 1217 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1218 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1219 | |
| 1220 | 2G: struct osmo_sub_auth_data { |
| 1221 | .type = GSM, |
| 1222 | .algo = COMP128v3, |
| 1223 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1224 | } |
| 1225 | 3G: struct osmo_sub_auth_data { |
| 1226 | .type = UMTS, |
| 1227 | .algo = MILENAGE, |
| 1228 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1229 | .u.umts.opc_is_op = 0, |
| 1230 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1231 | .u.umts.amf = '0000', |
| 1232 | .u.umts.ind_bitlen = 5, |
| 1233 | } |
| 1234 | |
| 1235 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "X000000000000f00000000000f000000", false, "f000000000000f00000000000f000000", 5)) --> -EINVAL |
| 1236 | DAUC Cannot update auth tokens: Invalid OP/OPC: 'X000000000000f00000000000f000000' |
| 1237 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1238 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1239 | |
| 1240 | 2G: struct osmo_sub_auth_data { |
| 1241 | .type = GSM, |
| 1242 | .algo = COMP128v3, |
| 1243 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1244 | } |
| 1245 | 3G: struct osmo_sub_auth_data { |
| 1246 | .type = UMTS, |
| 1247 | .algo = MILENAGE, |
| 1248 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1249 | .u.umts.opc_is_op = 0, |
| 1250 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1251 | .u.umts.amf = '0000', |
| 1252 | .u.umts.ind_bitlen = 5, |
| 1253 | } |
| 1254 | |
| 1255 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "f000000000000f00000000000f000000", false, "f000000000000 f00000000000 f000000", 5)) --> -EINVAL |
| 1256 | DAUC Cannot update auth tokens: Invalid K: 'f000000000000 f00000000000 f000000' |
| 1257 | |
Neels Hofmeyr | 57a8792 | 2017-10-09 17:51:13 +0200 | [diff] [blame] | 1258 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1259 | |
| 1260 | 2G: struct osmo_sub_auth_data { |
| 1261 | .type = GSM, |
| 1262 | .algo = COMP128v3, |
| 1263 | .u.gsm.ki = 'cededeffacedacefacedbadfadedbeef', |
| 1264 | } |
| 1265 | 3G: struct osmo_sub_auth_data { |
| 1266 | .type = UMTS, |
| 1267 | .algo = MILENAGE, |
| 1268 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1269 | .u.umts.opc_is_op = 0, |
| 1270 | .u.umts.k = 'deafbeddedbabeacceededfadeddecaf', |
| 1271 | .u.umts.amf = '0000', |
| 1272 | .u.umts.ind_bitlen = 5, |
| 1273 | } |
| 1274 | |
| 1275 | |
| 1276 | --- Delete subscriber |
| 1277 | |
| 1278 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 1279 | struct hlr_subscriber { |
| 1280 | .id = 1, |
| 1281 | .imsi = '123456789000000', |
| 1282 | } |
| 1283 | |
| 1284 | db_subscr_delete_by_id(dbc, id) --> 0 |
| 1285 | |
| 1286 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1287 | |
| 1288 | |
| 1289 | --- Re-add subscriber and verify auth data didn't come back |
| 1290 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 1291 | db_subscr_create(dbc, imsi0, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1292 | |
| 1293 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 1294 | struct hlr_subscriber { |
| 1295 | .id = 1, |
| 1296 | .imsi = '123456789000000', |
| 1297 | } |
| 1298 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 1299 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1300 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1301 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1302 | |
| 1303 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 1304 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -ENOKEY |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 1305 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1306 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1307 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1308 | db_subscr_delete_by_id(dbc, id) --> 0 |
| 1309 | |
| 1310 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1311 | |
Harald Welte | 06f5af2 | 2019-08-21 20:01:31 +0200 | [diff] [blame] | 1312 | db_get_auc(dbc, imsi0, 3, vec, N_VECTORS, NULL, NULL, false) --> -2 |
Neels Hofmeyr | 2dee60e | 2017-11-23 15:27:50 +0100 | [diff] [blame] | 1313 | DAUC IMSI='123456789000000': No such subscriber |
| 1314 | |
Neels Hofmeyr | 1332a17 | 2017-10-10 02:25:00 +0200 | [diff] [blame] | 1315 | ===== test_subscr_aud: SUCCESS |
| 1316 | |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1317 | |
Oliver Smith | 6401b90 | 2019-07-24 11:32:45 +0200 | [diff] [blame] | 1318 | ===== test_subscr_aud_invalid_len |
| 1319 | |
| 1320 | --- Create subscriber |
| 1321 | |
| 1322 | db_subscr_create(dbc, imsi0, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
| 1323 | |
| 1324 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 1325 | struct hlr_subscriber { |
| 1326 | .id = 1, |
| 1327 | .imsi = '123456789000000', |
| 1328 | } |
| 1329 | |
| 1330 | |
| 1331 | --- Set auth data, 2G only, with invalid Ki length |
| 1332 | |
| 1333 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_COMP128v1, "0123456789abcdef0123456789abcdef")) --> 0 |
| 1334 | |
| 1335 | raw SQL: UPDATE auc_2g SET ki = '0123456789abcdef0123456789abcde' |
| 1336 | sqlite3_prepare_v2(dbc->db, sql, -1, &stmt, NULL) --> SQLITE_OK |
| 1337 | |
| 1338 | sqlite3_step(stmt) --> SQLITE_DONE |
| 1339 | |
Pau Espin Pedrol | 28f0774 | 2019-08-13 11:59:01 +0200 | [diff] [blame] | 1340 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Oliver Smith | 6401b90 | 2019-07-24 11:32:45 +0200 | [diff] [blame] | 1341 | DAUC IMSI='123456789000000': Error reading Ki, expected length 16 but has length 15 |
| 1342 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1343 | |
| 1344 | |
| 1345 | |
| 1346 | --- Remove 2G auth data |
| 1347 | |
| 1348 | db_subscr_update_aud_by_id(dbc, id, mk_aud_2g(OSMO_AUTH_ALG_NONE, NULL)) --> 0 |
| 1349 | |
| 1350 | |
| 1351 | --- Set auth data, 3G only, with invalid K length |
| 1352 | |
| 1353 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", true, "C01ffedC1cadaeAc1d1f1edAcac1aB0a", 5)) --> 0 |
| 1354 | |
| 1355 | raw SQL: UPDATE auc_3g SET k = 'C01ffedC1cadaeAc1d1f1edAcac1aB0' |
| 1356 | sqlite3_prepare_v2(dbc->db, sql, -1, &stmt, NULL) --> SQLITE_OK |
| 1357 | |
| 1358 | sqlite3_step(stmt) --> SQLITE_DONE |
| 1359 | |
| 1360 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -5 |
| 1361 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1362 | DAUC IMSI='123456789000000': Error reading K, expected length 16 but has length 15 |
| 1363 | |
| 1364 | |
| 1365 | |
| 1366 | --- Set auth data, 3G only, with invalid OP length |
| 1367 | |
| 1368 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", true, "C01ffedC1cadaeAc1d1f1edAcac1aB0a", 5)) --> 0 |
| 1369 | |
| 1370 | raw SQL: UPDATE auc_3g SET op = 'BeefedCafeFaceAcedAddedDecadeFe' |
| 1371 | sqlite3_prepare_v2(dbc->db, sql, -1, &stmt, NULL) --> SQLITE_OK |
| 1372 | |
| 1373 | sqlite3_step(stmt) --> SQLITE_DONE |
| 1374 | |
| 1375 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -5 |
| 1376 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1377 | DAUC IMSI='123456789000000': Error reading OP, expected length 16 but has length 15 |
| 1378 | |
| 1379 | |
| 1380 | |
| 1381 | --- Set auth data, 3G only, with invalid OPC length |
| 1382 | |
| 1383 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", false, "C01ffedC1cadaeAc1d1f1edAcac1aB0a", 5)) --> 0 |
| 1384 | |
| 1385 | raw SQL: UPDATE auc_3g SET opc = 'BeefedCafeFaceAcedAddedDecadeFe' |
| 1386 | sqlite3_prepare_v2(dbc->db, sql, -1, &stmt, NULL) --> SQLITE_OK |
| 1387 | |
| 1388 | sqlite3_step(stmt) --> SQLITE_DONE |
| 1389 | |
| 1390 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -5 |
| 1391 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1392 | DAUC IMSI='123456789000000': Error reading OPC, expected length 16 but has length 15 |
| 1393 | |
| 1394 | |
| 1395 | |
| 1396 | --- Delete subscriber |
| 1397 | |
| 1398 | db_subscr_delete_by_id(dbc, id) --> 0 |
| 1399 | |
| 1400 | ===== test_subscr_aud_invalid_len: SUCCESS |
| 1401 | |
| 1402 | |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1403 | ===== test_subscr_sqn |
| 1404 | |
| 1405 | --- Set SQN for unknown subscriber |
| 1406 | |
| 1407 | db_update_sqn(dbc, 99, 999) --> -ENOENT |
| 1408 | DAUC Cannot update SQN for subscriber ID=99: no auc_3g entry for such subscriber |
| 1409 | |
| 1410 | db_subscr_get_by_id(dbc, 99, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1411 | |
| 1412 | db_update_sqn(dbc, 9999, 99) --> -ENOENT |
| 1413 | DAUC Cannot update SQN for subscriber ID=9999: no auc_3g entry for such subscriber |
| 1414 | |
| 1415 | db_subscr_get_by_id(dbc, 9999, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1416 | |
| 1417 | |
| 1418 | --- Create subscriber |
| 1419 | |
Oliver Smith | cd2af5e | 2019-03-06 13:17:39 +0100 | [diff] [blame] | 1420 | db_subscr_create(dbc, imsi0, DB_SUBSCR_FLAG_NAM_CS | DB_SUBSCR_FLAG_NAM_PS) --> 0 |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1421 | |
| 1422 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 1423 | struct hlr_subscriber { |
| 1424 | .id = 1, |
| 1425 | .imsi = '123456789000000', |
| 1426 | } |
| 1427 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 1428 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1429 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1430 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1431 | |
| 1432 | |
| 1433 | |
| 1434 | --- Set SQN, but no 3G auth data present |
| 1435 | |
| 1436 | db_update_sqn(dbc, id, 123) --> -ENOENT |
| 1437 | DAUC Cannot update SQN for subscriber ID=1: no auc_3g entry for such subscriber |
| 1438 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 1439 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1440 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1441 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1442 | |
| 1443 | |
| 1444 | db_update_sqn(dbc, id, 543) --> -ENOENT |
| 1445 | DAUC Cannot update SQN for subscriber ID=1: no auc_3g entry for such subscriber |
| 1446 | |
Ruben Undheim | 8b860e5 | 2018-11-16 08:47:26 +0100 | [diff] [blame] | 1447 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> -ENOKEY |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1448 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1449 | DAUC IMSI='123456789000000': No 3G Auth Data |
| 1450 | |
| 1451 | |
| 1452 | |
| 1453 | --- Set auth 3G data |
| 1454 | |
| 1455 | db_subscr_update_aud_by_id(dbc, id, mk_aud_3g(OSMO_AUTH_ALG_MILENAGE, "BeefedCafeFaceAcedAddedDecadeFee", true, "C01ffedC1cadaeAc1d1f1edAcac1aB0a", 5)) --> 0 |
| 1456 | |
| 1457 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1458 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1459 | |
| 1460 | 2G: none |
| 1461 | 3G: struct osmo_sub_auth_data { |
| 1462 | .type = UMTS, |
| 1463 | .algo = MILENAGE, |
| 1464 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1465 | .u.umts.opc_is_op = 1, |
| 1466 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1467 | .u.umts.amf = '0000', |
| 1468 | .u.umts.ind_bitlen = 5, |
| 1469 | } |
| 1470 | |
| 1471 | |
| 1472 | --- Set SQN |
| 1473 | |
| 1474 | db_update_sqn(dbc, id, 23315) --> 0 |
| 1475 | |
| 1476 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1477 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1478 | |
| 1479 | 2G: none |
| 1480 | 3G: struct osmo_sub_auth_data { |
| 1481 | .type = UMTS, |
| 1482 | .algo = MILENAGE, |
| 1483 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1484 | .u.umts.opc_is_op = 1, |
| 1485 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1486 | .u.umts.amf = '0000', |
| 1487 | .u.umts.sqn = 23315, |
| 1488 | .u.umts.sqn = 0x5b13, |
| 1489 | .u.umts.ind_bitlen = 5, |
| 1490 | } |
| 1491 | |
| 1492 | db_update_sqn(dbc, id, 23315) --> 0 |
| 1493 | |
| 1494 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1495 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1496 | |
| 1497 | 2G: none |
| 1498 | 3G: struct osmo_sub_auth_data { |
| 1499 | .type = UMTS, |
| 1500 | .algo = MILENAGE, |
| 1501 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1502 | .u.umts.opc_is_op = 1, |
| 1503 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1504 | .u.umts.amf = '0000', |
| 1505 | .u.umts.sqn = 23315, |
| 1506 | .u.umts.sqn = 0x5b13, |
| 1507 | .u.umts.ind_bitlen = 5, |
| 1508 | } |
| 1509 | |
| 1510 | db_update_sqn(dbc, id, 423) --> 0 |
| 1511 | |
| 1512 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1513 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1514 | |
| 1515 | 2G: none |
| 1516 | 3G: struct osmo_sub_auth_data { |
| 1517 | .type = UMTS, |
| 1518 | .algo = MILENAGE, |
| 1519 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1520 | .u.umts.opc_is_op = 1, |
| 1521 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1522 | .u.umts.amf = '0000', |
| 1523 | .u.umts.sqn = 423, |
| 1524 | .u.umts.sqn = 0x1a7, |
| 1525 | .u.umts.ind_bitlen = 5, |
| 1526 | } |
| 1527 | |
| 1528 | |
| 1529 | --- Set SQN: thru uint64_t range, using the int64_t SQLite bind |
| 1530 | |
| 1531 | db_update_sqn(dbc, id, 0) --> 0 |
| 1532 | |
| 1533 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1534 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1535 | |
| 1536 | 2G: none |
| 1537 | 3G: struct osmo_sub_auth_data { |
| 1538 | .type = UMTS, |
| 1539 | .algo = MILENAGE, |
| 1540 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1541 | .u.umts.opc_is_op = 1, |
| 1542 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1543 | .u.umts.amf = '0000', |
| 1544 | .u.umts.ind_bitlen = 5, |
| 1545 | } |
| 1546 | |
| 1547 | db_update_sqn(dbc, id, INT64_MAX) --> 0 |
| 1548 | |
| 1549 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1550 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1551 | |
| 1552 | 2G: none |
| 1553 | 3G: struct osmo_sub_auth_data { |
| 1554 | .type = UMTS, |
| 1555 | .algo = MILENAGE, |
| 1556 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1557 | .u.umts.opc_is_op = 1, |
| 1558 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1559 | .u.umts.amf = '0000', |
| 1560 | .u.umts.sqn = 9223372036854775807, |
| 1561 | .u.umts.sqn = 0x7fffffffffffffff, |
| 1562 | .u.umts.ind_bitlen = 5, |
| 1563 | } |
| 1564 | |
| 1565 | db_update_sqn(dbc, id, INT64_MIN) --> 0 |
| 1566 | |
| 1567 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1568 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1569 | |
| 1570 | 2G: none |
| 1571 | 3G: struct osmo_sub_auth_data { |
| 1572 | .type = UMTS, |
| 1573 | .algo = MILENAGE, |
| 1574 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1575 | .u.umts.opc_is_op = 1, |
| 1576 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1577 | .u.umts.amf = '0000', |
| 1578 | .u.umts.sqn = 9223372036854775808, |
| 1579 | .u.umts.sqn = 0x8000000000000000, |
| 1580 | .u.umts.ind_bitlen = 5, |
| 1581 | } |
| 1582 | |
| 1583 | db_update_sqn(dbc, id, UINT64_MAX) --> 0 |
| 1584 | |
| 1585 | db_get_auth_data(dbc, imsi0, &g_aud2g, &g_aud3g, &g_id) --> 0 |
| 1586 | DAUC IMSI='123456789000000': No 2G Auth Data |
| 1587 | |
| 1588 | 2G: none |
| 1589 | 3G: struct osmo_sub_auth_data { |
| 1590 | .type = UMTS, |
| 1591 | .algo = MILENAGE, |
| 1592 | .u.umts.opc = 'beefedcafefaceacedaddeddecadefee', |
| 1593 | .u.umts.opc_is_op = 1, |
| 1594 | .u.umts.k = 'c01ffedc1cadaeac1d1f1edacac1ab0a', |
| 1595 | .u.umts.amf = '0000', |
| 1596 | .u.umts.sqn = 18446744073709551615, |
| 1597 | .u.umts.sqn = 0xffffffffffffffff, |
| 1598 | .u.umts.ind_bitlen = 5, |
| 1599 | } |
| 1600 | |
| 1601 | |
| 1602 | --- Delete subscriber |
| 1603 | |
| 1604 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> 0 |
| 1605 | struct hlr_subscriber { |
| 1606 | .id = 1, |
| 1607 | .imsi = '123456789000000', |
| 1608 | } |
| 1609 | |
| 1610 | db_subscr_delete_by_id(dbc, id) --> 0 |
| 1611 | |
| 1612 | db_subscr_get_by_imsi(dbc, imsi0, &g_subscr) --> -ENOENT |
Neels Hofmeyr | 1cbdb70 | 2017-10-09 23:03:57 +0200 | [diff] [blame] | 1613 | |
| 1614 | ===== test_subscr_sqn: SUCCESS |
| 1615 | |
Neels Hofmeyr | 3f9d197 | 2019-12-12 04:04:53 +0100 | [diff] [blame] | 1616 | |
| 1617 | ===== test_ind |
| 1618 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1619 | |
| 1620 | "msc-23\0" ind = 1 |
| 1621 | |
| 1622 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1623 | |
| 1624 | "sgsn-11\0" ind = 2 |
| 1625 | |
| 1626 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1627 | |
| 1628 | "msc-42\0" ind = 3 |
| 1629 | |
| 1630 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1631 | |
| 1632 | "sgsn-22\0" ind = 4 |
| 1633 | |
| 1634 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1635 | |
| 1636 | "msc-0x17\0" ind = 5 |
| 1637 | |
| 1638 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1639 | |
| 1640 | "sgsn-0xaa\0" ind = 6 |
| 1641 | |
| 1642 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1643 | |
| 1644 | "msc-42\0" ind = 3 |
| 1645 | |
| 1646 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1647 | |
| 1648 | "sgsn-22\0" ind = 4 |
| 1649 | |
| 1650 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1651 | |
| 1652 | "msc-0x17\0" ind = 5 |
| 1653 | |
| 1654 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1655 | |
| 1656 | "sgsn-0xaa\0" ind = 6 |
| 1657 | |
| 1658 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1659 | |
| 1660 | "sgsn-0xbb\0" ind = 7 |
| 1661 | |
| 1662 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1663 | |
| 1664 | "msc-0x2a\0" ind = 8 |
| 1665 | |
| 1666 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1667 | |
| 1668 | "msc-42\0" ind = 3 |
| 1669 | |
| 1670 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1671 | |
| 1672 | "sgsn-22\0" ind = 4 |
| 1673 | |
| 1674 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1675 | |
| 1676 | "msc-23\0" ind = 1 |
| 1677 | |
| 1678 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1679 | |
| 1680 | "sgsn-11\0" ind = 2 |
| 1681 | |
| 1682 | db_ind_del(dbc, &vlr) --> 0 |
| 1683 | |
| 1684 | "msc-0x17\0" ind deleted |
| 1685 | |
| 1686 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1687 | |
| 1688 | "msc-0x2a\0" ind = 8 |
| 1689 | |
| 1690 | db_ind(dbc, &vlr, &ind) --> 0 |
| 1691 | |
| 1692 | "any-unknown\0" ind = 9 |
| 1693 | |
| 1694 | ===== test_ind: SUCCESS |
| 1695 | |