def test_get_users(self): user_name = random_str() password = random_str() register(RgstHttpRpc, "", user_name, password, 1, "rdm1", urllib.quote(Signer().gen_sign("", user_name, password, 1, "rdm1"))) token = LoginGetToken(RgstHttpRpc, user_name, password) result = get_users(RgstHttpRpc, token, [user_name]) self.assertTrue(result['user_info_ls'][0]['user_name'] == user_name) cancel(RgstHttpRpc, "", user_name, password, urllib.quote(Signer().gen_sign("", user_name, password)))
def test_wechat_user_login(self): user_name = random_str() password = random_str() register(RgstHttpRpc, "", user_name, password, enum.WECHAT_USER, "TEST1", urllib.quote(Signer().gen_sign("", user_name, password, enum.WECHAT_USER, "TEST1"))) result = login(RgstHttpRpc, user_name, password, type=enum.WECHAT_USER) assert result["result"] == error_code.ERROR_SUCCESS LoginGetToken(RgstHttpRpc, user_name, password) LoginGetTokenUser(RgstHttpRpc, user_name, password) cancel(RgstHttpRpc, "", user_name, password, urllib.quote(Signer().gen_sign("", user_name, password)), enum.WECHAT_USER)
def test_register_reregister(self): user_name = "random_str111" password = "******" relogin_times = 2 for _ in xrange(relogin_times): result = register(RgstHttpRpc, "", user_name, password, 1, "rdm1", urllib.quote(Signer().gen_sign("", user_name, password, 1, "rdm1"))) self.assertTrue(result['result'] == error_code.ERROR_SUCCESS) result = cancel(RgstHttpRpc, "", user_name, password, urllib.quote(Signer().gen_sign("", user_name, password))) self.assertTrue(result['result'] == error_code.ERROR_SUCCESS)
def test_device_user_get_users_device_type(self): user_name = random_str() password = random_str() dtype = choice_device_type() result = register(RgstHttpRpc, "", user_name, password, enum.DEVICE_USER, "TEST1", urllib.quote(Signer().gen_sign("", user_name, password, enum.DEVICE_USER, "TEST1")), device_type=dtype) assert result["result"] == error_code.ERROR_SUCCESS token = LoginGetToken(RgstHttpRpc, user_name, password) result = get_users(RgstHttpRpc, token, [user_name]) self.assertTrue(int(result['user_info_ls'][0]['device_type']['code']) == int(dtype)) cancel(RgstHttpRpc, "", user_name, password, urllib.quote(Signer().gen_sign("", user_name, password)))
def test_user_banding_eachother(self): user_name2 = random_str() password2 = random_str() user_name3 = random_str() password3 = random_str() # register register(RgstHttpRpc, "", user_name2, password2, 1, "rdm2", urllib.quote(Signer().gen_sign("", user_name2, password2, 1, "rdm2"))) register(RgstHttpRpc, "", user_name3, password3, 1, "rdm3", urllib.quote(Signer().gen_sign("", user_name3, password3, 1, "rdm3"))) # banding banding_result = set_user_banding(RgstHttpRpc, user_name2, [user_name3]) self.assertTrue(banding_result.get("result", error_code.ERROR_SUCCESS) == error_code.ERROR_SUCCESS) # get banding user_name2 banding_result = get_user_banding(RgstHttpRpc, user_name2) self.assertTrue(user_name3 == banding_result['roster_item'][0]['nickname']) # get banding user_name3 banding_result = get_user_banding(RgstHttpRpc, user_name3) self.assertTrue(user_name2 == banding_result['roster_item'][0]['nickname']) # unbanding unbanding_result = set_user_unbanding(RgstHttpRpc, user_name2, [user_name3]) self.assertTrue(unbanding_result.get("result", error_code.ERROR_SUCCESS) == error_code.ERROR_SUCCESS) # get banding user_name2 banding_result = get_user_banding(RgstHttpRpc, user_name2) self.assertTrue(not banding_result['roster_item']) # get banding user_name3 banding_result = get_user_banding(RgstHttpRpc, user_name3) self.assertTrue(not banding_result['roster_item']) # cancel cancel(RgstHttpRpc, "", user_name2, password2, urllib.quote(Signer().gen_sign("", user_name2, password2))) cancel(RgstHttpRpc, "", user_name3, password3, urllib.quote(Signer().gen_sign("", user_name3, password3)))
def wcmt_me_unsubscribe(*args, **kwargs): """ wechat message event: unsubscribe/取消关注 :param args: :param kwargs: :return: """ """ 由于openfire不支持用户名大写:有大写的话,roster关系表会转化成小写 所以将openid转化为小写 """ result = cancel(ServiceMgrCacher().get_connection(US_REGISTER, protocol=PT_HTTPS), "", kwargs['body']['FromUserName'].lower(), WECHAT_PASSWORD, type=enum.WECHAT_USER) assert result['result'] == ERROR_SUCCESS
def test_register_cancel_user(self): user_name = random_str() password = random_str() register(RgstHttpRpc, "", user_name, password, 1, "rdm1", urllib.quote(Signer().gen_sign("", user_name, password, 1, "rdm1"))) user_name2 = random_str() password2 = random_str() register(RgstHttpRpc, "", user_name2, password2, 1, "rdm2", urllib.quote(Signer().gen_sign("", user_name2, password2, 1, "rdm2"))) user_name3 = random_str() password3 = random_str() register(RgstHttpRpc, "", user_name3, password3, 1, "rdm3", urllib.quote(Signer().gen_sign("", user_name3, password3, 1, "rdm3"))) cancel(RgstHttpRpc, "", user_name, password, urllib.quote(Signer().gen_sign("", user_name, password))) cancel(RgstHttpRpc, "", user_name2, password2, urllib.quote(Signer().gen_sign("", user_name2, password2))) cancel(RgstHttpRpc, "", user_name3, password3, urllib.quote(Signer().gen_sign("", user_name3, password3)))
def test_user_banding_userls(self): user_name = random_str() password = random_str() user_name2 = random_str() password2 = random_str() user_name3 = random_str() password3 = random_str() # register register(RgstHttpRpc, "", user_name, password, 1, "rdm1", urllib.quote(Signer().gen_sign("", user_name, password, 1, "rdm1"))) register(RgstHttpRpc, "", user_name2, password2, 1, "rdm2", urllib.quote(Signer().gen_sign("", user_name2, password2, 1, "rdm2"))) register(RgstHttpRpc, "", user_name3, password3, 1, "rdm3", urllib.quote(Signer().gen_sign("", user_name3, password3, 1, "rdm3"))) # get banding banding_result = get_user_banding(RgstHttpRpc, user_name) self.assertTrue(not banding_result['roster_item']) # banding banding_result = set_user_banding(RgstHttpRpc, user_name, [user_name2, user_name3]) self.assertTrue(banding_result.get("result", error_code.ERROR_SUCCESS) == error_code.ERROR_SUCCESS) # get banding banding_result = get_user_banding(RgstHttpRpc, user_name) banding_nickname_ls = [roster_item['nickname'] for roster_item in banding_result['roster_item']] self.assertTrue(user_name2 in banding_nickname_ls) self.assertTrue(user_name3 in banding_nickname_ls) # unbanding unbanding_result = set_user_unbanding(RgstHttpRpc, user_name, [user_name2, user_name3]) self.assertTrue(unbanding_result.get("result", error_code.ERROR_SUCCESS) == error_code.ERROR_SUCCESS) # get banding banding_result = get_user_banding(RgstHttpRpc, user_name) self.assertRaises(not banding_result['roster_item']) # cancel cancel(RgstHttpRpc, "", user_name, password, urllib.quote(Signer().gen_sign("", user_name, password))) cancel(RgstHttpRpc, "", user_name2, password2, urllib.quote(Signer().gen_sign("", user_name2, password2))) cancel(RgstHttpRpc, "", user_name3, password3, urllib.quote(Signer().gen_sign("", user_name3, password3)))
def CancelTestUsers(http_rpc=ServiceMgrCacher().get_connection(ST_REGISTER, protocol=PT_HTTPS)): cancel(http_rpc, "", UserName1, Password1, urllib.quote(Signer().gen_sign("", UserName1, Password1))) cancel(http_rpc, "", UserName2, Password2, urllib.quote(Signer().gen_sign("", UserName2, Password2))) cancel(http_rpc, "", UserName3, Password3, urllib.quote(Signer().gen_sign("", UserName3, Password3))) cancel(http_rpc, "", UserName4, Password4, urllib.quote(Signer().gen_sign("", UserName4, Password4)))