blob: fc4145c7f0e7884062f4fcee66b3050036cf198c [file] [log] [blame]
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +02001#!/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 Pedroldfe38ad2017-11-09 13:57:39 +01009from osmo_gsm_tester.testenv import *
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020010
11SMPP_ESME_RINVPASWD = 0x0000000E
12SMPP_ESME_RINVSYSID = 0x0000000F
13
Pau Espin Pedrol40c7bc72020-05-05 13:41:42 +020014hlr = tenv.hlr()
15bts = tenv.bts()
16mgw_msc = tenv.mgw()
17stp = tenv.stp()
18msc = tenv.msc(hlr, mgw_msc, stp)
Pau Espin Pedrol43857802018-09-13 15:07:27 +020019smsc = msc.smsc
20
Pau Espin Pedrol40c7bc72020-05-05 13:41:42 +020021esme = tenv.esme()
22esme_no_pwd = tenv.esme()
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020023esme_no_pwd.set_password('')
24
25smsc.set_smsc_policy(smsc.SMSC_POLICY_CLOSED)
26smsc.esme_add(esme)
27smsc.esme_add(esme_no_pwd)
28
Pau Espin Pedrol43857802018-09-13 15:07:27 +020029stp.start()
30hlr.start()
31msc.start()
32mgw_msc.start()
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020033
34log('Test with correct credentials (no password)')
35esme_no_pwd.connect()
36esme_no_pwd.disconnect()
37
38log('Test with correct credentials (no password, non empty)')
39esme_no_pwd.set_password('foobar')
40esme_no_pwd.connect()
41esme_no_pwd.disconnect()
42
43log('Test with correct credentials')
44esme.connect()
45esme.disconnect()
46
47log('Test with bad password, checking for failure')
48correct_password = esme.password
49new_password = 'barfoo' if correct_password == 'foobar' else 'foobar'
50esme.set_password(new_password)
51esme.run_method_expect_failure(SMPP_ESME_RINVPASWD, esme.connect)
52esme.set_password(correct_password)
53
54log('Test with bad system_id, checking for failure')
55correct_system_id = esme.system_id
56new_system_id = 'barfoo' if correct_system_id == 'foobar' else 'foobar'
57esme.set_system_id(new_system_id)
58esme.run_method_expect_failure(SMPP_ESME_RINVSYSID, esme.connect)
59esme.set_system_id(correct_system_id)