def setUp(self, authentication=False): # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests self.InterceptorPBConfigInstance = InterceptorPBConfig() self.InterceptorPBConfigInstance.authentication = authentication # Launch the interceptor pb server pbRoot = InterceptorPB() pbRoot.setConfig(self.InterceptorPBConfigInstance) p = portal.Portal(JasminPBRealm(pbRoot)) if not authentication: p.registerChecker(AllowAnonymousAccess()) else: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser('test_user', md5('test_password').digest()) p.registerChecker(c) jPBPortalRoot = JasminPBPortalRoot(p) self.IPBServer = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot)) self.ipbPort = self.IPBServer.getHost().port # Test fixtures self.SubmitSMPDU = SubmitSM( source_addr='20203060', destination_addr='20203060', short_message='MT hello world', ) self.DeliverSMPDU = DeliverSM( source_addr='20203060', destination_addr='20203060', short_message='MO hello world', ) self.connector = Connector('abc') self.user = User(1, Group(100), 'username', 'password') # Routables fixtures self.routable_simple = SimpleRoutablePDU(self.connector, self.SubmitSMPDU, self.user, datetime.now()) # Scripts fixtures self.script_generic = InterceptorScript( 'somevar = "something in MOIS"') self.script_3_second = InterceptorScript('import time;time.sleep(3)') self.script_syntax_error = InterceptorScript('somevar = sssss') self.script_http_status = InterceptorScript('http_status = 404') self.script_smpp_status = InterceptorScript('smpp_status = 64')
def setUp(self, authentication=False): # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests self.SMPPClientPBConfigInstance = SMPPClientPBConfig() self.SMPPClientPBConfigInstance.authentication = authentication AMQPServiceConfigInstance = AmqpConfig() AMQPServiceConfigInstance.reconnectOnConnectionLoss = False # Launch AMQP Broker self.amqpBroker = AmqpFactory(AMQPServiceConfigInstance) self.amqpBroker.preConnect() self.amqpClient = reactor.connectTCP(AMQPServiceConfigInstance.host, AMQPServiceConfigInstance.port, self.amqpBroker) # Wait for AMQP Broker connection to get ready yield self.amqpBroker.getChannelReadyDeferred() # Launch the client manager server pbRoot = SMPPClientManagerPB(self.SMPPClientPBConfigInstance) yield pbRoot.addAmqpBroker(self.amqpBroker) p = portal.Portal(JasminPBRealm(pbRoot)) if not authentication: p.registerChecker(AllowAnonymousAccess()) else: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser('test_user', md5('test_password'.encode('ascii')).digest()) p.registerChecker(c) jPBPortalRoot = JasminPBPortalRoot(p) self.PBServer = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot)) self.pbPort = self.PBServer.getHost().port # Launch the router server self.RouterPBInstance = RouterPB(RouterPBConfig()) pbRoot.addRouterPB(self.RouterPBInstance) # Default SMPPClientConfig defaultSMPPClientId = '001-testconnector' self.defaultConfig = SMPPClientConfig( id=defaultSMPPClientId, username='******', reconnectOnConnectionFailure=True, port=9002, )
def setUp(self, authentication=False): SMPPServerTestCases.setUp(self) # Initiating config objects without any filename self.SMPPServerPBConfigInstance = SMPPServerPBConfig() self.SMPPServerPBConfigInstance.authentication = authentication # Launch the SMPPServerPB pbRoot = SMPPServerPB(self.SMPPServerPBConfigInstance) pbRoot.addSmpps(self.smpps_factory) p = portal.Portal(JasminPBRealm(pbRoot)) if not authentication: p.registerChecker(AllowAnonymousAccess()) else: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser('test_user', md5('test_password').digest()) p.registerChecker(c) jPBPortalRoot = JasminPBPortalRoot(p) self.PBServer = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot)) self.pbPort = self.PBServer.getHost().port
def startInterceptorPBService(self): """Start Interceptor PB server""" InterceptorPBConfigInstance = InterceptorPBConfig(self.options['config']) self.components['interceptor-pb-factory'] = InterceptorPB(InterceptorPBConfigInstance) # Set authentication portal p = portal.Portal(JasminPBRealm(self.components['interceptor-pb-factory'])) if InterceptorPBConfigInstance.authentication: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser(InterceptorPBConfigInstance.admin_username, InterceptorPBConfigInstance.admin_password) p.registerChecker(c) else: p.registerChecker(AllowAnonymousAccess()) jPBPortalRoot = JasminPBPortalRoot(p) # Add service self.components['interceptor-pb-server'] = reactor.listenTCP( InterceptorPBConfigInstance.port, pb.PBServerFactory(jPBPortalRoot), interface=InterceptorPBConfigInstance.bind)
def startSMPPClientManagerPBService(self): "Start SMPP Client Manager PB server" SMPPClientPBConfigInstance = SMPPClientPBConfig(self.options['config']) self.components['smppcm-pb-factory'] = SMPPClientManagerPB() self.components['smppcm-pb-factory'].setConfig( SMPPClientPBConfigInstance) # Set authentication portal p = portal.Portal(JasminPBRealm(self.components['smppcm-pb-factory'])) if SMPPClientPBConfigInstance.authentication: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser(SMPPClientPBConfigInstance.admin_username, SMPPClientPBConfigInstance.admin_password) p.registerChecker(c) else: p.registerChecker(AllowAnonymousAccess()) jPBPortalRoot = JasminPBPortalRoot(p) # Add service self.components['smppcm-pb-server'] = reactor.listenTCP( SMPPClientPBConfigInstance.port, pb.PBServerFactory(jPBPortalRoot), interface=SMPPClientPBConfigInstance.bind) # AMQP Broker is used to listen to submit_sm queues and publish to deliver_sm/dlr queues self.components['smppcm-pb-factory'].addAmqpBroker( self.components['amqp-broker-factory']) self.components['smppcm-pb-factory'].addRedisClient( self.components['rc']) self.components['smppcm-pb-factory'].addRouterPB( self.components['router-pb-factory']) # Add interceptor if enabled: if 'interceptor-pb-client' in self.components: self.components['smppcm-pb-factory'].addInterceptorPBClient( self.components['interceptor-pb-client'])