def test_submit_and_deliver_ussd_close(self): smpp_helper = yield self.get_smpp_helper() yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_CLOSE) [submit_sm_pdu] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(command_id(submit_sm_pdu), 'submit_sm') self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '02') self.assertEqual(pdu_tlv(submit_sm_pdu, 'its_session_info'), '0001') # Server delivers a USSD message to the Client pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!") pdu.add_optional_parameter('ussd_service_op', '02') pdu.add_optional_parameter('its_session_info', '0001') yield smpp_helper.handle_pdu(pdu) [mess] = yield self.tx_helper.wait_for_dispatched_inbound(1) self.assertEqual(mess['content'], "reply!") self.assertEqual(mess['transport_type'], "ussd") self.assertEqual(mess['session_event'], TransportUserMessage.SESSION_CLOSE)
def test_submit_and_deliver_ussd_close(self): yield self.get_transport() session_identifier = 12345 yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_CLOSE, transport_metadata={"session_info": {"session_identifier": session_identifier}}, ) submit_sm_pdu = yield self.fake_smsc.await_pdu() self.assertEqual(command_id(submit_sm_pdu), "submit_sm") self.assertEqual(pdu_tlv(submit_sm_pdu, "ussd_service_op"), "17") self.assertEqual(pdu_tlv(submit_sm_pdu, "user_message_reference"), session_identifier)
def test_submit_sm_op_codes_resume(self): session = SessionInfo() yield self.get_transport() yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_RESUME, transport_metadata={ 'session_info': { 'session_identifier': session.sixdee_id, } }, to_addr=session.addr) resume = yield self.fake_smsc.await_pdu() self.assertEqual(pdu_tlv(resume, 'ussd_service_op'), '02') self.assertEqual(pdu_tlv(resume, 'its_session_info'), session.its_info)
def test_submit_and_deliver_ussd_continue(self): user_msisdn = 'msisdn' session_identifier = 12345 vumi_session_identifier = make_vumi_session_identifier( user_msisdn, session_identifier) transport = yield self.get_transport() deliver_sm_processor = transport.deliver_sm_processor session_manager = deliver_sm_processor.session_manager yield session_manager.create_session(vumi_session_identifier, ussd_code='*123#') yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", transport_metadata={ 'session_info': { 'session_identifier': session_identifier } }, to_addr=user_msisdn) submit_sm_pdu = yield self.fake_smsc.await_pdu() self.assertEqual(command_id(submit_sm_pdu), 'submit_sm') self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '02') self.assertEqual(pdu_tlv(submit_sm_pdu, 'user_message_reference'), session_identifier) # Server delivers a USSD message to the Client pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!", source_addr=user_msisdn) # 0x12 is 'continue' pdu.add_optional_parameter('ussd_service_op', '12') pdu.add_optional_parameter('user_message_reference', session_identifier) yield self.fake_smsc.handle_pdu(pdu) [mess] = yield self.tx_helper.wait_for_dispatched_inbound(1) self.assertEqual(mess['content'], "reply!") self.assertEqual(mess['transport_type'], "ussd") self.assertEqual(mess['to_addr'], '*123#') self.assertEqual(mess['session_event'], TransportUserMessage.SESSION_RESUME)
def test_submit_sm_op_codes_close(self): session = SessionInfo(continue_session=False) smpp_helper = yield self.get_smpp_helper() yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_CLOSE, transport_metadata={ 'session_info': { 'session_identifier': session.sixdee_id, } }, to_addr=session.addr) [close] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(pdu_tlv(close, 'ussd_service_op'), '17') self.assertEqual(pdu_tlv(close, 'its_session_info'), session.its_info)
def test_submit_and_deliver_ussd_close(self): smpp_helper = yield self.get_smpp_helper() session_identifier = 12345 yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_CLOSE, transport_metadata={ 'session_info': { 'session_identifier': session_identifier } }) [submit_sm_pdu] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(command_id(submit_sm_pdu), 'submit_sm') self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '17') self.assertEqual(pdu_tlv(submit_sm_pdu, 'user_message_reference'), session_identifier)
def test_submit_and_deliver_ussd_close(self): session = SessionInfo(continue_session=False) yield self.get_transport() yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_CLOSE, transport_metadata={ 'session_info': { 'session_identifier': session.sixdee_id, } }) submit_sm_pdu = yield self.fake_smsc.await_pdu() self.assertEqual(command_id(submit_sm_pdu), 'submit_sm') self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '17') self.assertEqual(pdu_tlv(submit_sm_pdu, 'its_session_info'), session.its_info)
def test_submit_and_deliver_ussd_continue(self): user_msisdn = 'msisdn' session_identifier = 12345 vumi_session_identifier = make_vumi_session_identifier( user_msisdn, session_identifier) smpp_helper = yield self.get_smpp_helper() deliver_sm_processor = smpp_helper.transport.deliver_sm_processor session_manager = deliver_sm_processor.session_manager yield session_manager.create_session( vumi_session_identifier, ussd_code='*123#') yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", transport_metadata={ 'session_info': { 'session_identifier': session_identifier } }, to_addr=user_msisdn) [submit_sm_pdu] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(command_id(submit_sm_pdu), 'submit_sm') self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '02') self.assertEqual( pdu_tlv(submit_sm_pdu, 'user_message_reference'), session_identifier) # Server delivers a USSD message to the Client pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!", source_addr=user_msisdn) # 0x12 is 'continue' pdu.add_optional_parameter('ussd_service_op', '12') pdu.add_optional_parameter('user_message_reference', session_identifier) yield smpp_helper.handle_pdu(pdu) [mess] = yield self.tx_helper.wait_for_dispatched_inbound(1) self.assertEqual(mess['content'], "reply!") self.assertEqual(mess['transport_type'], "ussd") self.assertEqual(mess['to_addr'], '*123#') self.assertEqual(mess['session_event'], TransportUserMessage.SESSION_RESUME)
def test_submit_sm_null_message(self): """ We can successfully send a message with null content. """ session = SessionInfo() yield self.get_transport() yield self.tx_helper.make_dispatch_outbound( None, transport_type="ussd", session_event=TransportUserMessage.SESSION_RESUME, transport_metadata={ 'session_info': { 'session_identifier': session.sixdee_id, } }, to_addr=session.addr) resume = yield self.fake_smsc.await_pdu() self.assertEqual(pdu_tlv(resume, 'ussd_service_op'), '02') self.assertEqual(pdu_tlv(resume, 'its_session_info'), session.its_info)
def test_submit_and_deliver_ussd_continue(self): session = SessionInfo() smpp_helper = yield self.get_smpp_helper() deliver_sm_processor = smpp_helper.transport.deliver_sm_processor session_manager = deliver_sm_processor.session_manager yield session_manager.create_session(session.vumi_id, ussd_code='*123#') yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", transport_metadata={ 'session_info': { 'session_identifier': session.sixdee_id, } }, to_addr=session.addr) [submit_sm_pdu] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(command_id(submit_sm_pdu), 'submit_sm') self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '02') self.assertEqual(pdu_tlv(submit_sm_pdu, 'its_session_info'), session.its_info) # Server delivers a USSD message to the Client pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!", source_addr=session.addr) # 0x12 is 'continue' pdu.add_optional_parameter('ussd_service_op', '12') pdu.add_optional_parameter('its_session_info', session.its_info) yield smpp_helper.handle_pdu(pdu) [mess] = yield self.tx_helper.wait_for_dispatched_inbound(1) self.assertEqual(mess['content'], "reply!") self.assertEqual(mess['transport_type'], "ussd") self.assertEqual(mess['to_addr'], '*123#') self.assertEqual(mess['session_event'], TransportUserMessage.SESSION_RESUME)
def test_submit_and_deliver_ussd_continue(self): session = SessionInfo() transport = yield self.get_transport() deliver_sm_processor = transport.deliver_sm_processor session_manager = deliver_sm_processor.session_manager yield session_manager.create_session( session.vumi_id, ussd_code='*123#') yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", transport_metadata={ 'session_info': { 'session_identifier': session.sixdee_id, } }, to_addr=session.addr) submit_sm_pdu = yield self.fake_smsc.await_pdu() self.assertEqual(command_id(submit_sm_pdu), 'submit_sm') self.assertEqual(pdu_tlv(submit_sm_pdu, 'ussd_service_op'), '02') self.assertEqual(pdu_tlv(submit_sm_pdu, 'its_session_info'), session.its_info) # Server delivers a USSD message to the Client pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!", source_addr=session.addr) # 0x12 is 'continue' pdu.add_optional_parameter('ussd_service_op', '12') pdu.add_optional_parameter('its_session_info', session.its_info) yield self.fake_smsc.handle_pdu(pdu) [mess] = yield self.tx_helper.wait_for_dispatched_inbound(1) self.assertEqual(mess['content'], "reply!") self.assertEqual(mess['transport_type'], "ussd") self.assertEqual(mess['to_addr'], '*123#') self.assertEqual(mess['session_event'], TransportUserMessage.SESSION_RESUME)
def test_submit_sm_op_codes_resume(self): user_msisdn = "msisdn" session_identifier = 12345 yield self.get_transport() yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_RESUME, transport_metadata={"session_info": {"session_identifier": session_identifier}}, to_addr=user_msisdn, ) resume = yield self.fake_smsc.await_pdu() self.assertEqual(pdu_tlv(resume, "ussd_service_op"), "02")
def test_mt_sms_multipart_long(self): smpp_helper = yield self.get_smpp_helper(config={ 'submit_short_message_processor_config': { 'send_long_messages': True, } }) # SMPP specifies that messages longer than 254 bytes should # be put in the message_payload field using TLVs content = '1' * 255 msg = self.tx_helper.make_outbound(content) yield self.tx_helper.dispatch_outbound(msg) [submit_sm] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(pdu_tlv(submit_sm, 'message_payload').decode('hex'), content)
def test_submit_and_deliver_ussd_continue(self): user_msisdn = "msisdn" session_identifier = 12345 vumi_session_identifier = make_vumi_session_identifier(user_msisdn, session_identifier) transport = yield self.get_transport() deliver_sm_processor = transport.deliver_sm_processor session_manager = deliver_sm_processor.session_manager yield session_manager.create_session(vumi_session_identifier, ussd_code="*123#") yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", transport_metadata={"session_info": {"session_identifier": session_identifier}}, to_addr=user_msisdn, ) submit_sm_pdu = yield self.fake_smsc.await_pdu() self.assertEqual(command_id(submit_sm_pdu), "submit_sm") self.assertEqual(pdu_tlv(submit_sm_pdu, "ussd_service_op"), "02") self.assertEqual(pdu_tlv(submit_sm_pdu, "user_message_reference"), session_identifier) # Server delivers a USSD message to the Client pdu = DeliverSM(seq_no(submit_sm_pdu) + 1, short_message="reply!", source_addr=user_msisdn) # 0x12 is 'continue' pdu.add_optional_parameter("ussd_service_op", "12") pdu.add_optional_parameter("user_message_reference", session_identifier) yield self.fake_smsc.handle_pdu(pdu) [mess] = yield self.tx_helper.wait_for_dispatched_inbound(1) self.assertEqual(mess["content"], "reply!") self.assertEqual(mess["transport_type"], "ussd") self.assertEqual(mess["to_addr"], "*123#") self.assertEqual(mess["session_event"], TransportUserMessage.SESSION_RESUME)
def test_mt_sms_multipart_long(self): smpp_helper = yield self.get_smpp_helper( config={ 'submit_short_message_processor_config': { 'send_long_messages': True, } }) # SMPP specifies that messages longer than 254 bytes should # be put in the message_payload field using TLVs content = '1' * 255 msg = self.tx_helper.make_outbound(content) yield self.tx_helper.dispatch_outbound(msg) [submit_sm] = yield smpp_helper.wait_for_pdus(1) self.assertEqual( pdu_tlv(submit_sm, 'message_payload').decode('hex'), content)
def test_submit_sm_op_codes_resume(self): user_msisdn = 'msisdn' session_identifier = 12345 smpp_helper = yield self.get_smpp_helper() yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_RESUME, transport_metadata={ 'session_info': { 'session_identifier': session_identifier } }, to_addr=user_msisdn) [resume] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(pdu_tlv(resume, 'ussd_service_op'), '02')
def test_submit_sm_null_message(self): """ We can successfully send a message with null content. """ user_msisdn = "msisdn" session_identifier = 12345 yield self.get_transport() yield self.tx_helper.make_dispatch_outbound( None, transport_type="ussd", session_event=TransportUserMessage.SESSION_RESUME, transport_metadata={"session_info": {"session_identifier": session_identifier}}, to_addr=user_msisdn, ) resume = yield self.fake_smsc.await_pdu() self.assertEqual(pdu_tlv(resume, "ussd_service_op"), "02")
def test_submit_sm_op_codes_close(self): user_msisdn = 'msisdn' session_identifier = 12345 yield self.get_transport() yield self.tx_helper.make_dispatch_outbound( "hello world", transport_type="ussd", session_event=TransportUserMessage.SESSION_CLOSE, transport_metadata={ 'session_info': { 'session_identifier': session_identifier } }, to_addr=user_msisdn) close = yield self.fake_smsc.await_pdu() self.assertEqual(pdu_tlv(close, 'ussd_service_op'), '17')
def test_submit_sm_null_message(self): """ We can successfully send a message with null content. """ user_msisdn = 'msisdn' session_identifier = 12345 smpp_helper = yield self.get_smpp_helper() yield self.tx_helper.make_dispatch_outbound( None, transport_type="ussd", session_event=TransportUserMessage.SESSION_RESUME, transport_metadata={ 'session_info': { 'session_identifier': session_identifier } }, to_addr=user_msisdn) [resume] = yield smpp_helper.wait_for_pdus(1) self.assertEqual(pdu_tlv(resume, 'ussd_service_op'), '02')
def test_mt_sms_multipart_sar(self): smpp_helper = yield self.get_smpp_helper(config={ 'submit_short_message_processor_config': { 'send_multipart_sar': True, } }) content = '1' * 161 msg = self.tx_helper.make_outbound(content) yield self.tx_helper.dispatch_outbound(msg) [submit_sm1, submit_sm2] = yield smpp_helper.wait_for_pdus(2) ref_num = pdu_tlv(submit_sm1, 'sar_msg_ref_num') self.assertEqual(pdu_tlv(submit_sm1, 'sar_total_segments'), 2) self.assertEqual(pdu_tlv(submit_sm1, 'sar_segment_seqnum'), 1) self.assertEqual(pdu_tlv(submit_sm2, 'sar_msg_ref_num'), ref_num) self.assertEqual(pdu_tlv(submit_sm2, 'sar_total_segments'), 2) self.assertEqual(pdu_tlv(submit_sm2, 'sar_segment_seqnum'), 2)
def test_mt_sms_multipart_sar(self): smpp_helper = yield self.get_smpp_helper( config={ 'submit_short_message_processor_config': { 'send_multipart_sar': True, } }) content = '1' * 161 msg = self.tx_helper.make_outbound(content) yield self.tx_helper.dispatch_outbound(msg) [submit_sm1, submit_sm2] = yield smpp_helper.wait_for_pdus(2) ref_num = pdu_tlv(submit_sm1, 'sar_msg_ref_num') self.assertEqual(pdu_tlv(submit_sm1, 'sar_total_segments'), 2) self.assertEqual(pdu_tlv(submit_sm1, 'sar_segment_seqnum'), 1) self.assertEqual(pdu_tlv(submit_sm2, 'sar_msg_ref_num'), ref_num) self.assertEqual(pdu_tlv(submit_sm2, 'sar_total_segments'), 2) self.assertEqual(pdu_tlv(submit_sm2, 'sar_segment_seqnum'), 2)