Beispiel #1
0
    def test_deliver_sm_op_codes_end(self):
        source_addr = "msisdn"
        session_identifier = 12345
        vumi_session_identifier = make_vumi_session_identifier(source_addr, 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#")

        pdu = DeliverSM(1, short_message="", source_addr=source_addr)
        pdu.add_optional_parameter("ussd_service_op", "81")
        pdu.add_optional_parameter("user_message_reference", session_identifier)
        yield self.fake_smsc.handle_pdu(pdu)
        [end] = yield self.tx_helper.wait_for_dispatched_inbound(1)
        self.assertEqual(end["session_event"], TransportUserMessage.SESSION_CLOSE)
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    def test_deliver_sm_op_codes_end(self):
        source_addr = 'msisdn'
        session_identifier = 12345
        vumi_session_identifier = make_vumi_session_identifier(
            source_addr, 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#')

        pdu = DeliverSM(1, short_message="", source_addr=source_addr)
        pdu.add_optional_parameter('ussd_service_op', '81')
        pdu.add_optional_parameter('user_message_reference',
                                   session_identifier)
        yield smpp_helper.handle_pdu(pdu)
        [end] = yield self.tx_helper.wait_for_dispatched_inbound(1)
        self.assertEqual(end['session_event'],
                         TransportUserMessage.SESSION_CLOSE)
Beispiel #5
0
    def test_deliver_sm_op_codes_resume(self):
        source_addr = 'msisdn'
        session_identifier = 12345
        vumi_session_identifier = make_vumi_session_identifier(
            source_addr, 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#')

        pdu = DeliverSM(1, short_message="", source_addr=source_addr)
        pdu.add_optional_parameter('ussd_service_op', '12')
        pdu.add_optional_parameter('user_message_reference',
                                   session_identifier)
        yield smpp_helper.handle_pdu(pdu)
        [resume] = yield self.tx_helper.wait_for_dispatched_inbound(1)
        self.assertEqual(resume['session_event'],
                         TransportUserMessage.SESSION_RESUME)
Beispiel #6
0
    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)