blob: 7fac276b16e27a5aad805a5197597f89c7c97e29 [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
14nitb = suite.nitb()
15smsc = nitb.smsc
16esme = suite.esme()
17esme_no_pwd = suite.esme()
18esme_no_pwd.set_password('')
19
20smsc.set_smsc_policy(smsc.SMSC_POLICY_CLOSED)
21smsc.esme_add(esme)
22smsc.esme_add(esme_no_pwd)
23
24nitb.start()
25
26log('Test with correct credentials (no password)')
27esme_no_pwd.connect()
28esme_no_pwd.disconnect()
29
30log('Test with correct credentials (no password, non empty)')
31esme_no_pwd.set_password('foobar')
32esme_no_pwd.connect()
33esme_no_pwd.disconnect()
34
35log('Test with correct credentials')
36esme.connect()
37esme.disconnect()
38
39log('Test with bad password, checking for failure')
40correct_password = esme.password
41new_password = 'barfoo' if correct_password == 'foobar' else 'foobar'
42esme.set_password(new_password)
43esme.run_method_expect_failure(SMPP_ESME_RINVPASWD, esme.connect)
44esme.set_password(correct_password)
45
46log('Test with bad system_id, checking for failure')
47correct_system_id = esme.system_id
48new_system_id = 'barfoo' if correct_system_id == 'foobar' else 'foobar'
49esme.set_system_id(new_system_id)
50esme.run_method_expect_failure(SMPP_ESME_RINVSYSID, esme.connect)
51esme.set_system_id(correct_system_id)