blob: 29b25d12385be8501009c53ec9c8ffa423eca476 [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
9from osmo_gsm_tester.test import *
10
11SMPP_ESME_RINVPASWD = 0x0000000E
12SMPP_ESME_RINVSYSID = 0x0000000F
13
14hlr = suite.hlr()
15bts = suite.bts()
16mgcpgw = suite.mgcpgw(bts_ip=bts.remote_addr())
17msc = suite.msc(hlr, mgcpgw)
18smsc = msc.smsc
19
20esme = suite.esme()
21esme_no_pwd = suite.esme()
22esme_no_pwd.set_password('')
23
24smsc.set_smsc_policy(smsc.SMSC_POLICY_CLOSED)
25smsc.esme_add(esme)
26smsc.esme_add(esme_no_pwd)
27
28hlr.start()
29msc.start()
30mgcpgw.start()
31
32log('Test with correct credentials (no password)')
33esme_no_pwd.connect()
34esme_no_pwd.disconnect()
35
36log('Test with correct credentials (no password, non empty)')
37esme_no_pwd.set_password('foobar')
38esme_no_pwd.connect()
39esme_no_pwd.disconnect()
40
41log('Test with correct credentials')
42esme.connect()
43esme.disconnect()
44
45log('Test with bad password, checking for failure')
46correct_password = esme.password
47new_password = 'barfoo' if correct_password == 'foobar' else 'foobar'
48esme.set_password(new_password)
49esme.run_method_expect_failure(SMPP_ESME_RINVPASWD, esme.connect)
50esme.set_password(correct_password)
51
52log('Test with bad system_id, checking for failure')
53correct_system_id = esme.system_id
54new_system_id = 'barfoo' if correct_system_id == 'foobar' else 'foobar'
55esme.set_system_id(new_system_id)
56esme.run_method_expect_failure(SMPP_ESME_RINVSYSID, esme.connect)
57esme.set_system_id(correct_system_id)