Beispiel #1
0
    def test_tagging(self):
        """Refs #495
        Will tag message inside interceptor script and assert
        routing based tagfilter were correctly done
        """
        # Re-provision interceptor with correct script
        mt_interceptor = MTInterceptorScript("routable.addTag(10)")
        yield self.mtinterceptor_add(DefaultInterceptor(mt_interceptor), 0)

        # Change routing rules by shadowing (high order value) default route with a
        # static route having a tagfilter
        yield self.mtroute_flush()
        yield self.mtroute_add(StaticMTRoute([TagFilter(10)], self.c1, 0.0),
                               1000)

        # Connect to InterceptorPB
        yield self.ipb_connect()

        # Send a SMS MT through http interface
        url = 'http://127.0.0.1:1401/send?to=06155423&content=test&username=%s&password=%s' % (
            self.u1.username, self.u1_password)

        # We should receive an error since interceptorpb is not connected
        lastErrorStatus = None
        lastResponse = None
        try:
            yield getPage(url)
        except Exception, e:
            lastErrorStatus = e.status
            lastResponse = e.response
Beispiel #2
0
    def setUp(self):
        HTTPApiTestCases.setUp(self)

        # Provision Router with additional Users and Routes
        u2 = User(2, Group(2), 'user2', 'correct')
        u3 = User(3, Group(2), 'user3', 'correct')
        u3.mt_credential.setQuota('balance', 10)
        self.RouterPB_f.users.append(u2)
        self.RouterPB_f.users.append(u3)
        filters = [GroupFilter(Group(2))]
        route = StaticMTRoute(filters, SmppClientConnector('abc'), 1.5)
        self.RouterPB_f.mt_routing_table.add(route, 2)
Beispiel #3
0
    def test_add_list_and_remove_mt_route(self):
        yield self.connect('127.0.0.1', self.pbPort)

        yield self.mtroute_add(
            StaticMTRoute([GroupFilter(Group(1))],
                          SmppClientConnector(id_generator()), 0.0), 2)
        yield self.mtroute_add(
            DefaultRoute(SmppClientConnector(id_generator())), 0)
        listRet1 = yield self.mtroute_get_all()
        listRet1 = pickle.loads(listRet1)

        yield self.mtroute_remove(2)
        listRet2 = yield self.mtroute_get_all()
        listRet2 = pickle.loads(listRet2)

        self.assertEqual(2, len(listRet1))
        self.assertEqual(1, len(listRet2))
    def test_tagging(self):
        """Refs #495
        Will tag message inside interceptor script and assert
        routing based tagfilter were correctly done
        """
        # Re-provision interceptor with correct script
        mt_interceptor = MTInterceptorScript("routable.addTag(10)")
        yield self.mtinterceptor_add(DefaultInterceptor(mt_interceptor), 0)

        # Change routing rules by shadowing (high order value) default route with a
        # static route having a tagfilter
        yield self.mtroute_flush()
        yield self.mtroute_add(StaticMTRoute([TagFilter(10)], self.c1, 0.0),
                               1000)

        # Connect to InterceptorPB
        yield self.ipb_connect()

        # Send a SMS MT through http interface
        url = 'http://127.0.0.1:1401/send'
        params = {
            'to': '06155423',
            'content': 'test',
            'username': self.u1.username,
            'password': self.u1_password
        }

        agent = Agent(reactor)
        client = HTTPClient(agent)
        response = yield client.post(url, data=params)

        lastErrorStatus = response.code
        lastResponse = yield text_content(response)

        # Wait some time for message delivery through smppc
        yield waitFor(2)

        # Asserts
        self.assertEqual(lastErrorStatus, 200)
        self.assertEqual(1,
                         len(self.SMSCPort.factory.lastClient.submitRecords))
    def test_tagging(self):
        """Refs #495
        Will tag message inside interceptor script and assert
        routing based tagfilter were correctly done
        """
        # Re-provision interceptor with correct script
        # Connect to RouterPB
        yield self.connect('127.0.0.1', self.pbPort)
        mt_interceptor = MTInterceptorScript("routable.addTag(10)")
        yield self.mtinterceptor_add(DefaultInterceptor(mt_interceptor), 0)
        # Disconnect from RouterPB
        self.disconnect()

        # Connect to InterceptorPB
        yield self.ipb_connect()

        yield self.connect('127.0.0.1', self.pbPort)
        yield self.prepareRoutingsAndStartConnector()

        # Change routing rules by shadowing (high order value) default route with a
        # static route having a tagfilter
        yield self.mtroute_flush()
        yield self.mtroute_add(StaticMTRoute([TagFilter(10)], self.c1, 0.0),
                               1000)

        # Bind
        yield self.smppc_factory.connectAndBind()

        # Send a SMS MT through smpps interface
        yield self.smppc_factory.lastProto.sendDataRequest(self.SubmitSmPDU)

        # Wait 3 seconds for submit_sm_resp
        yield waitFor(3)

        # Unbind & Disconnect
        yield self.smppc_factory.smpp.unbindAndDisconnect()
        yield self.stopSmppClientConnectors()

        # Run tests on final destination smpp server (third party mocker)
        self.assertEqual(1,
                         len(self.SMSCPort.factory.lastClient.submitRecords))