blob: 41a74f21283636200db54e49747c9ed26418f74a [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 +020014nitb = tenv.nitb()
Pau Espin Pedrol43857802018-09-13 15:07:27 +020015smsc = nitb.smsc
Pau Espin Pedrol40c7bc72020-05-05 13:41:42 +020016esme = tenv.esme()
17esme_no_pwd = tenv.esme()
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020018esme_no_pwd.set_password('')
19
20smsc.set_smsc_policy(smsc.SMSC_POLICY_CLOSED)
21smsc.esme_add(esme)
22smsc.esme_add(esme_no_pwd)
23
Pau Espin Pedrol43857802018-09-13 15:07:27 +020024nitb.start()
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +020025
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)