def setUp(self, authentication = False): "This will launch InterceptorPB and provide a client connected to it." # Launch a client in a disconnected state # it will be connected on demand through the self.ipb_connect() method self.ipb_client = InterceptorPBProxy() yield ProvisionWithoutInterceptorPB.setUp(self) # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests InterceptorPBConfigInstance = InterceptorPBConfig() # Launch the interceptor server pbInterceptor_factory = InterceptorPB() pbInterceptor_factory.setConfig(InterceptorPBConfigInstance) # Configure portal p = portal.Portal(JasminPBRealm(pbInterceptor_factory)) if not authentication: p.registerChecker(AllowAnonymousAccess()) else: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser('test_user', md5('test_password').digest()) p.registerChecker(c) jPBPortalRoot = JasminPBPortalRoot(p) self.pbInterceptor_server = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot)) self.pbInterceptor_port = self.pbInterceptor_server.getHost().port
def setUp(self, authentication=False): "This will launch InterceptorPB and provide a client connected to it." # Launch a client in a disconnected state # it will be connected on demand through the self.ipb_connect() method self.ipb_client = InterceptorPBProxy() yield ProvisionWithoutInterceptorPB.setUp(self) # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests InterceptorPBConfigInstance = InterceptorPBConfig() # Launch the interceptor server pbInterceptor_factory = InterceptorPB() pbInterceptor_factory.setConfig(InterceptorPBConfigInstance) # Configure portal p = portal.Portal(JasminPBRealm(pbInterceptor_factory)) if not authentication: p.registerChecker(AllowAnonymousAccess()) else: c = InMemoryUsernamePasswordDatabaseDontUse() c.addUser("test_user", md5("test_password").digest()) p.registerChecker(c) jPBPortalRoot = JasminPBPortalRoot(p) self.pbInterceptor_server = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot)) self.pbInterceptor_port = self.pbInterceptor_server.getHost().port
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 startInterceptorPBService(self): "Start Interceptor PB server" InterceptorPBConfigInstance = InterceptorPBConfig( self.options['config']) self.components['interceptor-pb-factory'] = InterceptorPB() self.components['interceptor-pb-factory'].setConfig( 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 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')