def test_all(self): _cred = SmppsCredential() _cred.setAuthorization('bind', False) _cred.setQuota('max_bindings', 11) # Assert User adding extraCommands = [{ 'command': 'uid user_1' }, { 'command': 'smpps_cred authorization bind no' }, { 'command': 'smpps_cred quota max_bindings 11' }] self.add_user(r'jcli : ', extraCommands, GID='AnyGroup', Username='******') self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred) # Assert User updating _cred.setAuthorization('bind', True) _cred.setQuota('max_bindings', 66) extraCommands = [{ 'command': 'smpps_cred authorization bind y' }, { 'command': 'smpps_cred quota max_bindings 66' }] self.update_user(r'jcli : ', 'user_1', extraCommands) self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred)
def test_quota(self): _cred = SmppsCredential() _cred.setQuota('max_bindings', 10) # Assert User adding extraCommands = [{ 'command': 'uid user_1' }, { 'command': 'smpps_cred quota max_bindings 10' }] self.add_user(r'jcli : ', extraCommands, GID='AnyGroup', Username='******') self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred) # Assert User updating _cred.setQuota('max_bindings', 20) extraCommands = [{ 'command': 'password anypassword' }, { 'command': 'smpps_cred quota max_bindings 20' }] self.update_user(r'jcli : ', 'user_1', extraCommands) self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred)
def test_quota(self): _cred = SmppsCredential() _cred.setQuota('max_bindings', 10) # Assert User adding extraCommands = [{'command': 'uid user_1'}, {'command': 'smpps_cred quota max_bindings 10'}] self.add_user(r'jcli : ', extraCommands, GID = 'AnyGroup', Username = '******') self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred) # Assert User updating _cred.setQuota('max_bindings', 20) extraCommands = [{'command': 'password anypassword'}, {'command': 'smpps_cred quota max_bindings 20'}] self.update_user(r'jcli : ', 'user_1', extraCommands) self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred)
def test_increase_decrease_quota_int(self): # Add with initial quota extraCommands = [{'command': 'uid user_1'}, {'command': 'smpps_cred quota max_bindings 100'}] self.add_user(r'jcli : ', extraCommands, GID = 'AnyGroup', Username = '******') _cred = SmppsCredential() _cred.setQuota('max_bindings', 20) # Assert User increasing/decreasing quota extraCommands = [{'command': 'password anypassword'}, {'command': 'smpps_cred quota max_bindings -90'}] self.update_user(r'jcli : ', 'user_1', extraCommands) extraCommands = [{'command': 'password anypassword'}, {'command': 'smpps_cred quota max_bindings +10'}] self.update_user(r'jcli : ', 'user_1', extraCommands) self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred)
def test_increase_decrease_quota_invalid_type(self): # Add with initial quota extraCommands = [{'command': 'uid user_1'}, {'command': 'smpps_cred quota max_bindings 100'}] self.add_user(r'jcli : ', extraCommands, GID = 'AnyGroup', Username = '******') # Quota will remain the same since the following updates are using incorrect type _cred = SmppsCredential() _cred.setQuota('max_bindings', 100) # Assert User increasing/decreasing quota extraCommands = [{'command': 'password anypassword'}, {'command': 'smpps_cred quota max_bindings -90.2'}] self.update_user(r'jcli : ', 'user_1', extraCommands) extraCommands = [{'command': 'password anypassword'}, {'command': 'smpps_cred quota max_bindings +10.2'}] self.update_user(r'jcli : ', 'user_1', extraCommands) self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred)
def test_all(self): _cred = SmppsCredential() _cred.setAuthorization('bind', False) _cred.setQuota('max_bindings', 11) # Assert User adding extraCommands = [{'command': 'uid user_1'}, {'command': 'smpps_cred authorization bind no'}, {'command': 'smpps_cred quota max_bindings 11'}] self.add_user(r'jcli : ', extraCommands, GID = 'AnyGroup', Username = '******') self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred) # Assert User updating _cred.setAuthorization('bind', True) _cred.setQuota('max_bindings', 66) extraCommands = [{'command': 'smpps_cred authorization bind y'}, {'command': 'smpps_cred quota max_bindings 66'}] self.update_user(r'jcli : ', 'user_1', extraCommands) self._test_user_with_SmppsCredential('user_1', 'AnyGroup', 'AnyUsername', _cred)
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)