def test_get_messages_text(self): # создаем команду team_uid = func.add_team(self.api)['uid'] # приглашаем пользователей user1_jid = func.get_my_jid(self.api, team_uid) user2_jid = func.add_contact(self.api, team_uid, self.phone2)['jid'] user3_jid = func.add_contact(self.api, team_uid, self.phone3)['jid'] # добавляем участников к группе group_jid = func.add_group(self.api, team_uid)['jid'] func.add_member_to_group(self.api, team_uid, group_jid, user2_jid, 'member') func.add_member_to_group(self.api, team_uid, group_jid, user3_jid, 'admin') # добавляем сообщения api2 = auth.login_another_user(self.url, self.phone2, self.code2) api3 = auth.login_another_user(self.url, self.phone3, self.code3) pattern = 'msg' text = f'{pattern}_{tools.generate_random_string(7)}' msg1 = f'1_{text}' msg2 = f'2_{text}' msg3 = 'hello' func.send_text(self.api, team_uid, group_jid, msg1) func.send_text(api2, team_uid, group_jid, msg2) func.send_text(api3, team_uid, group_jid, msg3) params = { 'text': pattern, } resp = self.api.get_filtered_messages(team_uid, params).json() assert 'error' not in resp assert len(resp['result']['objects']) == 2 assert resp['result']['objects'][0]['content']['text'] == msg2 assert resp['result']['objects'][1]['content']['text'] == msg1
def test_get_contact_outsider(self): team_uid = func.add_team(self.api)['uid'] resp = self.api.get_contacts(team_uid).json() contact_jid = resp['result'][0]['jid'] api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.get_contact(team_uid, contact_jid).json() assert const.ACCESS_DENIED == resp['error']
def test_get_usage_exist_team_member(self): team = func.add_team(self.api) team_uid = team['uid'] func.add_contact(self.api, team_uid, self.phone2, role='member') api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.get_team_usage(team_uid).json() assert resp['error'] == const.ACCESS_DENIED
def test_delete_section_outsider(self): data = {'name': tools.generate_random_string()} exp_dict = self.api.add_section(self.team_uid, data).json() section_uid = exp_dict['result']['uid'] api2 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api2.delete_section(self.team_uid, section_uid).json() assert resp['error'] == const.ACCESS_DENIED
def test_upload_team_icon_outsider(self): resp = func.add_team(self.api) api2 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api2.upload_team_icon(resp['uid'], os.path.join(const.TD_FILES, 'tiger.jpg')) resp = resp.json() assert resp['error'] == const.ACCESS_DENIED
def test_get_usage_exist_team_outsider(self): resp = func.add_team(self.api) team_uid = resp['uid'] api2 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api2.get_team_usage(team_uid) resp = resp.json() assert resp['error'] == const.ACCESS_DENIED
def test_delete_contact_icon_another_user(self): team_uid = func.add_team(self.api)['uid'] resp = self.api.get_contacts(team_uid).json() contact_jid = resp['result'][0]['jid'] api2 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api2.delete_contact_icon(self.team_uid, contact_jid) resp = resp.json() assert const.ACCESS_DENIED == resp['error']
def test_invite_contact_outsider(self): team_uid = func.add_team(self.api)['uid'] data = {'phone': self.phone2, 'status': 'member'} self.api.add_contacts(team_uid, data) api2 = auth.login_another_user(self.url, self.phone4, self.code4) data = {'phone': self.phone3} resp = api2.add_contacts(team_uid, data).json() assert resp['error'] == const.ACCESS_DENIED
def test_send_help_outsider(self): team = func.add_team(self.api) team_uid = team['uid'] email = '*****@*****.**' text = 'I need help, outsider' api4 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api4.send_help(team_uid, email, text).json() assert resp['error'] == const.ACCESS_DENIED
def test_edit_team_name_member(self): team = func.add_team(self.api) team_uid = team['uid'] func.add_contact(self.api, team_uid, self.phone2, role='member') new_name = 'new_' + tools.generate_random_string() data = {'name': new_name} api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.edit_team(team_uid, data).json() assert resp['error'] == const.ACCESS_DENIED
def test_delete_exist_section_member(self): team_uid = func.add_team(self.api)['uid'] func.add_contact(self.api, team_uid, self.phone2, 'member') api2 = auth.login_another_user(self.url, self.phone2, self.code2) data = {'name': tools.generate_random_string()} exp_dict = self.api.add_section(team_uid, data).json() section_uid = exp_dict['result']['uid'] resp = api2.delete_section(team_uid, section_uid).json() assert resp['error'] == const.ACCESS_DENIED
def test_send_help_upload_outsider(self): team = func.add_team(self.api) team_uid = team['uid'] api4 = auth.login_another_user(self.url, self.phone4, self.code4) filename = 'word.docx' resp = api4.send_help_upload(team_uid, os.path.join(const.TD_FILES, filename)).json() assert resp['error'] == const.ACCESS_DENIED
def test_upload_contact_icon_another_user(self): resp = self.api.get_contacts(self.team_uid).json() contact_jid = resp['result'][0]['jid'] api2 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api2.upload_contact_icon( self.team_uid, contact_jid, os.path.join(const.TD_FILES, 'tiger.jpg')) resp = resp.json() assert const.ACCESS_DENIED == resp['error']
def test_get_sections_member(self): team_uid = func.add_team(self.api)['uid'] func.add_contact(self.api, team_uid, self.phone2, 'member')['jid'] api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.get_sections(team_uid) resp = resp.json() assert 'error' not in resp for item in resp['result']: assert 'name' in item
def test_edit_team_name_outsider(self): resp = func.add_team(self.api) team_uid = resp['uid'] new_name = 'new_' + tools.generate_random_string() data = {'name': new_name} api2 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api2.edit_team(team_uid, data) resp = resp.json() assert resp['error'] == const.ACCESS_DENIED
def test_upload_team_icon_member(self): team = func.add_team(self.api) team_uid = team['uid'] func.add_contact(self.api, team_uid, self.phone2, role='member') api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.upload_team_icon(team_uid, os.path.join(const.TD_FILES, 'tiger.jpg')) resp = resp.json() assert resp['error'] == const.ACCESS_DENIED
def test_get_team_member(self): team = func.add_team(self.api) team_uid = team['uid'] name = team['name'] func.add_contact(self.api, team_uid, self.phone2, role='member') api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.get_team(team_uid).json() assert 'error' not in resp assert resp['result']['uid'] == team_uid assert resp['result']['name'] == name
def test_edit_section_with_name_outsider(self): team_uid = func.add_team(self.api)['uid'] data = {'name': tools.generate_random_string()} exp_dict = self.api.add_section(team_uid, data).json() section_uid = exp_dict['result']['uid'] new_name = 'edit_' + tools.generate_random_string() data = {'name': new_name} api4 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api4.edit_section(team_uid, section_uid, data).json() assert resp['error'] == const.ACCESS_DENIED
def test_get_contact_another_user_role(self, role): team_uid = func.add_team(self.api)['uid'] data = {'phone': self.phone2, 'status': role} self.api.add_contacts(team_uid, data) resp = self.api.get_contacts(team_uid).json() contact_jid = resp['result'][1]['jid'] api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.get_contact(team_uid, contact_jid).json() assert 'error' not in resp assert contact_jid == resp['result']['jid']
def test_delete_contact_outsider(self): # создаем команду team_uid = func.add_team(self.api)['uid'] # получаем jid овнера команды resp = self.api.get_contacts(team_uid).json() contact_jid = resp['result'][0]['jid'] # пытаемся удалить контакт овнера пользователем из другой команды api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.delete_contact(team_uid, contact_jid).json() assert const.ACCESS_DENIED == resp['error']
def test_send_help_member(self): team = func.add_team(self.api) team_uid = team['uid'] func.add_contact(self.api, team_uid, self.phone2, role='member') email = '*****@*****.**' text = 'I need help. This is member of team.' api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.send_help(team_uid, email, text).json() assert 'error' not in resp assert resp['result'] == 'OK'
def test_get_botcommands_member(self): team_uid = func.add_team(self.api)['uid'] group_jid = func.add_group(self.api, team_uid)['jid'] user2_jid = func.add_contact(self.api, team_uid, self.phone2)['jid'] func.add_member_to_group(self.api, team_uid, group_jid, user2_jid, 'member') api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.get_botcommands(team_uid, group_jid).json() path = os.path.join(const.EXPECTED_RESULTS, 'bot_commands_member.json') expected = read_json(path) assert 'error' not in resp assert resp['result'] == expected['result']
def test_invite_contact_member_admin(self): team_uid = func.add_team(self.api)['uid'] data = {'phone': self.phone2, 'status': 'admin'} self.api.add_contacts(team_uid, data) api2 = auth.login_another_user(self.url, self.phone2, self.code2) data = {'phone': self.phone3} resp = api2.add_contacts(team_uid, data).json() resp2 = self.api.get_contacts(team_uid).json() assert 'error' not in resp assert self.phone3 == resp['result']['contact_phone'] assert self.phone3 == resp2['result'][0]['contact_phone']
def test_edit_contact_outsider(self): # создаем команду team_uid = func.add_team(self.api)['uid'] # получаем jid овнера команды resp = self.api.get_contacts(team_uid).json() contact_jid = resp['result'][0]['jid'] # изменяем контакт овнера пользователем не состоящим в команде api2 = auth.login_another_user(self.url, self.phone2, self.code2) data = {'family_name': 'Test'} resp = api2.edit_contact(team_uid, contact_jid, data).json() assert const.ACCESS_DENIED == resp['error']
def test_move_section_move_before_outsider(self): team_uid = func.add_team(self.api)['uid'] resp = self.api.get_sections(team_uid).json() before_uid = resp['result'][0]['uid'] name = 'before_' + tools.generate_random_string(10) data = {'name': name, 'move_after': before_uid} resp = self.api.add_section(team_uid, data).json() current_uid = resp['result']['uid'] api4 = auth.login_another_user(self.url, self.phone4, self.code4) resp = api4.set_section_move_before(team_uid, current_uid, before_uid).json() assert resp['error'] == const.ACCESS_DENIED
def test_edit_section_with_name_admin(self): team_uid = func.add_team(self.api)['uid'] func.add_contact(self.api, team_uid, self.phone2, 'admin') data = {'name': tools.generate_random_string()} exp_dict = self.api.add_section(team_uid, data).json() section_uid = exp_dict['result']['uid'] new_name = 'edit_' + tools.generate_random_string() data = {'name': new_name} api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.edit_section(team_uid, section_uid, data).json() assert 'error' not in resp assert resp['result']['uid'] == section_uid assert resp['result']['name'] == new_name
def test_send_help_upload_member(self): team = func.add_team(self.api) team_uid = team['uid'] func.add_contact(self.api, team_uid, self.phone2, role='member') api2 = auth.login_another_user(self.url, self.phone2, self.code2) filename = 'word.docx' resp = api2.send_help_upload(team_uid, os.path.join(const.TD_FILES, filename)).json() assert 'error' not in resp assert resp['result']['name'] == filename assert filename in resp['result']['url'] assert resp['result']['size'] == 11573
def test_get_messages_sender(self): # создаем команду team_uid = func.add_team(self.api)['uid'] # приглашаем пользователей user1_jid = func.get_my_jid(self.api, team_uid) user2_jid = func.add_contact(self.api, team_uid, self.phone2)['jid'] user3_jid = func.add_contact(self.api, team_uid, self.phone3)['jid'] # добавляем участников к группе group_jid = func.add_group(self.api, team_uid)['jid'] func.add_member_to_group(self.api, team_uid, group_jid, user2_jid, 'member') func.add_member_to_group(self.api, team_uid, group_jid, user3_jid, 'admin') # добавляем сообщения api2 = auth.login_another_user(self.url, self.phone2, self.code2) api3 = auth.login_another_user(self.url, self.phone3, self.code3) text = 'msg_{}'.format(tools.generate_random_string(7)) func.send_text(self.api, team_uid, group_jid, text) func.send_text(api2, team_uid, group_jid, text) func.send_text(api3, team_uid, group_jid, text) params = { 'sender': f'{user1_jid},{user2_jid}', } resp = self.api.get_filtered_messages(team_uid, params).json() assert 'error' not in resp assert tools.is_items_exist_in_list_of_dict( resp['result']['objects'], 'from', user1_jid, ) assert tools.is_items_exist_in_list_of_dict( resp['result']['objects'], 'from', user2_jid, ) assert not tools.is_items_exist_in_list_of_dict( resp['result']['objects'], 'from', user3_jid, )
def test_edit_contact_another_user_not_admin(self): # создаем команду team_uid = func.add_team(self.api)['uid'] # добавляем контакт с правами админа data = {'phone': self.phone2, 'status': 'member'} self.api.add_contacts(team_uid, data) # получаем jid овнера команды resp = self.api.get_contacts(team_uid).json() contact_jid = resp['result'][1]['jid'] # изменяем контакт овнера вторым узером админом api2 = auth.login_another_user(self.url, self.phone2, self.code2) data = {'family_name': 'Test'} resp = api2.edit_contact(team_uid, contact_jid, data).json() assert const.ACCESS_DENIED == resp['error']
def test_move_section_move_before_admin(self): team_uid = func.add_team(self.api)['uid'] func.add_contact(self.api, team_uid, self.phone2, 'admin') resp = self.api.get_sections(team_uid).json() before_uid = resp['result'][0]['uid'] name = 'before_' + tools.generate_random_string(10) data = {'name': name, 'move_after': before_uid} resp = self.api.add_section(team_uid, data).json() current_uid = resp['result']['uid'] api2 = auth.login_another_user(self.url, self.phone2, self.code2) resp = api2.set_section_move_before(team_uid, current_uid, before_uid).json() resp = self.api.get_sections(team_uid) resp = resp.json() assert 'error' not in resp assert resp['result'][1]['uid'] == before_uid assert resp['result'][0]['uid'] == current_uid