Pau Espin Pedrol | e913e37 | 2017-08-24 17:21:51 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Pau Espin Pedrol | dfe38ad | 2017-11-09 13:57:39 +0100 | [diff] [blame] | 2 | from osmo_gsm_tester.testenv import * |
Pau Espin Pedrol | e913e37 | 2017-08-24 17:21:51 +0200 | [diff] [blame] | 3 | |
| 4 | hlr = suite.hlr() |
| 5 | bts = suite.bts() |
| 6 | mgcpgw = suite.mgcpgw(bts_ip=bts.remote_addr()) |
Pau Espin Pedrol | 386b78d | 2017-11-09 13:02:09 +0100 | [diff] [blame] | 7 | mgw_bsc = suite.mgw() |
Pau Espin Pedrol | e913e37 | 2017-08-24 17:21:51 +0200 | [diff] [blame] | 8 | msc = suite.msc(hlr, mgcpgw) |
Pau Espin Pedrol | 386b78d | 2017-11-09 13:02:09 +0100 | [diff] [blame] | 9 | bsc = suite.bsc(msc, mgw_bsc) |
Pau Espin Pedrol | e913e37 | 2017-08-24 17:21:51 +0200 | [diff] [blame] | 10 | stp = suite.stp() |
| 11 | ms = suite.modem() |
| 12 | |
| 13 | print('start network...') |
| 14 | msc.set_authentication(True) |
Pau Espin Pedrol | abd556a | 2017-09-04 16:26:08 +0200 | [diff] [blame] | 15 | msc.set_encryption('a5_1') |
| 16 | bsc.set_encryption('a5_1') |
Pau Espin Pedrol | e913e37 | 2017-08-24 17:21:51 +0200 | [diff] [blame] | 17 | hlr.start() |
| 18 | stp.start() |
| 19 | msc.start() |
| 20 | mgcpgw.start() |
Pau Espin Pedrol | 386b78d | 2017-11-09 13:02:09 +0100 | [diff] [blame] | 21 | mgw_bsc.start() |
Pau Espin Pedrol | e913e37 | 2017-08-24 17:21:51 +0200 | [diff] [blame] | 22 | bsc.bts_add(bts) |
| 23 | bsc.start() |
| 24 | bts.start() |
| 25 | |
| 26 | ms.log_info() |
| 27 | good_ki = ms.ki() |
| 28 | bad_ki = ("%1X" % (int(good_ki[0], 16) ^ 0x01)) + good_ki[1:] |
| 29 | |
| 30 | print('KI changed: ' + good_ki + " => " + bad_ki) |
| 31 | ms.set_ki(bad_ki) |
| 32 | hlr.subscriber_add(ms) |
| 33 | print('Attempt connection with wrong KI...') |
| 34 | ms.connect(msc.mcc_mnc()) |
| 35 | |
Pau Espin Pedrol | 6680ef2 | 2017-09-11 01:24:05 +0200 | [diff] [blame] | 36 | sleep(40) # TODO: read pcap or CTRL interface and look for Rejected? (gsm_a.dtap.msg_mm_type == 0x04) |
Pau Espin Pedrol | e913e37 | 2017-08-24 17:21:51 +0200 | [diff] [blame] | 37 | print('Asserting modem did not register') |
| 38 | # FIXME: this can fail because ofono qmi signals registered before being accepted by network. See OS#2458 |
| 39 | # assert not ms.is_connected(msc.mcc_mnc()) |
| 40 | assert not msc.subscriber_attached(ms) |
| 41 | |
| 42 | hlr.subscriber_delete(ms) |
| 43 | print('KI changed: ' + bad_ki + " => " + good_ki) |
| 44 | ms.set_ki(good_ki) |
| 45 | hlr.subscriber_add(ms, ms.msisdn) |
| 46 | print('Attempt connection with correct KI...') |
| 47 | ms.connect(msc.mcc_mnc()) |
| 48 | wait(ms.is_connected, msc.mcc_mnc()) |
| 49 | wait(msc.subscriber_attached, ms) |