2017-05-30 13:33:57 +00:00
|
|
|
# osmo_gsm_tester: SMPP ESME to talk to SMSC
|
|
|
|
#
|
|
|
|
# Copyright (C) 2017 by sysmocom - s.f.m.c. GmbH
|
|
|
|
#
|
|
|
|
# Author: Pau Espin Pedrol <pespin@sysmocom.de>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Affero General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 3 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2020-04-10 18:46:07 +00:00
|
|
|
from ..core import log
|
|
|
|
from ..core.event_loop import MainLoop
|
2017-05-30 13:33:57 +00:00
|
|
|
|
|
|
|
# if you want to know what's happening inside python-smpplib
|
|
|
|
#import logging
|
|
|
|
#logging.basicConfig(level='DEBUG')
|
|
|
|
|
|
|
|
MAX_SYS_ID_LEN = 16
|
|
|
|
MAX_PASSWD_LEN = 16
|
|
|
|
|
2020-05-11 09:55:42 +00:00
|
|
|
smpplib_gsm = None
|
|
|
|
smpplib_client = None
|
|
|
|
smpplib_command = None
|
|
|
|
smpplib_consts = None
|
|
|
|
smpplib_exceptions = None
|
|
|
|
def _import_smpplib_modules():
|
|
|
|
global smpplib_gsm, smpplib_client, smpplib_command, smpplib_consts, smpplib_exceptions
|
|
|
|
if smpplib_exceptions is None:
|
|
|
|
import smpplib.gsm
|
|
|
|
import smpplib.client
|
|
|
|
import smpplib.command
|
|
|
|
import smpplib.consts
|
|
|
|
import smpplib.exceptions
|
|
|
|
smpplib_gsm = smpplib.gsm
|
|
|
|
smpplib_client = smpplib.client
|
|
|
|
smpplib_command = smpplib.command
|
|
|
|
smpplib_consts = smpplib.consts
|
|
|
|
smpplib_exceptions = smpplib.exceptions
|
|
|
|
|
2017-05-30 13:33:57 +00:00
|
|
|
class Esme(log.Origin):
|
|
|
|
|
|
|
|
def __init__(self, msisdn):
|
|
|
|
self.msisdn = msisdn
|
|
|
|
# Get last characters of msisdn to stay inside MAX_SYS_ID_LEN. Similar to modulus operator.
|
|
|
|
self.set_system_id('esme-' + self.msisdn[-11:])
|
|
|
|
super().__init__(log.C_TST, self.system_id)
|
2018-08-09 11:45:55 +00:00
|
|
|
self.client = None
|
|
|
|
self.smsc = None
|
2017-05-30 13:33:57 +00:00
|
|
|
self.set_password('esme-pwd')
|
|
|
|
self.connected = False
|
|
|
|
self.bound = False
|
|
|
|
self.listening = False
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
self.references_pending_receipt = []
|
|
|
|
self.next_user_message_reference = 1
|
2020-05-11 09:55:42 +00:00
|
|
|
_import_smpplib_modules()
|
|
|
|
self.MSGMODE_TRANSACTION = smpplib_consts.SMPP_MSGMODE_FORWARD
|
|
|
|
self.MSGMODE_STOREFORWARD = smpplib_consts.SMPP_MSGMODE_STOREFORWARD
|
2017-05-30 13:33:57 +00:00
|
|
|
|
|
|
|
def __del__(self):
|
2017-08-10 08:59:40 +00:00
|
|
|
self.cleanup()
|
|
|
|
|
|
|
|
def cleanup(self):
|
2017-05-30 13:33:57 +00:00
|
|
|
try:
|
|
|
|
self.disconnect()
|
2020-05-11 09:55:42 +00:00
|
|
|
except smpplib_exceptions.ConnectionError:
|
2017-05-30 13:33:57 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
def set_smsc(self, smsc):
|
|
|
|
self.smsc = smsc
|
|
|
|
|
|
|
|
def set_system_id(self, name):
|
|
|
|
if len(name) > MAX_SYS_ID_LEN:
|
|
|
|
raise log.Error('Esme system_id too long! %d vs %d', len(name), MAX_SYS_ID_LEN)
|
|
|
|
self.system_id = name
|
|
|
|
|
|
|
|
def set_password(self, password):
|
|
|
|
if len(password) > MAX_PASSWD_LEN:
|
|
|
|
raise log.Error('Esme password too long! %d vs %d', len(password), MAX_PASSWD_LEN)
|
|
|
|
self.password = password
|
|
|
|
|
|
|
|
def conf_for_smsc(self):
|
|
|
|
config = { 'system_id': self.system_id, 'password': self.password }
|
|
|
|
return config
|
|
|
|
|
|
|
|
def poll(self):
|
|
|
|
self.client.poll()
|
|
|
|
|
|
|
|
def start_listening(self):
|
|
|
|
self.listening = True
|
2018-03-28 17:17:34 +00:00
|
|
|
MainLoop.register_poll_func(self.poll)
|
2017-05-30 13:33:57 +00:00
|
|
|
|
|
|
|
def stop_listening(self):
|
|
|
|
if not self.listening:
|
|
|
|
return
|
|
|
|
self.listening = False
|
|
|
|
# Empty the queue before processing the unbind + disconnect PDUs
|
2018-03-28 17:17:34 +00:00
|
|
|
MainLoop.unregister_poll_func(self.poll)
|
2017-05-30 13:33:57 +00:00
|
|
|
self.poll()
|
|
|
|
|
|
|
|
def connect(self):
|
|
|
|
host, port = self.smsc.addr_port
|
|
|
|
if self.client:
|
|
|
|
self.disconnect()
|
2020-05-11 09:55:42 +00:00
|
|
|
self.client = smpplib_client.Client(host, port, timeout=None)
|
2017-05-30 13:33:57 +00:00
|
|
|
self.client.set_message_sent_handler(
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
lambda pdu: self.dbg('Unhandled submit_sm_resp message:', pdu.sequence) )
|
|
|
|
self.client.set_message_received_handler(self._message_received_handler)
|
2017-05-30 13:33:57 +00:00
|
|
|
self.client.connect()
|
|
|
|
self.connected = True
|
|
|
|
self.client.bind_transceiver(system_id=self.system_id, password=self.password)
|
|
|
|
self.bound = True
|
2017-07-31 15:25:15 +00:00
|
|
|
self.log('Connected and bound successfully to %s (%s:%d). Starting to listen.' % (self.system_id, host, port))
|
2017-05-30 13:33:57 +00:00
|
|
|
self.start_listening()
|
|
|
|
|
|
|
|
def disconnect(self):
|
|
|
|
self.stop_listening()
|
|
|
|
if self.bound:
|
|
|
|
self.client.unbind()
|
|
|
|
self.bound = False
|
|
|
|
if self.connected:
|
|
|
|
self.client.disconnect()
|
|
|
|
self.connected = False
|
|
|
|
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
def _message_received_handler(self, pdu, *args):
|
|
|
|
self.dbg('message received:', seq=pdu.sequence)
|
2020-05-11 09:55:42 +00:00
|
|
|
if isinstance(pdu, smpplib_command.AlertNotification):
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
self.dbg('message received: AlertNotification:', ms_availability_status=pdu.ms_availability_status)
|
2020-05-11 09:55:42 +00:00
|
|
|
elif isinstance(pdu, smpplib_command.DeliverSM):
|
2017-08-17 15:01:50 +00:00
|
|
|
umref = int(pdu.user_message_reference)
|
|
|
|
self.dbg('message received: DeliverSM', references_pending_receipt=self.references_pending_receipt, user_message_reference=umref)
|
|
|
|
self.references_pending_receipt.remove(umref)
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
|
|
|
|
def receipt_was_received(self, umref):
|
2017-08-18 15:22:19 +00:00
|
|
|
return umref not in self.references_pending_receipt
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
|
2017-05-30 13:33:57 +00:00
|
|
|
def run_method_expect_failure(self, errcode, method, *args):
|
|
|
|
try:
|
|
|
|
method(*args)
|
|
|
|
#it should not succeed, raise an exception:
|
2020-05-11 09:55:42 +00:00
|
|
|
raise log.Error('SMPP Failure: %s should have failed with SMPP error %d (%s) but succeeded.' % (method, errcode, smpplib_consts.DESCRIPTIONS[errcode]))
|
|
|
|
except smpplib_exceptions.PDUError as e:
|
2017-05-30 13:33:57 +00:00
|
|
|
if e.args[1] != errcode:
|
|
|
|
raise e
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
self.dbg('Expected failure triggered: %d' % errcode)
|
2017-05-30 13:33:57 +00:00
|
|
|
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
def sms_send(self, sms_obj, mode, receipt=False):
|
2020-05-11 09:55:42 +00:00
|
|
|
parts, encoding_flag, msg_type_flag = smpplib_gsm.make_parts(str(sms_obj))
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
seqs = []
|
2017-05-30 13:33:57 +00:00
|
|
|
self.log('Sending SMS "%s" to %s' % (str(sms_obj), sms_obj.dst_msisdn()))
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
umref = self.next_user_message_reference
|
2017-08-17 15:57:58 +00:00
|
|
|
self.next_user_message_reference = (self.next_user_message_reference + 1) % (1 << 8)
|
2017-05-30 13:33:57 +00:00
|
|
|
for part in parts:
|
|
|
|
pdu = self.client.send_message(
|
2020-05-11 09:55:42 +00:00
|
|
|
source_addr_ton=smpplib_consts.SMPP_TON_INTL,
|
|
|
|
source_addr_npi=smpplib_consts.SMPP_NPI_ISDN,
|
2017-05-30 13:33:57 +00:00
|
|
|
source_addr=sms_obj.src_msisdn(),
|
2020-05-11 09:55:42 +00:00
|
|
|
dest_addr_ton=smpplib_consts.SMPP_TON_INTL,
|
|
|
|
dest_addr_npi=smpplib_consts.SMPP_NPI_ISDN,
|
2017-05-30 13:33:57 +00:00
|
|
|
destination_addr=sms_obj.dst_msisdn(),
|
|
|
|
short_message=part,
|
|
|
|
data_coding=encoding_flag,
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
esm_class=mode,
|
|
|
|
registered_delivery=receipt,
|
|
|
|
user_message_reference=umref,
|
2017-05-30 13:33:57 +00:00
|
|
|
)
|
|
|
|
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
self.dbg('sent part with seq', pdu.sequence)
|
|
|
|
seqs.append(pdu.sequence)
|
|
|
|
if receipt:
|
|
|
|
self.references_pending_receipt.append(umref)
|
|
|
|
return umref, seqs
|
|
|
|
|
|
|
|
def _process_pdus_pending(self, pdu, **kwargs):
|
|
|
|
self.dbg('message sent resp with seq', pdu.sequence, ', pdus_pending:', self.pdus_pending)
|
2017-07-20 20:41:22 +00:00
|
|
|
if pdu.sequence in self.pdus_pending:
|
|
|
|
self.pdus_pending.remove(pdu.sequence)
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
|
|
|
|
def sms_send_wait_resp(self, sms_obj, mode, receipt=False):
|
|
|
|
old_func = self.client.message_sent_handler
|
|
|
|
try:
|
|
|
|
umref, self.pdus_pending = self.sms_send(sms_obj, mode, receipt)
|
|
|
|
self.dbg('pdus_pending:', self.pdus_pending)
|
|
|
|
self.client.set_message_sent_handler(self._process_pdus_pending)
|
2020-06-10 17:30:33 +00:00
|
|
|
MainLoop.wait(lambda: len(self.pdus_pending) == 0, timeout=10)
|
Improve SMPP supported features and test coverage
esme: Add several bits to handle logic required by tests:
- Allow specifying the mode used to send an sms
- Add a parameter to ask to receive a Delivery receipt for that message
- Add sms_send_wait_resp API, which waits until the response message for
a given smpp message is received when sending an sms.
- Add receipt_was_received API, which together with
message_received_handler maintains state of the delivery receipts we
asked for and were still not received. However, the check needs to be
disabled for now because OsmoNITB doens't seem to be sending stuff
properly, see OsmoNITB #2353.
- On message_received_handler, also print alert_notification messages,
to show that there's actually a bug in OsmoNITB, see #2352.
Move old esme_ms_sms to esme_ms_sms_transaction, and explicitly state
that we are using that mode. On the same test, we can now enable the
part which asserts that sending an SMS to an msisdn with unknown
destination triggers an error. The issue was mainly that the error had
to come from the SMSC server response, not from the sent message, so
we have to wait for the response to have the failure triggered.
Finally, add esme_ms_sms_storeforward, which tests features for sms sent
using that mode, and uses the APIs described above.
Change-Id: Ia2c0c325fee14143deca8310312fc530cd9ce92e
2017-07-05 11:38:33 +00:00
|
|
|
return umref
|
|
|
|
finally:
|
|
|
|
self.client.set_message_sent_handler(old_func)
|
|
|
|
|
2017-05-30 13:33:57 +00:00
|
|
|
# vim: expandtab tabstop=4 shiftwidth=4
|