def test_delete_ak_by_name(self): """@Test: Create Activation key and delete it for all variations of Activation key name @Feature: Activation key - Positive Delete @Steps: 1. Create Activation key for all valid Activation Key names 2. Delete the Activation key @Assert: Activation key is deleted """ for name in valid_data_list(): with self.subTest(name): activation_key = self._make_activation_key({ u'name': name, u'organization-id': self.org['id'], }) ActivationKey.delete({ 'name': activation_key['name'], 'organization-id': self.org['id'], }) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': activation_key['id']})
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_delete_ak_with_env(self): """@Test: Create activation key with lifecycle environment assigned to it and delete it using activation key id @Feature: Activation key - Positive Delete @Steps: 1. Create Activation key with lifecycle environment assigned to it 2. Delete Activation key using activation key id @Assert: Activation key is deleted """ self.update_env() env = make_lifecycle_environment({ u'organization-id': self.org['id'], }) activation_key = self._make_activation_key({ u'lifecycle-environment': env['name'], u'name': gen_string('alpha'), }) ActivationKey.delete({'id': activation_key['id']}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': activation_key['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_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_delete_by_org_label(self): """Create Activation key and delete it using organization label for which that key was created @Feature: Activation key - Positive Delete @Assert: Activation key is deleted """ new_ak = self._make_activation_key() ActivationKey.delete({"name": new_ak["name"], "organization-label": self.org["label"]}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({"id": new_ak["id"]})
def test_positive_delete_with_lce(self): """Create activation key with lifecycle environment assigned to it and delete it using activation key id @Feature: Activation key - Positive Delete @Assert: Activation key is deleted """ new_ak = self._make_activation_key({u"lifecycle-environment": self.get_default_env()["name"]}) ActivationKey.delete({"id": new_ak["id"]}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({"id": new_ak["id"]})
def test_positive_delete_with_cv(self): """Create activation key with content view assigned to it and delete it using activation key id @Feature: Activation key - Positive Delete @Assert: Activation key is deleted """ new_cv = make_content_view({u"organization-id": self.org["id"]}) new_ak = self._make_activation_key({u"content-view": new_cv["name"]}) ActivationKey.delete({"id": new_ak["id"]}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({"id": new_ak["id"]})
def test_positive_delete_with_cv(self): """Create activation key with content view assigned to it and delete it using activation key id @Feature: Activation key - Positive Delete @Assert: Activation key is deleted """ new_cv = make_content_view({u'organization-id': self.org['id']}) new_ak = self._make_activation_key({u'content-view': new_cv['name']}) ActivationKey.delete({'id': new_ak['id']}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
def test_bugzilla_1111723(self): """@test: Create activation key, rename it and create another with the initial name @feature: Activation key - Positive Create @steps: 1. Create an activation key 2. Rename it 3. Create another activation key with the same name from step 1 @assert: Activation key is created @bz: 1111723 """ name = generate_string("utf8", 15) try: activation_key = self._make_activation_key({u"name": name, u"organization-id": self.org["id"]}) except CLIFactoryError as err: self.fail(err) new_name = generate_string("utf8", 15) result = ActivationKey.update( {u"id": activation_key["id"], u"new-name": new_name, u"organization-id": self.org["id"]} ) self.assertEqual(result.return_code, 0, "Failed to update 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["name"], new_name, "Activation key name was not updated") try: new_activation_key = self._make_activation_key({u"name": name, u"organization-id": self.org["id"]}) except CLIFactoryError as err: self.fail( ("Failed to create an activation key with a previous name of" "another activation key: {0}").format(err) ) result = ActivationKey.info({u"id": new_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["name"], name, u"Activation key names don't not match {0} != {1}".format(result.stdout["name"], name), )
def test_positive_delete_with_lce(self): """Create activation key with lifecycle environment assigned to it and delete it using activation key id @Feature: Activation key - Positive Delete @Assert: Activation key is deleted """ new_ak = self._make_activation_key({ u'lifecycle-environment': self.get_default_env()['name'], }) ActivationKey.delete({'id': new_ak['id']}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
def test_positive_delete_by_name(self): """Create Activation key and delete it for all variations of Activation key name @Feature: Activation key - Positive Delete @Assert: Activation key is deleted """ for name in valid_data_list(): with self.subTest(name): new_ak = self._make_activation_key({u"name": name, u"organization-id": self.org["id"]}) ActivationKey.delete({"name": new_ak["name"], "organization-id": self.org["id"]}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({"id": new_ak["id"]})
def test_positive_delete_with_cv(self): """Create activation key with content view assigned to it and delete it using activation key id :id: bba323fa-0362-4a9b-97af-560d446cbb6c :expectedresults: Activation key is deleted :CaseLevel: Integration """ new_cv = make_content_view({u'organization-id': self.org['id']}) new_ak = self._make_activation_key({u'content-view': new_cv['name']}) ActivationKey.delete({'id': new_ak['id']}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
def test_positive_delete_by_org_name(self): """Create Activation key and delete it using organization name for which that key was created @id: 006cbe5c-fb72-43a1-9760-30c97043c36b @Assert: Activation key is deleted """ new_ak = self._make_activation_key() ActivationKey.delete({ 'name': new_ak['name'], 'organization': self.org['name'], }) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
def test_positive_delete_by_org_label(self): """Create Activation key and delete it using organization label for which that key was created @id: f66e5a42-b531-4290-a907-9f5c01305885 @Assert: Activation key is deleted """ new_ak = self._make_activation_key() ActivationKey.delete({ 'name': new_ak['name'], 'organization-label': self.org['label'], }) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
def test_positive_delete_by_org_label(self): """@Test: Create Activation key and delete it using organization label for which that key was created @Feature: Activation key - Positive Delete @Assert: Activation key is deleted """ new_ak = self._make_activation_key() ActivationKey.delete({ 'name': new_ak['name'], 'organization-label': self.org['label'], }) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
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")
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_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_ak5(self): """@Test: Update Content View in an Activation key @Feature: Activation key - Positive Update @Steps: 1. Create Activation key 2. Update Content View for all variations in [1] and include both RH and custom products @Assert: Activation key is updated """ activation_key = self._make_activation_key() for content_view_name in valid_data_list(): with self.subTest(content_view_name): con_view = make_content_view({ u'name': content_view_name, u'organization-id': self.org['id'], }) ActivationKey.update({ u'content-view': con_view['name'], u'name': activation_key['name'], u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({ 'id': activation_key['id'], }) self.assertEqual( activation_key['content-view'], content_view_name)
def test_positive_update_lce(self): """Update Environment in an Activation key @Feature: Activation key - Positive Update @Assert: Activation key is updated """ ak_env = self._make_activation_key({ u'lifecycle-environment-id': self.get_default_env()['id'], }) env = make_lifecycle_environment({u'organization-id': self.org['id']}) new_cv = make_content_view({u'organization-id': self.org['id']}) ContentView.publish({u'id': new_cv['id']}) cvv = ContentView.info({u'id': new_cv['id']})['versions'][0] ContentView.version_promote({ u'id': cvv['id'], u'to-lifecycle-environment-id': env['id'], }) ActivationKey.update({ u'id': ak_env['id'], u'lifecycle-environment-id': env['id'], u'content-view': new_cv['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': ak_env['id']}) self.assertEqual(updated_ak['lifecycle-environment'], env['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_bugzilla_1111723(self): """@test: Create activation key, rename it and create another with the initial name @feature: Activation key - Positive Create @steps: 1. Create an activation key 2. Rename it 3. Create another activation key with the same name from step 1 @assert: Activation key is created """ name = gen_string('utf8') activation_key = self._make_activation_key({'name': name}) new_name = gen_string('utf8') ActivationKey.update({ u'id': activation_key['id'], u'new-name': new_name, u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({'id': activation_key['id']}) self.assertEqual(activation_key['name'], new_name) new_activation_key = self._make_activation_key({ u'name': name, u'organization-id': self.org['id'], }) self.assertEqual(new_activation_key['name'], 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_delete_activation_key_1(self, test_data): """ @Test: Create Activation key and delete it for all variations of Activation key name @Feature: Activation key - Positive Delete @Steps: 1. Create Activation key for all valid Activation Key names in [1] using valid Description, Environment, Content View, Usage limit 2. Delete the Activation key @Assert: Activation key is deleted @bz: 1109650 """ try: activation_key = self._make_activation_key({ u'name': test_data['name'], u'organization-id': self.org['id'], }) except CLIFactoryError as err: self.fail(err) result = ActivationKey.delete({'id': activation_key['id']}) self.assertEqual( result.return_code, 0, 'Failed to delete activation key') self.assertEqual( len(result.stderr), 0, 'There should not be an error here') # Can we find the object? result = ActivationKey.info({'id': activation_key['id']}) self.assertNotEqual( result.return_code, 0, 'Activation key should be deleted') self.assertGreater( len(result.stderr), 0, 'There should be an error here') self.assertEqual( len(result.stdout), 0, 'Output should be blank')
def test_positive_update_autoattach_toggle(self): """Update Activation key with inverse auto-attach value :id: de3b5fb7-7963-420a-b4c9-c66e78a111dc :Steps: 1. Get the key's current auto attach value. 2. Update the key with the value's inverse. 3. Verify key was updated. :expectedresults: Activation key is successfully copied :CaseImportance: Critical """ new_ak = self._make_activation_key() attach_value = new_ak['auto-attach'] # invert value new_value = u'false' if attach_value == u'true' else u'true' ActivationKey.update({ u'auto-attach': new_value, u'id': new_ak['id'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': new_ak['id']}) self.assertEqual(updated_ak['auto-attach'], new_value)
def test_positive_update_activation_key_5(self, test_data): """@Test: Update Content View in an Activation key @Feature: Activation key - Positive Update @Steps: 1. Create Activation key 2. Update Content View for all variations in [1] and include both RH and custom products @Assert: Activation key is updated """ try: activation_key = self._make_activation_key({u"organization-id": self.org["id"]}) con_view = make_content_view({u"organization-id": self.org["id"], u"name": test_data["content-view"]}) except CLIFactoryError as err: self.fail(err) result = ActivationKey.update( {u"name": activation_key["name"], u"content-view": con_view["name"], u"organization-id": self.org["id"]} ) self.assertEqual(result.return_code, 0, "Failed to update 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["content-view"], test_data["content-view"], "Activation key content-view was not updated" )
def _make_activation_key(self, options=None): """Make a new activation key and assert its success""" if options is None: options = {} # Use default organization if None are provided if ( not options.get("organization", None) and not options.get("organization-label", None) and not options.get("organization-id", None) ): options["organization-id"] = self.org["id"] # Create activation key ackey = make_activation_key(options) # Fetch it result = ActivationKey.info({"id": ackey["id"]}) self.assertEqual(result.return_code, 0, "Activation key was not found: %s" % str(result.stderr)) self.assertEqual(len(result.stderr), 0, "No error was expected %s" % str(result.stderr)) # Return the activation key dictionary return ackey
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_create_using_old_name(self): """Create activation key, rename it and create another with the initial name :id: 9801319a-f42c-41a4-9ea4-3718e544c8e0 :expectedresults: Activation key is created :CaseImportance: Critical """ name = gen_string('utf8') activation_key = self._make_activation_key({'name': name}) new_name = gen_string('utf8') ActivationKey.update({ u'id': activation_key['id'], u'new-name': new_name, u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({'id': activation_key['id']}) self.assertEqual(activation_key['name'], new_name) new_activation_key = self._make_activation_key({ u'name': name, u'organization-id': self.org['id'], }) self.assertEqual(new_activation_key['name'], name)
def test_positive_update_activation_key_3(self, test_data): """@Test: Update Description in an Activation key @Feature: Activation key - Positive Update @Steps: 1. Create Activation key 2. Update Description for all variations in [1] @Assert: Activation key is updated @bz: 1109649 """ try: activation_key = self._make_activation_key({u"organization-id": self.org["id"]}) except CLIFactoryError as err: self.fail(err) result = ActivationKey.update( { u"name": activation_key["name"], u"description": test_data["description"], u"organization-id": self.org["id"], } ) self.assertEqual(result.return_code, 0, "Failed to update 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["description"], test_data["description"], "Activation key description was not updated" )
def test_positive_update_lce(self): """Update Environment in an Activation key :id: 55aaee60-b8c8-49f0-995a-6c526b9b653b :expectedresults: Activation key is updated :CaseLevel: Integration """ ak_env = self._make_activation_key({ u'lifecycle-environment-id': self.get_default_env()['id'], }) env = make_lifecycle_environment({u'organization-id': self.org['id']}) new_cv = make_content_view({u'organization-id': self.org['id']}) ContentView.publish({u'id': new_cv['id']}) cvv = ContentView.info({u'id': new_cv['id']})['versions'][0] ContentView.version_promote({ u'id': cvv['id'], u'to-lifecycle-environment-id': env['id'], }) ActivationKey.update({ u'id': ak_env['id'], u'lifecycle-environment-id': env['id'], u'content-view': new_cv['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': ak_env['id']}) self.assertEqual(updated_ak['lifecycle-environment'], env['name'])
def test_positive_delete_with_lce(self): """Create activation key with lifecycle environment assigned to it and delete it using activation key id :id: e1830e52-5b1a-4ac4-8d0a-df6efb218a8b :expectedresults: Activation key is deleted :CaseLevel: Integration """ new_ak = self._make_activation_key({ u'lifecycle-environment': self.get_default_env()['name'], }) ActivationKey.delete({'id': new_ak['id']}) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
def test_positive_delete_activation_key_2(self, test_data): """@Test: Create Activation key and delete it for all variations of Description @Feature: Activation key - Positive Delete @Steps: 1. Create Activation key for all valid Description in [1] using valid Name, Environment, Content View, Usage limit 2. Delete the Activation key @Assert: Activation key is deleted @bz: 1109650 """ try: activation_key = self._make_activation_key( {u"description": test_data["description"], u"organization-id": self.org["id"]} ) except CLIFactoryError as err: self.fail(err) result = ActivationKey.delete({"id": activation_key["id"]}) self.assertEqual(result.return_code, 0, "Failed to delete activation key") self.assertEqual(len(result.stderr), 0, "There should not be an error here") # Can we find the object? result = ActivationKey.info({"id": activation_key["id"]}) self.assertNotEqual(result.return_code, 0, "Activation key should be deleted") self.assertGreater(len(result.stderr), 0, "There should be an error here") self.assertEqual(len(result.stdout), 0, "Output should be blank")
def _make_activation_key(self, options=None): """ Make a new activation key and assert its success""" if options is None: options = {} # Use default organization if None are provided if (not options.get('organization', None) and not options.get('organization-label', None) and not options.get('organization-id', None)): options['organization-id'] = self.org['id'] # Create activation key ackey = make_activation_key(options) # Fetch it result = ActivationKey.info({'id': ackey['id']}) self.assertEqual( result.return_code, 0, "Activation key was not found: %s" % str(result.stderr)) self.assertEqual(len(result.stderr), 0, "No error was expected %s" % str(result.stderr)) # Return the activation key dictionary return ackey
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_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_delete_by_name(self): """Create Activation key and delete it for all variations of Activation key name @id: ef5f6a28-6bfd-415b-aac9-b3dc9a014ca9 @Assert: Activation key is deleted """ for name in valid_data_list(): with self.subTest(name): new_ak = self._make_activation_key({ u'name': name, u'organization-id': self.org['id'], }) ActivationKey.delete({ 'name': new_ak['name'], 'organization-id': self.org['id'], }) with self.assertRaises(CLIReturnCodeError): ActivationKey.info({'id': new_ak['id']})
def test_positive_remove_user(self): """Delete any user who has previously created an activation key and check that activation key still exists :id: ba9c4b29-2349-47ea-8081-917de2c17ed2 :expectedresults: Activation Key can be read :BZ: 1291271 """ password = gen_string('alpha') user = make_user({'password': password, 'admin': 'true'}) ak = ActivationKey.with_user( username=user['login'], password=password ).create({ 'name': gen_string('alpha'), 'organization-id': self.org['id'], }) User.delete({'id': user['id']}) try: ActivationKey.info({'id': ak['id']}) except CLIReturnCodeError: self.fail("Activation Key can't be read")
def test_positive_update_usage_limit_to_finite_number(self): """Update Usage limit from Unlimited to a finite number @id: a55bb8dc-c7d8-4a6a-ac0f-1d5a377da543 @Assert: Activation key is updated """ new_ak = self._make_activation_key() self.assertEqual(new_ak['host-limit'], u'Unlimited') ActivationKey.update({ u'max-hosts': '2147483647', u'name': new_ak['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': new_ak['id']}) self.assertEqual(updated_ak['host-limit'], u'2147483647')
def test_positive_update_usage_limit_to_finite_number(self): """Update Usage limit from Unlimited to a finite number @Feature: Activation key - Positive Update @Assert: Activation key is updated """ new_ak = self._make_activation_key() self.assertEqual(new_ak['content-host-limit'], u'Unlimited') ActivationKey.update({ u'max-content-hosts': '2147483647', u'name': new_ak['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': new_ak['id']}) self.assertEqual(updated_ak['content-host-limit'], u'2147483647')
def test_positive_update_description(self): """Update Description in an Activation key @id: 60a4e860-d99c-431e-b70b-9b0fa90d839b @Assert: Activation key is updated """ activation_key = self._make_activation_key() for description in valid_data_list(): with self.subTest(description): ActivationKey.update({ u'description': description, u'name': activation_key['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': activation_key['id']}) self.assertEqual(updated_ak['description'], description)
def test_positive_update_cv(self): """Update Content View in an Activation key @Feature: Activation key - Positive Update @Assert: Activation key is updated """ cv = make_content_view({u'organization-id': self.org['id']}) ak_cv = self._make_activation_key({u'content-view-id': cv['id']}) new_cv = make_content_view({u'organization-id': self.org['id']}) ActivationKey.update({ u'content-view': new_cv['name'], u'name': ak_cv['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': ak_cv['id']}) self.assertEqual(updated_ak['content-view'], new_cv['name'])
def test_positive_update_name_by_name(self): """Update Activation Key Name in an Activation key searching by name @id: bce4533e-1a58-4edb-a51a-4aa46bc28676 @Assert: Activation key is updated """ new_name = gen_string('alpha') activation_key = self._make_activation_key() ActivationKey.update({ u'name': activation_key['name'], u'new-name': new_name, u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': activation_key['id']}) self.assertEqual(updated_ak['name'], new_name)
def test_positive_update_name_by_id(self): """Update Activation Key Name in Activation key searching by ID @id: bc304894-fd9b-4622-96e3-57c2257e26ca @Assert: Activation key is updated """ activation_key = self._make_activation_key() for name in valid_data_list(): with self.subTest(name): ActivationKey.update({ u'id': activation_key['id'], u'new-name': name, u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': activation_key['id']}) self.assertEqual(updated_ak['name'], name)
def test_positive_update_usage_limit_to_unlimited(self): """Update Usage limit from definite number to Unlimited @id: 0b83657b-41d1-4fb2-9c23-c36011322b83 @Assert: Activation key is updated """ new_ak = self._make_activation_key({ u'max-hosts': '10', }) self.assertEqual(new_ak['host-limit'], u'10') ActivationKey.update({ u'unlimited-hosts': True, u'name': new_ak['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': new_ak['id']}) self.assertEqual(updated_ak['host-limit'], u'Unlimited')
def test_positive_update_cv(self): """Update Content View in an Activation key :id: aa94997d-fc9b-4532-aeeb-9f27b9834914 :expectedresults: Activation key is updated :CaseLevel: Integration """ cv = make_content_view({u'organization-id': self.org['id']}) ak_cv = self._make_activation_key({u'content-view-id': cv['id']}) new_cv = make_content_view({u'organization-id': self.org['id']}) ActivationKey.update({ u'content-view': new_cv['name'], u'name': ak_cv['name'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': ak_cv['id']}) self.assertEqual(updated_ak['content-view'], new_cv['name'])
def test_positive_create_using_old_name(self): """Create activation key, rename it and create another with the initial name @Feature: Activation key - Positive Create @Assert: Activation key is created """ name = gen_string('utf8') activation_key = self._make_activation_key({'name': name}) new_name = gen_string('utf8') ActivationKey.update({ u'id': activation_key['id'], u'new-name': new_name, u'organization-id': self.org['id'], }) activation_key = ActivationKey.info({'id': activation_key['id']}) self.assertEqual(activation_key['name'], new_name) new_activation_key = self._make_activation_key({ u'name': name, u'organization-id': self.org['id'], }) self.assertEqual(new_activation_key['name'], name)
def test_positive_update_autoattach_toggle(self): """Update Activation key with inverse auto-attach value @Feature: Activation key update / info @Steps: 1. Get the key's current auto attach value. 2. Update the key with the value's inverse. 3. Verify key was updated. @Assert: Activation key is successfully copied """ new_ak = self._make_activation_key() attach_value = new_ak['auto-attach'] # invert value new_value = u'false' if attach_value == u'true' else u'true' ActivationKey.update({ u'auto-attach': new_value, u'id': new_ak['id'], u'organization-id': self.org['id'], }) updated_ak = ActivationKey.info({'id': new_ak['id']}) self.assertEqual(updated_ak['auto-attach'], new_value)