def test_positive_refresh_usergroup_with_ad(self, member_group, ad_data, ldap_tear_down): """Verify the usergroup-sync functionality in AD Auth Source :id: 2e913e76-49c3-11eb-b4c6-d46d6dd3b5b2 :customerscenario: true :CaseImportance: Medium :bz: 1901392 :parametrized: yes :expectedresults: external user-group sync works as expected automatically based on user-sync """ ad_data = ad_data() group_base_dn = ','.join(ad_data['group_base_dn'].split(',')[1:]) LOGEDIN_MSG = "Using configured credentials for user '{0}'." auth_source = make_ldap_auth_source( { 'name': gen_string('alpha'), 'onthefly-register': 'true', 'host': ad_data['ldap_hostname'], 'server-type': LDAP_SERVER_TYPE['CLI']['ad'], 'attr-login': LDAP_ATTR['login_ad'], 'attr-firstname': LDAP_ATTR['firstname'], 'attr-lastname': LDAP_ATTR['surname'], 'attr-mail': LDAP_ATTR['mail'], 'account': ad_data['ldap_user_name'], 'account-password': ad_data['ldap_user_passwd'], 'base-dn': ad_data['base_dn'], 'groups-base': group_base_dn, } ) # assert auth_source['account']['groups-base'] == group_base_dn viewer_role = Role.info({'name': 'Viewer'}) user_group = make_usergroup() make_usergroup_external( { 'auth-source-id': auth_source['server']['id'], 'user-group-id': user_group['id'], 'name': member_group, } ) UserGroup.add_role({'id': user_group['id'], 'role-id': viewer_role['id']}) user_group = UserGroup.info({'id': user_group['id']}) result = Auth.with_user( username=ad_data['ldap_user_name'], password=ad_data['ldap_user_passwd'] ).status() assert LOGEDIN_MSG.format(ad_data['ldap_user_name']) in result[0]['message'] UserGroupExternal.refresh({'user-group-id': user_group['id'], 'name': member_group}) user_group = UserGroup.info({'id': user_group['id']}) list = Role.with_user( username=ad_data['ldap_user_name'], password=ad_data['ldap_user_passwd'] ).list() assert len(list) > 1
def test_positive_delete_by_id(self): """Create user group with valid data and then delete it using its ID @id: b60b4da7-9d1b-487d-89e5-ebf3aa2218d6 @assert: User group is deleted successfully """ user_group = make_usergroup() UserGroup.delete({'id': user_group['id']}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'id': user_group['id']})
def test_positive_delete_by_id(self): """Create user group with valid data and then delete it using its ID @feature: Usergroup @assert: User group is deleted successfully """ user_group = make_usergroup() UserGroup.delete({'id': user_group['id']}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'id': user_group['id']})
def test_negative_create_with_name(self): """Attempt to create user group with invalid name. @Feature: Usergroup @Assert: User group is not created. """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIFactoryError): make_usergroup({'name': name}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'name': name})
def test_positive_delete_by_name(self): """Create user group with valid name and then delete it using that name @feature: Usergroup @assert: User group is deleted successfully """ for name in valid_data_list(): with self.subTest(name): user_group = make_usergroup({'name': name}) UserGroup.delete({'name': user_group['name']}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'name': user_group['name']})
def test_positive_delete_with_user_by_id(self): """Create new user group using valid user attached to that group. Then delete that user group using id of that group as a parameter @Feature: Usergroup @Assert: User group is deleted successfully. """ user = make_user() user_group = make_usergroup({'user-ids': user['id']}) UserGroup.delete({'id': user_group['id']}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'id': user_group['id']})
def test_positive_delete_with_user_by_id(self): """Create new user group using valid user attached to that group. Then delete that user group using id of that group as a parameter :id: 34ffa204-9376-41f2-aca1-edf29f553957 :expectedresults: User group is deleted successfully. :CaseImportance: Critical """ user = make_user() user_group = make_usergroup({'user-ids': user['id']}) UserGroup.delete({'id': user_group['id']}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'id': user_group['id']})
def test_positive_delete_by_name(self): """Create user group with valid name and then delete it using that name :id: 359b1806-64c5-42ec-9448-991e82f70e98 :expectedresults: User group is deleted successfully :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): user_group = make_usergroup({'name': name}) UserGroup.delete({'name': user_group['name']}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'name': user_group['name']})
def test_negative_create_with_name(self): """Attempt to create user group with invalid name. :id: 79d2d28d-a0d9-42ab-ba88-c259a463533a :expectedresults: User group is not created. :CaseImportance: Critical """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(CLIFactoryError): make_usergroup({'name': name}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'name': name})
def test_positive_CRUD(self): """Create new user group with valid elements that attached group. List the user group, update and delete it. :id: bacef0e3-31dd-4991-93f7-f54fbe64d0f0 :expectedresults: User group is created, listed, updated and deleted successfully. :CaseImportance: Critical """ user = make_user() ug_name = random.choice(list(valid_data_list().values())) role_name = random.choice(list(valid_data_list().values())) role = make_role({'name': role_name}) sub_user_group = make_usergroup() # Create user_group = make_usergroup({ 'user-ids': user['id'], 'name': ug_name, 'role-ids': role['id'], 'user-group-ids': sub_user_group['id'], }) self.assertEqual(user_group['name'], ug_name) self.assertEqual(user_group['users'][0], user['login']) self.assertEqual(len(user_group['roles']), 1) self.assertEqual(user_group['roles'][0], role_name) self.assertEqual(user_group['user-groups'][0]['usergroup'], sub_user_group['name']) # List result_list = UserGroup.list( {'search': 'name={0}'.format(user_group['name'])}) self.assertTrue(len(result_list) > 0) self.assertTrue(UserGroup.exists(search=('name', user_group['name']))) # Update new_name = random.choice(list(valid_data_list().values())) UserGroup.update({'id': user_group['id'], 'new-name': new_name}) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['name'], new_name) # Delete UserGroup.delete({'name': user_group['name']}) with self.assertRaises(CLIReturnCodeError): UserGroup.info({'name': user_group['name']})
def test_positive_CRUD(): """Create new user group with valid elements that attached group. List the user group, update and delete it. :id: bacef0e3-31dd-4991-93f7-f54fbe64d0f0 :expectedresults: User group is created, listed, updated and deleted successfully. :CaseImportance: Critical """ user = make_user() ug_name = random.choice(valid_usernames_list()) role_name = random.choice(valid_usernames_list()) role = make_role({'name': role_name}) sub_user_group = make_usergroup() # Create user_group = make_usergroup({ 'user-ids': user['id'], 'name': ug_name, 'role-ids': role['id'], 'user-group-ids': sub_user_group['id'], }) assert user_group['name'] == ug_name assert user_group['users'][0] == user['login'] assert len(user_group['roles']) == 1 assert user_group['roles'][0] == role_name assert user_group['user-groups'][0]['usergroup'] == sub_user_group['name'] # List result_list = UserGroup.list( {'search': 'name={}'.format(user_group['name'])}) assert len(result_list) > 0 assert UserGroup.exists(search=('name', user_group['name'])) # Update new_name = random.choice(valid_usernames_list()) UserGroup.update({'id': user_group['id'], 'new-name': new_name}) user_group = UserGroup.info({'id': user_group['id']}) assert user_group['name'] == new_name # Delete UserGroup.delete({'name': user_group['name']}) with pytest.raises(CLIReturnCodeError): UserGroup.info({'name': user_group['name']})
def test_positive_add_and_remove_elements(self): """Create new user group. Add and remove several element from the group. :id: a4ce8724-d3c8-4c00-9421-aaa40394134d :BZ: 1395229 :expectedresults: Elements are added to user group and then removed successfully. :CaseLevel: Integration """ role = make_role() user_group = make_usergroup() user = make_user() sub_user_group = make_usergroup() # Add elements by id UserGroup.add_role({'id': user_group['id'], 'role-id': role['id']}) UserGroup.add_user({'id': user_group['id'], 'user-id': user['id']}) UserGroup.add_user_group({ 'id': user_group['id'], 'user-group-id': sub_user_group['id'] }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['roles']), 1) self.assertEqual(user_group['roles'][0], role['name']) self.assertEqual(len(user_group['users']), 1) self.assertEqual(user_group['users'][0], user['login']) self.assertEqual(len(user_group['user-groups']), 1) self.assertEqual(user_group['user-groups'][0]['usergroup'], sub_user_group['name']) # Remove elements by name UserGroup.remove_role({'id': user_group['id'], 'role': role['name']}) UserGroup.remove_user({'id': user_group['id'], 'user': user['login']}) UserGroup.remove_user_group({ 'id': user_group['id'], 'user-group': sub_user_group['name'] }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['roles']), 0) self.assertEqual(len(user_group['users']), 0) self.assertEqual(len(user_group['user-groups']), 0)
def test_positive_add_user_group_by_id(self): """Create two new user groups. Then add one user group to another by id @Feature: Usergroup @Assert: User group is added to another user group successfully. """ sub_user_group = make_usergroup() user_group = make_usergroup() UserGroup.add_user_group({ 'id': user_group['id'], 'user-group-id': sub_user_group['id'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['user-groups'][0], sub_user_group['name'])
def test_positive_add_role_by_name(self): """Create new user group and new role. Then add created role to user group by name @Feature: Usergroup @Assert: Role is added to user group successfully. """ role = make_role() user_group = make_usergroup() UserGroup.add_role({ 'id': user_group['id'], 'role': role['name'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['roles'][0], role['name'])
def test_positive_add_user_by_name(self): """Create new user group and new user. Then add created user to user group by name @Feature: Usergroup @Assert: User is added to user group successfully. """ user = make_user() user_group = make_usergroup() UserGroup.add_user({ 'id': user_group['id'], 'user': user['login'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['users'][0], user['login'])
def test_positive_remove_role_by_name(self): """Create new user group using valid role attached to that group. Then remove that role from user group by name @Feature: Usergroup @Assert: Role is removed from user group successfully. """ role = make_role() user_group = make_usergroup({'role-ids': role['id']}) self.assertEqual(len(user_group['roles']), 1) UserGroup.remove_role({ 'id': user_group['id'], 'role': role['name'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['roles']), 0)
def test_positive_add_user_group_by_id(self): """Create two new user groups. Then add one user group to another by id @id: f041d325-93c0-4799-88d7-5ece65568266 @Assert: User group is added to another user group successfully. @CaseLevel: Integration """ sub_user_group = make_usergroup() user_group = make_usergroup() UserGroup.add_user_group({ 'id': user_group['id'], 'user-group-id': sub_user_group['id'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['user-groups'][0], sub_user_group['name'])
def test_positive_remove_usergroup_by_name(self): """Create new user group using another user group attached to the initial group. Then remove that attached user group by name @Feature: Usergroup @Assert: User group is removed from initial one successfully. """ sub_user_group = make_usergroup() user_group = make_usergroup({'user-group-ids': sub_user_group['id']}) self.assertEqual(len(user_group['user-groups']), 1) UserGroup.remove_user_group({ 'id': user_group['id'], 'user-group': sub_user_group['name'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['user-groups']), 0)
def test_positive_remove_user_by_name(self): """Create new user group using valid user attached to that group. Then remove that user from user group by name @Feature: Usergroup @Assert: User is removed from user group successfully. """ user = make_user() user_group = make_usergroup({'user-ids': user['id']}) self.assertEqual(len(user_group['users']), 1) UserGroup.remove_user({ 'id': user_group['id'], 'user': user['login'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['users']), 0)
def test_positive_update_by_id(self): """Update existing user group with different valid names. Use id of the user group as a parameter @id: bed911fe-da39-4798-a5d2-8a0467bfacc3 @Assert: User group is update successfully. """ user_group = make_usergroup() for new_name in valid_data_list(): with self.subTest(new_name): UserGroup.update({ 'id': user_group['id'], 'new-name': new_name, }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['name'], new_name)
def test_positive_update_by_name(self): """Update existing user group with different valid names. Use name of the user group as a parameter @Feature: Usergroup @Assert: User group is update successfully. """ user_group = make_usergroup() for new_name in valid_data_list(): with self.subTest(new_name): UserGroup.update({ 'name': user_group['name'], 'new-name': new_name, }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['name'], new_name)
def test_positive_remove_user_assigned_to_usergroup(): """Create new user and assign it to user group. Then remove that user. :id: 2a2623ce-4723-4402-aae7-8675473fd8bd :expectedresults: User should delete successfully. :CaseLevel: Integration :BZ: 1667704 """ user = make_user() user_group = make_usergroup() UserGroup.add_user({'id': user_group['id'], 'user-id': user['id']}) User.delete({'id': user['id']}) user_group = UserGroup.info({'id': user_group['id']}) assert user['login'] not in user_group['users']
def test_positive_add_user_by_name(self): """Create new user group and new user. Then add created user to user group by name :id: f622eb11-a3d2-4a25-8889-766133750431 :expectedresults: User is added to user group successfully. :CaseLevel: Integration """ user = make_user() user_group = make_usergroup() UserGroup.add_user({ 'id': user_group['id'], 'user': user['login'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['users'][0], user['login'])
def test_positive_add_user_by_id(self): """Create new user group and new user. Then add created user to user group by id :id: f2972e48-67c3-4dc9-8c4b-aa550086afb7 :expectedresults: User is added to user group successfully. :CaseLevel: Integration """ user = make_user() user_group = make_usergroup() UserGroup.add_user({ 'id': user_group['id'], 'user-id': user['id'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['users'][0], user['login'])
def test_positive_add_role_by_name(self): """Create new user group and new role. Then add created role to user group by name :id: 181bf2d5-0650-4fb0-890c-475eac3306a2 :expectedresults: Role is added to user group successfully. :CaseLevel: Integration """ role = make_role() user_group = make_usergroup() UserGroup.add_role({ 'id': user_group['id'], 'role': role['name'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['roles'][0], role['name'])
def test_positive_add_role_by_id(self): """Create new user group and new role. Then add created role to user group by id :id: a4ce8724-d3c8-4c00-9421-aaa40394134d :expectedresults: Role is added to user group successfully. :CaseLevel: Integration """ role = make_role() user_group = make_usergroup() UserGroup.add_role({ 'id': user_group['id'], 'role-id': role['id'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['roles'][0], role['name'])
def test_positive_add_user_group_by_name(self): """Create two new user groups. Then add one user group to another by name @id: de60c347-b440-45c6-8e79-19aa0d338099 @Assert: User group is added to another user group successfully. @CaseLevel: Integration """ sub_user_group = make_usergroup() user_group = make_usergroup() UserGroup.add_user_group({ 'id': user_group['id'], 'user-group': sub_user_group['name'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['user-groups'][0], sub_user_group['name'])
def test_negative_update_by_name(self): """Attempt to update existing user group using different invalid names. Use name of the user group as a parameter @Feature: Usergroup @Assert: User group is not updated. """ user_group = make_usergroup() for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(CLIReturnCodeError): UserGroup.update({ 'name': user_group['name'], 'new-name': new_name, }) user_group = UserGroup.info({'id': user_group['id']}) self.assertNotEqual(user_group['name'], new_name)
def test_positive_remove_usergroup_by_name(self): """Create new user group using another user group attached to the initial group. Then remove that attached user group by name :id: 45a070b5-60b1-4c8c-8171-9d63e0a55698 :expectedresults: User group is removed from initial one successfully. :CaseLevel: Integration """ sub_user_group = make_usergroup() user_group = make_usergroup({'user-group-ids': sub_user_group['id']}) self.assertEqual(len(user_group['user-groups']), 1) UserGroup.remove_user_group({ 'id': user_group['id'], 'user-group': sub_user_group['name'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['user-groups']), 0)
def test_positive_remove_usergroup_by_id(self): """Create new user group using another user group attached to the initial group. Then remove that attached user group by id :id: e7e8ccb2-a93d-420d-b71e-218ffbb428b4 :expectedresults: User group is removed from initial one successfully. :CaseLevel: Integration """ sub_user_group = make_usergroup() user_group = make_usergroup({'user-group-ids': sub_user_group['id']}) self.assertEqual(len(user_group['user-groups']), 1) UserGroup.remove_user_group({ 'id': user_group['id'], 'user-group-id': sub_user_group['id'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['user-groups']), 0)
def test_positive_remove_user_by_name(self): """Create new user group using valid user attached to that group. Then remove that user from user group by name :id: e99b215b-05bb-4e7b-a11a-cd506d88df6c :expectedresults: User is removed from user group successfully. :CaseLevel: Integration """ user = make_user() user_group = make_usergroup({'user-ids': user['id']}) self.assertEqual(len(user_group['users']), 1) UserGroup.remove_user({ 'id': user_group['id'], 'user': user['login'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['users']), 0)
def test_positive_remove_user_by_id(self): """Create new user group using valid user attached to that group. Then remove that user from user group by id :id: 9ae91110-88dd-4449-82c7-59f626fdd2be :expectedresults: User is removed from user group successfully. :CaseLevel: Integration """ user = make_user() user_group = make_usergroup({'user-ids': user['id']}) self.assertEqual(len(user_group['users']), 1) UserGroup.remove_user({ 'id': user_group['id'], 'user-id': user['id'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['users']), 0)
def test_positive_remove_role_by_id(self): """Create new user group using valid role attached to that group. Then remove that role from user group by id :id: f086e7f0-4a24-4097-8ec6-3f698ac926ba :expectedresults: Role is removed from user group successfully. :CaseLevel: Integration """ role = make_role() user_group = make_usergroup({'role-ids': role['id']}) self.assertEqual(len(user_group['roles']), 1) UserGroup.remove_role({ 'id': user_group['id'], 'role-id': role['id'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['roles']), 0)
def test_positive_remove_role_by_name(self): """Create new user group using valid role attached to that group. Then remove that role from user group by name :id: 0a5fdeaf-a05f-4153-b2c8-c5f8745cbb80 :expectedresults: Role is removed from user group successfully. :CaseLevel: Integration """ role = make_role() user_group = make_usergroup({'role-ids': role['id']}) self.assertEqual(len(user_group['roles']), 1) UserGroup.remove_role({ 'id': user_group['id'], 'role': role['name'], }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(len(user_group['roles']), 0)
def test_positive_update_by_name(self): """Update existing user group with different valid names. Use name of the user group as a parameter :id: 3bee63ff-ae2a-4fa4-a5bd-58ec85358c19 :expectedresults: User group is update successfully. :CaseImportance: Critical """ user_group = make_usergroup() for new_name in valid_data_list(): with self.subTest(new_name): UserGroup.update({ 'name': user_group['name'], 'new-name': new_name, }) user_group = UserGroup.info({'id': user_group['id']}) self.assertEqual(user_group['name'], new_name)