Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | # This test checks following use-cases while in 'closed' policy: |
| 4 | # * SMPP interface of SMSC accepts SMPP clients (ESMEs) with password previously |
| 5 | # defined in its configuration file. |
| 6 | # * SMPP interface of SMSC rejects ESMEs with known system id but wrong password. |
| 7 | # * SMPP interface of SMSC rejects ESEMs with unknown system id |
| 8 | |
Pau Espin Pedrol | dfe38ad | 2017-11-09 13:57:39 +0100 | [diff] [blame] | 9 | from osmo_gsm_tester.testenv import * |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 10 | |
| 11 | SMPP_ESME_RINVPASWD = 0x0000000E |
| 12 | SMPP_ESME_RINVSYSID = 0x0000000F |
| 13 | |
Pau Espin Pedrol | 4385780 | 2018-09-13 15:07:27 +0200 | [diff] [blame] | 14 | hlr = suite.hlr() |
| 15 | bts = suite.bts() |
| 16 | mgw_msc = suite.mgw() |
| 17 | stp = suite.stp() |
| 18 | msc = suite.msc(hlr, mgw_msc, stp) |
| 19 | smsc = msc.smsc |
| 20 | |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 21 | esme = suite.esme() |
| 22 | esme_no_pwd = suite.esme() |
| 23 | esme_no_pwd.set_password('') |
| 24 | |
| 25 | smsc.set_smsc_policy(smsc.SMSC_POLICY_CLOSED) |
| 26 | smsc.esme_add(esme) |
| 27 | smsc.esme_add(esme_no_pwd) |
| 28 | |
Pau Espin Pedrol | 4385780 | 2018-09-13 15:07:27 +0200 | [diff] [blame] | 29 | stp.start() |
| 30 | hlr.start() |
| 31 | msc.start() |
| 32 | mgw_msc.start() |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 33 | |
| 34 | log('Test with correct credentials (no password)') |
| 35 | esme_no_pwd.connect() |
| 36 | esme_no_pwd.disconnect() |
| 37 | |
| 38 | log('Test with correct credentials (no password, non empty)') |
| 39 | esme_no_pwd.set_password('foobar') |
| 40 | esme_no_pwd.connect() |
| 41 | esme_no_pwd.disconnect() |
| 42 | |
| 43 | log('Test with correct credentials') |
| 44 | esme.connect() |
| 45 | esme.disconnect() |
| 46 | |
| 47 | log('Test with bad password, checking for failure') |
| 48 | correct_password = esme.password |
| 49 | new_password = 'barfoo' if correct_password == 'foobar' else 'foobar' |
| 50 | esme.set_password(new_password) |
| 51 | esme.run_method_expect_failure(SMPP_ESME_RINVPASWD, esme.connect) |
| 52 | esme.set_password(correct_password) |
| 53 | |
| 54 | log('Test with bad system_id, checking for failure') |
| 55 | correct_system_id = esme.system_id |
| 56 | new_system_id = 'barfoo' if correct_system_id == 'foobar' else 'foobar' |
| 57 | esme.set_system_id(new_system_id) |
| 58 | esme.run_method_expect_failure(SMPP_ESME_RINVSYSID, esme.connect) |
| 59 | esme.set_system_id(correct_system_id) |