def test_positive_list_by_host_id(self): """Check if host collection list can be filtered by associated host id :id: de272461-9804-4524-83c8-23e47abfc8e3 :expectedresults: Only host-collection with specific host is listed :CaseLevel: Integration :BZ: 1379372 """ # Create two host collections within the same org but only one with # associated host that will be used for filtering host_col = make_host_collection({ 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) host = self._make_fake_host_helper() HostCollection.add_host({ 'host-ids': host['id'], 'id': host_col['id'], }) host_col = HostCollection.info({ 'id': host_col['id'], }) self.assertEqual(host_col['total-hosts'], '1') # List all host collections within organization result = HostCollection.list( {'organization-id': self.organization['id']}) self.assertGreaterEqual(len(result), 2) # Filter list by associated host id result = HostCollection.list({'host-id': host['id']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_positive_list_by_name(self): """Check if host collection list can be filtered by name :id: 2d611a48-1e51-49b5-8f20-81b09f96c542 :expectedresults: Only host-collection with specific name is listed :CaseLevel: Integration """ host_col_name = gen_string('alpha') # Create two host collections within the same org host_col = make_host_collection({ 'name': host_col_name, 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) # List all host collections self.assertGreaterEqual(len(HostCollection.list()), 2) # Filter list by name result = HostCollection.list({ 'name': host_col_name, 'organization-id': self.organization['id'], }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_positive_list_by_host_id(self): """Check if host collection list can be filtered by associated host id :id: de272461-9804-4524-83c8-23e47abfc8e3 :expectedresults: Only host-collection with specific host is listed :CaseLevel: Integration :BZ: 1379372 """ # Create two host collections within the same org but only one with # associated host that will be used for filtering host_col = make_host_collection({ 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) host = self._make_fake_host_helper() HostCollection.add_host({ 'host-ids': host['id'], 'id': host_col['id'], }) host_col = HostCollection.info({ 'id': host_col['id'], }) self.assertEqual(host_col['total-hosts'], '1') # List all host collections within organization result = HostCollection.list({ 'organization-id': self.organization['id']}) self.assertGreaterEqual(len(result), 2) # Filter list by associated host id result = HostCollection.list({'host-id': host['id']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_positive_list_by_name(self): """Check if host collection list can be filtered by name :id: 2d611a48-1e51-49b5-8f20-81b09f96c542 :expectedresults: Only host-collection with specific name is listed :CaseLevel: Integration """ host_col_name = gen_string('alpha') # Create two host collections within the same org host_col = make_host_collection({ 'name': host_col_name, 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) # List all host collections self.assertGreaterEqual(len(HostCollection.list()), 2) # Filter list by name result = HostCollection.list({ 'name': host_col_name, 'organization-id': self.organization['id'], }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_reimport_host_collections_default_negative(self, test_data): """@test: Try to re-import all System Groups from the default data set (predefined source) as the Host Collections. @feature: Repetitive Import Host-Collections @assert: 3 Host Collections created, no action taken on 2nd Import """ files = dict(self.default_dataset[1]) for file_ in zip( ['users', 'system-groups'], [u'organization_id', u'org_id'], [u'orgs', u'hcs'] ): files[file_[0]] = update_csv_values( files[file_[0]], file_[1], test_data[file_[2]], self.default_dataset[0] ) # import the prerequisities import_org = Import.organization_with_tr_data( {'csv-file': files['users']} ) import_hc = Import.host_collection( {'csv-file': files['system-groups']} ) self.assertEqual(import_org[0].return_code, 0) self.assertEqual(import_hc.return_code, 0) hcollections_before = [ HostCollection.list({'organization-id': tr['sat6']}).stdout for tr in import_org[1] ] self.assertNotEqual(hcollections_before, []) self.assertEqual( Import.host_collection( {'csv-file': files['system-groups']} ).return_code, 0 ) hcollections_after = [ HostCollection.list({'organization-id': tr['sat6']}).stdout for tr in import_org[1] ] self.assertEqual(hcollections_before, hcollections_after)
def test_positive_list_by_name(self): """Check if host collection list can be filtered by name @id: 2d611a48-1e51-49b5-8f20-81b09f96c542 @Assert: Only host-collection with specific name is listed @CaseLevel: Integration """ # Create two host collections within the same org host_col = self._new_host_collection() self._new_host_collection() # List all host collections self.assertGreaterEqual(len(HostCollection.list()), 2) # Filter list by name result = HostCollection.list({'name': host_col['name']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_positive_list_by_org_id(self): """Check if host collection list can be filtered by organization id :id: afbe077a-0de1-432c-a0c4-082129aab92e :expectedresults: Only host-collection within specific org is listed :CaseLevel: Integration """ # Create two host collections within different organizations new_org = make_org() host_col = make_host_collection({'organization-id': new_org['id']}) # List all host collections self.assertGreaterEqual(len(HostCollection.list()), 2) # Filter list by org id result = HostCollection.list({'organization-id': new_org['id']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_positive_list_by_org_id(module_org): """Check if host collection list can be filtered by organization id :id: afbe077a-0de1-432c-a0c4-082129aab92e :expectedresults: Only host-collection within specific org is listed :CaseLevel: Integration """ # Create two host collections within different organizations make_host_collection({'organization-id': module_org.id}) new_org = make_org() new_host_col = make_host_collection({'organization-id': new_org['id']}) # List all host collections assert len(HostCollection.list()) >= 2 # Filter list by org id result = HostCollection.list({'organization-id': new_org['id']}) assert len(result) == 1 assert result[0]['id'] == new_host_col['id']
def test_positive_list_by_host_name(self): """Check if host collection list can be filtered by associated host name :id: 2a99e11f-50b8-48b4-8dce-e6ad8ff9c051 :expectedresults: Only host-collection with specific host is listed :CaseLevel: Integration :BZ: 1379372 """ # Create two host collections within the same org but only one with # associated host that will be used for filtering host_col = make_host_collection({ 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) host = self._make_fake_host_helper() HostCollection.add_host({ 'hosts': host['name'], 'name': host_col['name'], 'organization': self.organization['name'], }) host_col = HostCollection.info({ 'name': host_col['name'], 'organization': self.organization['name'] }) self.assertEqual(host_col['total-hosts'], '1') # List all host collections within organization result = HostCollection.list( {'organization': self.organization['name']}) self.assertGreaterEqual(len(result), 2) # Filter list by associated host name result = HostCollection.list({ 'organization': self.organization['name'], 'host': host['name'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], host_col['name'])
def test_positive_list_by_org_name(self): """Check if host collection list can be filtered by organization name :id: 0102094f-f5af-4067-8a07-541ba9d94f61 :expectedresults: Only host-collection within specific org is listed :CaseLevel: Integration """ # Create two host collections within different organizations self._new_host_collection() new_org = make_org() host_col = self._new_host_collection( {'organization-id': new_org['id']}) # List all host collections self.assertGreaterEqual(len(HostCollection.list()), 2) # Filter list by org id result = HostCollection.list({'organization': new_org['name']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], host_col['name'])
def test_positive_list_by_org_name(self): """Check if host collection list can be filtered by organization name :id: 0102094f-f5af-4067-8a07-541ba9d94f61 :expectedresults: Only host-collection within specific org is listed :CaseLevel: Integration """ # Create two host collections within different organizations self._new_host_collection() new_org = make_org() host_col = self._new_host_collection( {'organization-id': new_org['id']}) # List all host collections self.assertGreaterEqual(len(HostCollection.list()), 2) # Filter list by org id result = HostCollection.list({'organization': new_org['name']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], host_col['name'])
def test_positive_list_by_org_id(self): """Check if host collection list can be filtered by organization id :id: afbe077a-0de1-432c-a0c4-082129aab92e :expectedresults: Only host-collection within specific org is listed :CaseLevel: Integration """ # Create two host collections within different organizations self._new_host_collection() new_org = make_org() host_col = self._new_host_collection( {'organization-id': new_org['id']}) # List all host collections self.assertGreaterEqual(len(HostCollection.list()), 2) # Filter list by org id result = HostCollection.list({'organization-id': new_org['id']}) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], host_col['id'])
def test_positive_list_by_host_name(self): """Check if host collection list can be filtered by associated host name :id: 2a99e11f-50b8-48b4-8dce-e6ad8ff9c051 :expectedresults: Only host-collection with specific host is listed :CaseLevel: Integration :BZ: 1379372 """ # Create two host collections within the same org but only one with # associated host that will be used for filtering host_col = make_host_collection({ 'organization-id': self.organization['id'], }) make_host_collection({'organization-id': self.organization['id']}) host = self._make_fake_host_helper() HostCollection.add_host({ 'hosts': host['name'], 'name': host_col['name'], 'organization': self.organization['name'], }) host_col = HostCollection.info({ 'name': host_col['name'], 'organization': self.organization['name'] }) self.assertEqual(host_col['total-hosts'], '1') # List all host collections within organization result = HostCollection.list({ 'organization': self.organization['name']}) self.assertGreaterEqual(len(result), 2) # Filter list by associated host name result = HostCollection.list({ 'organization': self.organization['name'], 'host': host['name'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], host_col['name'])
def test_import_host_collections_default(self, test_data): """@test: Import all System Groups from the default data set (predefined source) as the Host Collections. @feature: Import Host-Collections @assert: 3 Host Collections created """ files = dict(self.default_dataset[1]) for file_ in zip( ['users', 'system-groups'], [u'organization_id', u'org_id'], [u'orgs', u'hcs'] ): files[file_[0]] = update_csv_values( files[file_[0]], file_[1], test_data[file_[2]], self.default_dataset[0] ) # import the prerequisities import_org = Import.organization_with_tr_data( {'csv-file': files['users']} ) import_hc = Import.host_collection_with_tr_data( {'csv-file': files['system-groups']} ) for result in (import_org, import_hc): self.assertEqual(result[0].return_code, 0) # now to check whether the all HC from csv appeared in satellite imp_orgs = get_sat6_id(csv_to_dataset([files['users']]), import_org[1]) for imp_org in imp_orgs: self.assertNotEqual( HostCollection.list( {'organization-id': imp_org['sat6']} ).stdout, [] )
def test_import_host_collections_recovery(self, test_data): """@test: Try to Import Collections with the same name to invoke usage of a recovery strategy (rename, map, none) @feature: Import HostCollection Recover @assert: 2nd Import will rename the new collections, 3nd import will result in No Action Taken and the 4th one will map them """ # prepare the data files = dict(self.default_dataset[1]) for file_ in zip( ['users', 'system-groups'], [u'organization_id', u'org_id'], [u'orgs', u'hcs'] ): files[file_[0]] = update_csv_values( files[file_[0]], file_[1], test_data[file_[2]], self.default_dataset[0] ) # initial import import_org = Import.organization_with_tr_data( {'csv-file': files['users']} ) for result in ( import_org, Import.host_collection_with_tr_data( {'csv-file': files['system-groups']} ), ): self.assertEqual(result[0].return_code, 0) # clear the .transition_data to clear the transition mapping ssh.command('rm -rf "${HOME}"/.transition_data/host_collections*') # use the default (rename) strategy import_hc_rename = Import.host_collection_with_tr_data( {'csv-file': files['system-groups'], 'verbose': True} ) self.assertEqual(import_hc_rename[0].return_code, 0) for record in import_hc_rename[1]: self.assertEqual( HostCollection.info({'id': record['sat6']}).return_code, 0 ) Import.host_collection( {'csv-file': files['system-groups'], 'delete': True} ) # use the 'none' strategy hc_before = [ HostCollection.list({'organization-id': tr['sat6']}).stdout for tr in import_org[1] ] Import.host_collection( {'csv-file': files['system-groups'], 'recover': 'none'} ) hc_after = [ HostCollection.list({'organization-id': tr['sat6']}).stdout for tr in import_org[1] ] self.assertEqual(hc_before, hc_after) # use the 'map' strategy import_hc_map = Import.host_collection_with_tr_data({ 'csv-file': files['system-groups'], 'recover': 'map', 'verbose': True, }) self.assertEqual(import_hc_map[0].return_code, 0) for record in import_hc_map[1]: self.assertEqual( HostCollection.info({'id': record['sat6']}).return_code, 0 )
def test_positive_end_to_end(self): """Check if host collection can be created with name and description, content host can be added and removed, host collection can be listed, updated and deleted :id: 2d3b718e-6f57-4c83-aedb-15604cc8a4bd :expectedresults: Host collection is created and has expected name and description, content-host is added and removed, host collection is updated and deleted. :CaseImportance: Critical """ name = valid_data_list()[0] desc = valid_data_list()[0] new_host_col = make_host_collection({ 'description': desc, 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(new_host_col['name'], name) self.assertEqual(new_host_col['description'], desc) # add host new_system = self._make_fake_host_helper() no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({ 'host-ids': new_system['id'], 'id': new_host_col['id'] }) result = HostCollection.info({'id': new_host_col['id']}) self.assertGreater(result['total-hosts'], no_of_content_host) # list hosts result = HostCollection.hosts({ 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(new_system['name'].lower(), result[0]['name']) # List all host collections within organization result = HostCollection.list( {'organization': self.organization['name']}) self.assertGreaterEqual(len(result), 2) # Filter list by name result = HostCollection.list({ 'name': name, 'organization-id': self.organization['id'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['id'], new_host_col['id']) # Filter list by associated host name result = HostCollection.list({ 'organization': self.organization['name'], 'host': new_system['name'] }) self.assertEqual(len(result), 1) self.assertEqual(result[0]['name'], new_host_col['name']) # remove host no_of_content_host = HostCollection.info({'id': new_host_col['id'] })['total-hosts'] HostCollection.remove_host({ 'host-ids': new_system['id'], 'id': new_host_col['id'] }) result = HostCollection.info({'id': new_host_col['id']}) self.assertGreater(no_of_content_host, result['total-hosts']) # update new_name = valid_data_list()[0] new_desc = valid_data_list()[0] HostCollection.update({ 'description': new_desc, 'id': new_host_col['id'], 'new-name': new_name }) result = HostCollection.info({'id': new_host_col['id']}) self.assertEqual(result['name'], new_name) self.assertEqual(result['description'], new_desc) # delete HostCollection.delete({'id': new_host_col['id']}) with self.assertRaises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})
def test_positive_end_to_end(module_org): """Check if host collection can be created with name and description, content host can be added and removed, host collection can be listed, updated and deleted :id: 2d3b718e-6f57-4c83-aedb-15604cc8a4bd :expectedresults: Host collection is created and has expected name and description, content-host is added and removed, host collection is updated and deleted. :CaseImportance: Critical """ name = list(valid_data_list().values())[0] desc = list(valid_data_list().values())[0] new_host_col = make_host_collection( {'description': desc, 'name': name, 'organization-id': module_org.id} ) assert new_host_col['name'] == name assert new_host_col['description'] == desc # add host new_system = _make_fake_host_helper(module_org) no_of_content_host = new_host_col['total-hosts'] HostCollection.add_host({'host-ids': new_system['id'], 'id': new_host_col['id']}) result = HostCollection.info({'id': new_host_col['id']}) assert result['total-hosts'] > no_of_content_host # list hosts result = HostCollection.hosts({'name': name, 'organization-id': module_org.id}) assert new_system['name'].lower() == result[0]['name'] # List all host collections within organization result = HostCollection.list({'organization': module_org.name}) assert len(result) >= 1 # Filter list by name result = HostCollection.list({'name': name, 'organization-id': module_org.id}) assert len(result) == 1 assert result[0]['id'] == new_host_col['id'] # Filter list by associated host name result = HostCollection.list({'organization': module_org.name, 'host': new_system['name']}) assert len(result) == 1 assert result[0]['name'] == new_host_col['name'] # remove host no_of_content_host = HostCollection.info({'id': new_host_col['id']})['total-hosts'] HostCollection.remove_host({'host-ids': new_system['id'], 'id': new_host_col['id']}) result = HostCollection.info({'id': new_host_col['id']}) assert no_of_content_host > result['total-hosts'] # update new_name = list(valid_data_list().values())[0] new_desc = list(valid_data_list().values())[0] HostCollection.update( {'description': new_desc, 'id': new_host_col['id'], 'new-name': new_name} ) result = HostCollection.info({'id': new_host_col['id']}) assert result['name'] == new_name assert result['description'] == new_desc # delete HostCollection.delete({'id': new_host_col['id']}) with pytest.raises(CLIReturnCodeError): HostCollection.info({'id': new_host_col['id']})