def test_positive_remove_host_collection_by_id(self): """Test that hosts associated to Activation Keys can be removed using id of that host collection @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove host collection associated to Activation key using id of that collection @Assert: Host collection successfully removed from activation key """ activation_key = self._make_activation_key() new_host_col = make_host_collection({ u'name': gen_string('alpha'), u'organization-id': self.org['id'], }) ActivationKey.add_host_collection({ u'host-collection-id': new_host_col['id'], u'name': activation_key['name'], u'organization': self.org['name'], }) activation_key = ActivationKey.info({u'id': activation_key['id']}) self.assertEqual(len(activation_key['host-collections']), 1) ActivationKey.remove_host_collection({ u'host-collection-id': new_host_col['id'], u'name': activation_key['name'], u'organization': self.org['name'], }) activation_key = ActivationKey.info({u'id': activation_key['id']}) self.assertEqual(len(activation_key['host-collections']), 0)
def test_associate_host(self): """@Test: Test that host collection can be associated to Activation Keys @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create host collection 3. Associate the host collection to Activation key @Assert: Hosts are successfully associated to Activation key """ for host_col_name in valid_data_list(): with self.subTest(host_col_name): activation_key = self._make_activation_key() new_host_col_name = make_host_collection({ 'name': host_col_name, })['name'] # Assert that name matches data passed self.assertEqual(new_host_col_name, host_col_name) ActivationKey.add_host_collection({ u'host-collection': new_host_col_name, u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual( activation_key['host-collection'], host_col_name)
def test_positive_update_host_collection_with_default_org(self): """Test that host collection can be associated to Activation Keys with specified default organization setting in config :id: 01e830e9-91fd-4e45-9aaf-862e1fe134df :expectedresults: Host collection is successfully associated to Activation key :BZ: 1364876 """ Defaults.add({ u'param-name': 'organization_id', u'param-value': self.org['id'], }) try: activation_key = self._make_activation_key() host_col = make_host_collection() ActivationKey.add_host_collection({ u'host-collection': host_col['name'], u'name': activation_key['name'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual( activation_key['host-collections'][0]['name'], host_col['name'] ) finally: Defaults.delete({u'param-name': 'organization_id'})
def test_positive_remove_host_collection_by_id(self): """@Test: Test that hosts associated to Activation Keys can be removed using id of that host collection @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove host collection associated to Activation key using id of that collection @Assert: Host collection successfully removed from activation key """ activation_key = self._make_activation_key() new_host_col = make_host_collection({ u'name': gen_string('alpha'), u'organization-id': self.org['id'], }) ActivationKey.add_host_collection({ u'host-collection-id': new_host_col['id'], u'name': activation_key['name'], u'organization': self.org['name'], }) activation_key = ActivationKey.info({u'id': activation_key['id']}) self.assertEqual(len(activation_key['host-collections']), 1) ActivationKey.remove_host_collection({ u'host-collection-id': new_host_col['id'], u'name': activation_key['name'], u'organization': self.org['name'], }) activation_key = ActivationKey.info({u'id': activation_key['id']}) self.assertEqual(len(activation_key['host-collections']), 0)
def test_positive_update_host_collection(self): """Test that host collections can be associated to Activation Keys :id: 2114132a-fede-4791-98e7-a463ad79f398 :BZ: 1110476 :expectedresults: Host collections are successfully associated to Activation key :CaseLevel: Integration """ for host_col_name in valid_data_list(): with self.subTest(host_col_name): activation_key = self._make_activation_key() new_host_col_name = make_host_collection({ u'name': host_col_name, u'organization-id': self.org['id'], })['name'] # Assert that name matches data passed self.assertEqual(new_host_col_name, host_col_name) ActivationKey.add_host_collection({ u'host-collection': new_host_col_name, u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual( activation_key['host-collections'][0]['name'], host_col_name )
def test_positive_update_host_collection(self): """Test that host collection can be associated to Activation Keys @Feature: Activation key - Host @BZ: 1110476 @Assert: Hosts are successfully associated to Activation key """ for host_col_name in valid_data_list(): with self.subTest(host_col_name): activation_key = self._make_activation_key() new_host_col_name = make_host_collection({"name": host_col_name})["name"] # Assert that name matches data passed self.assertEqual(new_host_col_name, host_col_name) ActivationKey.add_host_collection( { u"host-collection": new_host_col_name, u"name": activation_key["name"], u"organization-id": self.org["id"], } ) activation_key = ActivationKey.info({u"id": activation_key["id"]}) self.assertEqual(activation_key["host-collection"], host_col_name)
def test_positive_update_host_collection(self): """Test that host collection can be associated to Activation Keys :id: 2114132a-fede-4791-98e7-a463ad79f398 :BZ: 1110476 :expectedresults: Hosts are successfully associated to Activation key :CaseLevel: Integration """ for host_col_name in valid_data_list(): with self.subTest(host_col_name): activation_key = self._make_activation_key() new_host_col_name = make_host_collection({ 'name': host_col_name, })['name'] # Assert that name matches data passed self.assertEqual(new_host_col_name, host_col_name) ActivationKey.add_host_collection({ u'host-collection': new_host_col_name, u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual( activation_key['host-collection'], host_col_name)
def test_positive_update_host_collection(self): """Test that host collection can be associated to Activation Keys @Feature: Activation key - Host @BZ: 1110476 @Assert: Hosts are successfully associated to Activation key """ for host_col_name in valid_data_list(): with self.subTest(host_col_name): activation_key = self._make_activation_key() new_host_col_name = make_host_collection({ 'name': host_col_name, })['name'] # Assert that name matches data passed self.assertEqual(new_host_col_name, host_col_name) ActivationKey.add_host_collection({ u'host-collection': new_host_col_name, u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual( activation_key['host-collection'], host_col_name)
def test_positive_remove_host_collection_by_name(self): """Test that hosts associated to Activation Keys can be removed using name of that host collection :id: 1a559a82-db5f-48b0-beeb-2fa02aed7ef9 :Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove the host collection associated to Activation key using name of that collection :expectedresults: Host collection successfully removed from activation key :CaseLevel: Integration """ for host_col in valid_data_list(): with self.subTest(host_col): activation_key = self._make_activation_key() new_host_col = make_host_collection({ u'name': host_col, u'organization-id': self.org['id'], }) # Assert that name matches data passed self.assertEqual(new_host_col['name'], host_col) ActivationKey.add_host_collection({ u'host-collection': new_host_col['name'], u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ 'id': activation_key['id'], }) self.assertEqual(len(activation_key['host-collections']), 1) self.assertEqual( activation_key['host-collections'][0]['name'], host_col, ) ActivationKey.remove_host_collection({ u'host-collection': new_host_col['name'], u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual(len(activation_key['host-collections']), 0)
def test_positive_register_host_ak_with_host_collection( katello_agent_client, module_cv, module_lce, module_org, rhel7_contenthost, default_sat): """Attempt to register a host using activation key with host collection :id: 7daf4e40-3fa6-42af-b3f7-1ca1a5c9bfeb :BZ: 1385814 :expectedresults: Host successfully registered and listed in host collection :CaseLevel: System """ # client = katello_agent_client['client'] host_info = katello_agent_client['host_info'] # create a new activation key activation_key = make_activation_key({ 'lifecycle-environment-id': module_lce.id, 'organization-id': module_org.id, 'content-view-id': module_cv.id, }) hc = make_host_collection({'organization-id': module_org.id}) ActivationKey.add_host_collection({ 'id': activation_key['id'], 'organization-id': module_org.id, 'host-collection-id': hc['id'], }) # add the registered instance host to collection HostCollection.add_host({ 'id': hc['id'], 'organization-id': module_org.id, 'host-ids': host_info['id'] }) with VMBroker(nick='rhel7', host_classes={'host': ContentHost}) as vm: vm.install_katello_ca(default_sat) # register the client host with the current activation key vm.register_contenthost(module_org.name, activation_key=activation_key['name']) assert vm.subscribed # note: when registering the host, it should be automatically added to the host-collection client_host = Host.info({'name': vm.hostname}) hosts = HostCollection.hosts({ 'id': hc['id'], 'organization-id': module_org.id }) assert len(hosts) == 2 expected_hosts_ids = {host_info['id'], client_host['id']} hosts_ids = {host['id'] for host in hosts} assert hosts_ids == expected_hosts_ids
def test_positive_register_host_ak_with_host_collection(self): """Attempt to register a host using activation key with host collection :id: 7daf4e40-3fa6-42af-b3f7-1ca1a5c9bfeb :BZ: 1385814 :expectedresults: Host successfully registered and listed in host collection :CaseLevel: System """ # create a new activation key activation_key = make_activation_key({ 'lifecycle-environment-id': self.env['id'], 'organization-id': self.org['id'], 'content-view-id': self.content_view['id'], }) hc = make_host_collection({'organization-id': self.org['id']}) ActivationKey.add_host_collection({ 'id': activation_key['id'], 'organization-id': self.org['id'], 'host-collection-id': hc['id'], }) # add the registered instance host to collection HostCollection.add_host({ 'id': hc['id'], 'organization-id': self.org['id'], 'host-ids': self.host['id'] }) with VirtualMachine() as client: client.create() client.install_katello_ca() # register the client host with the current activation key client.register_contenthost(self.org['name'], activation_key=activation_key['name']) assert client.subscribed # note: when registering the host, it should be automatically added # to the host collection client_host = Host.info({'name': client.hostname}) hosts = HostCollection.hosts({ 'id': hc['id'], 'organization-id': self.org['id'] }) assert len(hosts) == 2 expected_hosts_ids = {self.host['id'], client_host['id']} hosts_ids = {host['id'] for host in hosts} assert hosts_ids == expected_hosts_ids
def test_remove_hc_by_name(self): """@Test: Test that hosts associated to Activation Keys can be removed using name of that host collection @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove the host collection associated to Activation key using name of that collection @Assert: Host collection successfully removed from activation key """ for host_col in valid_data_list(): with self.subTest(host_col): activation_key = self._make_activation_key() new_host_col = make_host_collection({ u'name': host_col, u'organization-id': self.org['id'], }) # Assert that name matches data passed self.assertEqual(new_host_col['name'], host_col) ActivationKey.add_host_collection({ u'host-collection': new_host_col['name'], u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ 'id': activation_key['id'], }) self.assertEqual(len(activation_key['host-collections']), 1) self.assertEqual( activation_key['host-collections'][0]['name'], host_col, ) ActivationKey.remove_host_collection({ u'host-collection': new_host_col['name'], u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual(len(activation_key['host-collections']), 0)
def test_positive_remove_host_collection_by_name(self): """Test that hosts associated to Activation Keys can be removed using name of that host collection @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove the host collection associated to Activation key using name of that collection @Assert: Host collection successfully removed from activation key """ for host_col in valid_data_list(): with self.subTest(host_col): activation_key = self._make_activation_key() new_host_col = make_host_collection({ u'name': host_col, u'organization-id': self.org['id'], }) # Assert that name matches data passed self.assertEqual(new_host_col['name'], host_col) ActivationKey.add_host_collection({ u'host-collection': new_host_col['name'], u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ 'id': activation_key['id'], }) self.assertEqual(len(activation_key['host-collections']), 1) self.assertEqual( activation_key['host-collections'][0]['name'], host_col, ) ActivationKey.remove_host_collection({ u'host-collection': new_host_col['name'], u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual(len(activation_key['host-collections']), 0)
def test_positive_remove_host_collection_by_id(self): """Test that hosts associated to Activation Keys can be removed using id of that host collection :id: 20f8ecca-1756-4900-b966-f0144b6bd0aa :Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove host collection associated to Activation key using id of that collection :expectedresults: Host collection successfully removed from activation key :CaseLevel: Integration """ activation_key = self._make_activation_key() new_host_col = make_host_collection({ u'name': gen_string('alpha'), u'organization-id': self.org['id'], }) ActivationKey.add_host_collection({ u'host-collection-id': new_host_col['id'], u'name': activation_key['name'], u'organization': self.org['name'], }) activation_key = ActivationKey.info({u'id': activation_key['id']}) self.assertEqual(len(activation_key['host-collections']), 1) ActivationKey.remove_host_collection({ u'host-collection-id': new_host_col['id'], u'name': activation_key['name'], u'organization': self.org['name'], }) activation_key = ActivationKey.info({u'id': activation_key['id']}) self.assertEqual(len(activation_key['host-collections']), 0)
def test_positive_register_host_ak_with_host_collection( module_org, module_ak_with_cv, default_sat): """Attempt to register a host using activation key with host collection :id: 62459e8a-0cfa-44ff-b70c-7f55b4757d66 :expectedresults: Host successfully registered and listed in host collection :BZ: 1385814 :CaseLevel: System """ host_info = _make_fake_host_helper(module_org) hc = make_host_collection({'organization-id': module_org.id}) ActivationKey.add_host_collection({ 'id': module_ak_with_cv.id, 'organization-id': module_org.id, 'host-collection-id': hc['id'], }) # add the registered instance host to collection HostCollection.add_host({ 'id': hc['id'], 'organization-id': module_org.id, 'host-ids': host_info['id'] }) with VMBroker(nick='rhel7', host_classes={'host': ContentHost}) as client: client.install_katello_ca(default_sat) # register the client host with the current activation key client.register_contenthost(module_org.name, activation_key=module_ak_with_cv.name) assert client.subscribed # note: when registering the host, it should be automatically added to the host-collection client_host = Host.info({'name': client.hostname}) hosts = HostCollection.hosts({ 'id': hc['id'], 'organization-id': module_org.id }) assert len(hosts) == 2 expected_hosts_ids = {host_info['id'], client_host['id']} hosts_ids = {host['id'] for host in hosts} assert hosts_ids == expected_hosts_ids
def host_collection(module_org, module_ak_cv_lce, register_hosts): """Create and setup host collection.""" host_collection = make_host_collection({'organization-id': module_org.id}) host_ids = [ Host.info({'name': host.hostname})['id'] for host in register_hosts ] HostCollection.add_host({ 'id': host_collection['id'], 'organization-id': module_org.id, 'host-ids': host_ids, }) ActivationKey.add_host_collection({ 'id': module_ak_cv_lce.id, 'host-collection-id': host_collection['id'], 'organization-id': module_org.id, }) return host_collection
def test_positive_remove_host_collection_by_name(self): """Test that hosts associated to Activation Keys can be removed using name of that host collection @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove the host collection associated to Activation key using name of that collection @Assert: Host collection successfully removed from activation key """ for host_col in valid_data_list(): with self.subTest(host_col): activation_key = self._make_activation_key() new_host_col = make_host_collection({u"name": host_col, u"organization-id": self.org["id"]}) # Assert that name matches data passed self.assertEqual(new_host_col["name"], host_col) ActivationKey.add_host_collection( { u"host-collection": new_host_col["name"], u"name": activation_key["name"], u"organization-id": self.org["id"], } ) activation_key = ActivationKey.info({"id": activation_key["id"]}) self.assertEqual(len(activation_key["host-collections"]), 1) self.assertEqual(activation_key["host-collections"][0]["name"], host_col) ActivationKey.remove_host_collection( { u"host-collection": new_host_col["name"], u"name": activation_key["name"], u"organization-id": self.org["id"], } ) activation_key = ActivationKey.info({u"id": activation_key["id"]}) self.assertEqual(len(activation_key["host-collections"]), 0)
def test_associate_host(self, test_data): """@Test: Test that hosts can be associated to Activation Keys @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create different hosts 3. Associate the hosts to Activation key @Assert: Hosts are successfully associated to Activation key """ try: activation_key = self._make_activation_key({ u'organization-id': self.org['id'], }) new_host_col = make_host_collection({ 'name': test_data['host-col'] }) except CLIFactoryError as err: self.fail(err) # Assert that name matches data passed self.assertEqual( new_host_col['name'], test_data['host-col'], "Names don't match" ) result = ActivationKey.add_host_collection({ u'name': activation_key['name'], u'host-collection': new_host_col['name'], u'organization-id': self.org['id'], }) self.assertEqual( result.return_code, 0, 'Failed to add host-col activation key') self.assertEqual( len(result.stderr), 0, 'There should not be an error here') result = ActivationKey.info({ u'id': activation_key['id'], }) self.assertEqual( result.return_code, 0, 'Failed to get info for activation key') self.assertEqual( len(result.stderr), 0, 'There should not be an error here') self.assertEqual( result.stdout['host-collection'], test_data['host-col'], 'Activation key host-collection added')
def test_positive_remove_host_collection_by_id(self): """Test that hosts associated to Activation Keys can be removed using id of that host collection @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create host collection 3. Associate host collection to Activation key 4. Remove host collection associated to Activation key using id of that collection @Assert: Host collection successfully removed from activation key """ activation_key = self._make_activation_key() new_host_col = make_host_collection({u"name": gen_string("alpha"), u"organization-id": self.org["id"]}) ActivationKey.add_host_collection( { u"host-collection-id": new_host_col["id"], u"name": activation_key["name"], u"organization": self.org["name"], } ) activation_key = ActivationKey.info({u"id": activation_key["id"]}) self.assertEqual(len(activation_key["host-collections"]), 1) ActivationKey.remove_host_collection( { u"host-collection-id": new_host_col["id"], u"name": activation_key["name"], u"organization": self.org["name"], } ) activation_key = ActivationKey.info({u"id": activation_key["id"]}) self.assertEqual(len(activation_key["host-collections"]), 0)
def test_remove_host(self, test_data): """@Test: Test that hosts associated to Activation Keys can be removed @Feature: Activation key - Host @Steps: 1. Create Activation key 2. Create different hosts 3. Associate the hosts to Activation key 4. Remove the hosts associated to Activation key @Assert: Hosts successfully removed that are associated to Activation key """ try: org = make_org() activation_key = self._make_activation_key({u"organization-id": org["id"]}) new_host_col = make_host_collection({u"name": test_data["host-col"], u"organization-id": org["id"]}) except CLIFactoryError as err: self.fail(err) # Assert that name matches data passed self.assertEqual(new_host_col["name"], test_data["host-col"], "Names don't match") result = ActivationKey.add_host_collection( {u"name": activation_key["name"], u"host-collection": new_host_col["name"], u"organization-id": org["id"]} ) self.assertEqual(result.return_code, 0, "Failed to add host-col activation key") self.assertEqual(len(result.stderr), 0, "There should not be an error here") result = ActivationKey.info({u"id": activation_key["id"]}) self.assertEqual(result.return_code, 0, "Failed to get info for activation key") self.assertEqual(len(result.stderr), 0, "There should not be an error here") self.assertEqual( result.stdout["host-collections"][0]["name"], test_data["host-col"], "Activation key host-collection added" ) result = ActivationKey.remove_host_collection( {u"name": activation_key["name"], u"host-collection": new_host_col["name"], u"organization-id": org["id"]} ) self.assertEqual(result.return_code, 0, "Failed to remove host-col activation key") self.assertEqual(len(result.stderr), 0, "There should not be an error here") result = ActivationKey.info({u"id": activation_key["id"]}) self.assertEqual(result.return_code, 0, "Failed to get info for activation key") self.assertEqual(len(result.stderr), 0, "There should not be an error here") self.assertEqual(len(result.stdout["host-collections"]), 0, "Activation key host-collection removed")