def setUp(self): HTTPApiTestCases.setUp(self) # Provision Router with additional Users and Routes u2 = User(2, Group(2), 'user2', 'correct') u2.mt_credential.setQuota('balance', 100.2) u2.mt_credential.setQuota('submit_sm_count', 30) 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)
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)
def setUp(self): yield HappySMSCTestCase.setUp(self) # Init self.group1 = Group('g1') self.user1 = User('1', self.group1, 'u1', 'password') self.c1 = SmppClientConnector('smpp_c1')
def parse_args_and_call_with_instance(self, *args, **kwargs): cmd = args[0] arg = args[1] # Empty line if cmd is None: return self.protocol.sendData() # Initiate jasmin.routing.jasminApi.Group with sessBuffer content if cmd == 'ok': if len(self.sessBuffer) != 1: return self.protocol.sendData('You must set Group id (gid) before saving !') group = {} for key, value in self.sessBuffer.items(): group[key] = value try: GroupInstance = Group(**group) # Hand the instance to fCallback return fCallback(self, GroupInstance) except Exception as e: return self.protocol.sendData('Error: %s' % str(e)) else: # Unknown key if cmd not in GroupKeyMap: return self.protocol.sendData('Unknown Group key: %s' % cmd) # Buffer key for later Group initiating GroupKey = GroupKeyMap[cmd] self.sessBuffer[GroupKey] = arg return self.protocol.sendData()
def fix_users_and_smppccs_09rc23(data, context=None): """Adding the new authorization 'set_hex_content' and fix smppccs with proto_id having a None string value""" if context == 'users': # Create new users and modify the mt_credential to include the new authorization new_data = [] for old_user in data: user = User( uid=old_user.uid, group=Group(old_user.group.gid), username=old_user.username, password=old_user.password, password_crypted=True, mt_credential=old_user.mt_credential, smpps_credential=old_user.smpps_credential) user.mt_credential.authorizations['set_hex_content'] = True user.mt_credential.authorizations['set_schedule_delivery_time'] = True new_data.append(user) return new_data elif context == 'smppccs': # Fix smppccs proto_id value for smppcc in data: if isinstance(smppcc['config'].protocol_id, str) and smppcc['config'].protocol_id.lower() == 'none': smppcc['config'].protocol_id = None return data
def setUp(self): self.opFactory = SMPPOperationFactory(SMPPClientConfig(id='test-id')) self.user = User(1, Group(100), 'username', 'password') self.pdu = self.opFactory.SubmitSM( source_addr=b'2', destination_addr=b'3', short_message=b'sunny day !', )
def setUp(self): yield SMSCSimulatorRecorder.setUp(self) self.SMSCPort.factory.buildProtocol = mock.Mock( wraps=self.SMSCPort.factory.buildProtocol) self.SubmitSmBill = SubmitSmBill( User('test_user', Group('test_group'), 'test_username', 'pwd'))
def group_status(data): """Changes impacted by #306 Will migrate groups to enable newly applied changes for enable/disable""" # Create new groups, they will have the enable/disable methods new_data = [] for old_group in data: group = Group(gid=old_group.gid) new_data.append(group) return new_data
def setUp(self): SMPPClientTestCases.setUp(self) # Provision a user and default route into RouterPB # Add throughput limit on user self.foo = User('u1', Group('test'), 'username', 'password') self.foo.mt_credential.setQuota('smpps_throughput', 2) self.c1 = SmppClientConnector(id_generator()) self.defaultroute = DefaultRoute(self.c1) self.provision_user_defaultroute(user=self.foo, defaultroute=self.defaultroute) self.stats = SMPPServerStatsCollector().get(cid=self.smpps_config.id)
def runScenario(Request, method): try: proxy_router = RouterPBProxy() yield proxy_router.connect('127.0.0.1', 8988, 'radmin', 'rpwd') if method == "POST": smppUser = Request['username'] smppPass = Request['password'] smppThroughput = Request['tp'] smppBindSessions = Request['sessions'] if not smppUser: raise NameError('user') if len(smppPass) == 0 or len(smppPass) > 8: raise NameError('pass') if not smppThroughput.isdigit(): raise NameError('tp') if not smppBindSessions.isdigit(): raise NameError('session') # Provisiong router with users smpp_cred = SmppsCredential() yield smpp_cred.setQuota('max_bindings', int(smppBindSessions)) mt_cred = MtMessagingCredential() yield mt_cred.setQuota('smpps_throughput', smppThroughput) #yield mt_cred.setQuota('submit_sm_count' , 500) g1 = Group('clients') u1 = User(uid=smppUser, group=g1, username=smppUser, password=smppPass, mt_credential=mt_cred, smpps_credential=smpp_cred) yield proxy_router.group_add(g1) yield proxy_router.user_add(u1) print "Success" if method == 'DELETE': smppUser = Request['username'] if not smppUser: raise NameError('user') yield proxy_router.user_remove(smppUser) except Exception, e: print "%s" % str(e)
def setUp(self): yield SMSCSimulatorRecorder.setUp(self) self.SMSCPort.factory.buildProtocol = mock.Mock(wraps=self.SMSCPort.factory.buildProtocol) config = SMPPClientConfig(id='defaultId') opFactory = SMPPOperationFactory(config) self.SubmitSmPDU = opFactory.SubmitSM( source_addr='1423', destination_addr='06155423', short_message='Hello world !', ) self.SubmitSmBill = SubmitSmBill(User('test_user', Group('test_group'), 'test_username', 'pwd'))
def setUp(self): # Initiating config objects without any filename # will lead to setting defaults and that's what we # need to run the tests self.routerpb_config = RouterPBConfig() # Instanciate RouterPB but will not launch a server # we only need the instance to access its .users attribute # for authentication self.routerpb_factory = RouterPB(self.routerpb_config, persistenceTimer=False) # Provision a user and default route into RouterPB self.foo = User('u1', Group('test'), 'username', 'password') self.c1 = SmppClientConnector(id_generator()) self.defaultroute = DefaultRoute(self.c1) self.provision_user_defaultroute(user=self.foo, defaultroute=self.defaultroute)
def runScenario(): try: ## First part, SMPP Client connector management ############################################### # Connect to SMPP Client management PB proxy proxy_smpp = SMPPClientManagerPBProxy() yield proxy_smpp.connect('127.0.0.1', 8989, 'cmadmin', 'cmpwd') # Provision SMPPClientManagerPBProxy with a connector and start it connector1 = { 'id': 'abc', 'username': '******', 'reconnectOnConnectionFailure': True } config1 = SMPPClientConfig(**connector1) yield proxy_smpp.add(config1) yield proxy_smpp.start('abc') ## Second part, User and Routing management ########################################### # Connect to Router PB proxy proxy_router = RouterPBProxy() yield proxy_router.connect('127.0.0.1', 8988, 'radmin', 'rpwd') # Provision RouterPBProxy with MT routes yield proxy_router.mtroute_add( DefaultRoute(SmppClientConnector('abc')), 0) routes = yield proxy_router.mtroute_get_all() print("Configured routes: \n\t%s" % pickle.loads(routes)) # Provisiong router with users g1 = Group(1) u1 = User(uid=1, group=g1, username='******', password='******') yield proxy_router.group_add(g1) yield proxy_router.user_add(u1) users = yield proxy_router.user_get_all() print("Users: \n\t%s" % pickle.loads(users)) ## Last, tear down ################## # Stop connector yield proxy_smpp.stop('abc') except Exception as e: print("ERROR RUNNING SCENARIO: %s" % str(e)) finally: reactor.stop()
def user_status(data): """Changes impacted by #306 Will migrate users to enable newly applied changes for enable/disable""" # Create new users, they will have the enable/disable methods new_data = [] for old_user in data: user = User(uid=old_user.uid, group=Group(old_user.group.gid), username=old_user.username, password=old_user.password, password_crypted=True, mt_credential=old_user.mt_credential, smpps_credential=old_user.smpps_credential) new_data.append(user) return new_data
def setUp(self): # Instanciate a RouterPB (a requirement for HTTPApi) RouterPBConfigInstance = RouterPBConfig() self.RouterPB_f = RouterPB() self.RouterPB_f.setConfig(RouterPBConfigInstance) # Provision Router with User and Route self.u1 = User(1, Group(1), 'fourat', 'correct') self.RouterPB_f.users.append(self.u1) self.RouterPB_f.mt_routing_table.add(DefaultRoute(SmppClientConnector('abc')), 0) # Instanciate a SMPPClientManagerPB (a requirement for HTTPApi) SMPPClientPBConfigInstance = SMPPClientPBConfig() SMPPClientPBConfigInstance.authentication = False clientManager_f = SMPPClientManagerPB() clientManager_f.setConfig(SMPPClientPBConfigInstance) httpApiConfigInstance = HTTPApiConfig() self.web = DummySite(HTTPApi(self.RouterPB_f, clientManager_f, httpApiConfigInstance))
def fix_users_09rc24(data, context=None): """Adding the new authorization 'set_schedule_delivery_time' value""" if context == 'users': # Create new users and modify the mt_credential to include the new authorization new_data = [] for old_user in data: user = User( uid=old_user.uid, group=Group(old_user.group.gid), username=old_user.username, password=old_user.password, password_crypted=True, mt_credential=old_user.mt_credential, smpps_credential=old_user.smpps_credential) user.mt_credential.authorizations['set_schedule_delivery_time'] = True new_data.append(user) return new_data
def setUp(self): self.group = Group(1) self.user = User(1, self.group, 'foo', 'bar')