def test_positive_update_name(self): """Update selected Compute Profile entity using proper names @Feature: Compute Profile - Positive Update @Assert: Compute Profile is updated. """ profile = entities.ComputeProfile().create() for new_name in valid_data_list(): with self.subTest(new_name): updated_profile = entities.ComputeProfile( id=profile.id, name=new_name).update(['name']) self.assertEqual(new_name, updated_profile.name)
def test_positive_delete(self): """Delete Compute Profile entity @id: 0a620e23-7ba6-4178-af7a-fd1e332f478f @Assert: Compute Profile is deleted successfully. """ for name in valid_data_list(): with self.subTest(name): profile = entities.ComputeProfile(name=name).create() profile.delete() with self.assertRaises(HTTPError): entities.ComputeProfile(id=profile.id).read()
def test_positive_update_name(self): """Update selected Compute Profile entity using proper names @id: c79193d7-2e0f-4ed9-b947-05feeddabfda @Assert: Compute Profile is updated. """ profile = entities.ComputeProfile().create() for new_name in valid_data_list(): with self.subTest(new_name): updated_profile = entities.ComputeProfile( id=profile.id, name=new_name).update(['name']) self.assertEqual(new_name, updated_profile.name)
def test_positive_delete(self): """Delete Compute Profile entity @Feature: Compute Profile - Positive Delete @Assert: Compute Profile is deleted successfully. """ for name in valid_data_list(): with self.subTest(name): profile = entities.ComputeProfile(name=name).create() profile.delete() with self.assertRaises(HTTPError): entities.ComputeProfile(id=profile.id).read()
def test_positive_update_compute_profile(self): """Update a host with a new compute profile @feature: Hosts @assert: A host is updated with a new compute profile """ host = entities.Host( compute_profile=entities.ComputeProfile().create(), ).create() new_cprofile = entities.ComputeProfile().create() host.compute_profile = new_cprofile host = host.update(['compute_profile']) self.assertEqual(host.compute_profile.read().name, new_cprofile.name)
def test_positive_update_compute_profile(self): """Update a host with a new compute profile @id: a634c8a5-11ef-4d92-9df1-1f7e065f162e @assert: A host is updated with a new compute profile @CaseLevel: Integration """ host = entities.Host( compute_profile=entities.ComputeProfile().create(), ).create() new_cprofile = entities.ComputeProfile().create() host.compute_profile = new_cprofile host = host.update(['compute_profile']) self.assertEqual(host.compute_profile.read().name, new_cprofile.name)
def test_negative_update_name(self): """Attempt to update Compute Profile entity using invalid names only @Feature: Compute Profile - Negative Update @Assert: Compute Profile is not updated. """ profile = entities.ComputeProfile().create() for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(HTTPError): entities.ComputeProfile( id=profile.id, name=new_name).update(['name']) updated_profile = entities.ComputeProfile(id=profile.id).read() self.assertNotEqual(new_name, updated_profile.name)
def test_positive_rename(session): name = gen_string('alpha') new_name = gen_string('alpha') entities.ComputeProfile(name=name).create() with session: session.computeprofile.rename(name, {'name': new_name}) assert session.computeprofile.search(new_name)[0]['Name'] == new_name
def test_positive_delete(new_name): """Delete Compute Profile entity :id: 0a620e23-7ba6-4178-af7a-fd1e332f478f :expectedresults: Compute Profile is deleted successfully. :CaseImportance: Critical :CaseLevel: Component :parametrized: yes """ profile = entities.ComputeProfile(name=new_name).create() profile.delete() with pytest.raises(HTTPError): entities.ComputeProfile(id=profile.id).read()
def test_positive_update_name(self): """Update selected Compute Profile entity using proper names :id: c79193d7-2e0f-4ed9-b947-05feeddabfda :expectedresults: Compute Profile is updated. :CaseImportance: Critical :CaseLevel: Component """ profile = entities.ComputeProfile().create() for new_name in valid_data_list(): with self.subTest(new_name): updated_profile = entities.ComputeProfile( id=profile.id, name=new_name).update(['name']) self.assertEqual(new_name, updated_profile.name)
def test_positive_delete(self): """Delete Compute Profile entity :id: 0a620e23-7ba6-4178-af7a-fd1e332f478f :expectedresults: Compute Profile is deleted successfully. :CaseImportance: Critical :CaseLevel: Component """ for name in valid_data_list(): with self.subTest(name): profile = entities.ComputeProfile(name=name).create() profile.delete() with self.assertRaises(HTTPError): entities.ComputeProfile(id=profile.id).read()
def test_negative_update_name(self): """Attempt to update Compute Profile entity using invalid names only :id: 042b40d5-a78b-4e65-b5cb-5b270b800b37 :expectedresults: Compute Profile is not updated. :CaseImportance: Critical """ profile = entities.ComputeProfile().create() for new_name in invalid_values_list(): with self.subTest(new_name): with self.assertRaises(HTTPError): entities.ComputeProfile(id=profile.id, name=new_name).update(['name']) updated_profile = entities.ComputeProfile(id=profile.id).read() self.assertNotEqual(new_name, updated_profile.name)
def test_positive_update_name(new_name): """Update selected Compute Profile entity using proper names :id: c79193d7-2e0f-4ed9-b947-05feeddabfda :expectedresults: Compute Profile is updated. :CaseImportance: Critical :CaseLevel: Component :parametrized: yes """ profile = entities.ComputeProfile().create() entities.ComputeProfile(id=profile.id, name=new_name).update(['name']) updated_profile = entities.ComputeProfile(id=profile.id).read() assert new_name == updated_profile.name
def test_negative_update_name(new_name): """Attempt to update Compute Profile entity using invalid names only :id: 042b40d5-a78b-4e65-b5cb-5b270b800b37 :expectedresults: Compute Profile is not updated. :CaseImportance: Critical :CaseLevel: Component :parametrized: yes """ profile = entities.ComputeProfile().create() with pytest.raises(HTTPError): entities.ComputeProfile(id=profile.id, name=new_name).update(['name']) updated_profile = entities.ComputeProfile(id=profile.id).read() assert new_name != updated_profile.name
def test_positive_create_with_compute_profile(self): """Create a host with a compute profile specified @feature: Hosts @assert: A host is created with expected compute profile assigned """ profile = entities.ComputeProfile().create() host = entities.Host(compute_profile=profile).create() self.assertEqual(host.compute_profile.read().name, profile.name)
def test_negative_create(self): """Attempt to create Compute Profile using invalid names only @id: 2d34a1fd-70a5-4e59-b2e2-86fbfe8e31ab @Assert: Compute Profile is not created """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(HTTPError): entities.ComputeProfile(name=name).create()
def test_positive_create_with_name(self): """Create new Compute Profile using different names @id: 97d04911-9368-4674-92c7-1e3ff114bc18 @Assert: Compute Profile is created """ for name in valid_data_list(): with self.subTest(name): profile = entities.ComputeProfile(name=name).create() self.assertEqual(name, profile.name)
def test_positive_create_with_name(self): """Create new Compute Profile using different names @Feature: Compute Profile - Positive Create @Assert: Compute Profile is created """ for name in valid_data_list(): with self.subTest(name): profile = entities.ComputeProfile(name=name).create() self.assertEqual(name, profile.name)
def test_negative_create(self): """Attempt to create Compute Profile using invalid names only @Feature: Compute Profile - Negative Create @Assert: Compute Profile is not created """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(HTTPError): entities.ComputeProfile(name=name).create()
def test_positive_create_with_compute_profile(self): """Create a host with a compute profile specified @id: 94be25e8-035d-42c5-b1f3-3aa20030410d @assert: A host is created with expected compute profile assigned @CaseLevel: Integration """ profile = entities.ComputeProfile().create() host = entities.Host(compute_profile=profile).create() self.assertEqual(host.compute_profile.read().name, profile.name)
def test_positive_create_with_name(self): """Create new Compute Profile using different names :id: 97d04911-9368-4674-92c7-1e3ff114bc18 :expectedresults: Compute Profile is created :CaseImportance: Critical """ for name in valid_data_list(): with self.subTest(name): profile = entities.ComputeProfile(name=name).create() self.assertEqual(name, profile.name)
def test_negative_create(self): """Attempt to create Compute Profile using invalid names only :id: 2d34a1fd-70a5-4e59-b2e2-86fbfe8e31ab :expectedresults: Compute Profile is not created :CaseImportance: Critical """ for name in invalid_values_list(): with self.subTest(name): with self.assertRaises(HTTPError): entities.ComputeProfile(name=name).create()
def test_positive_end_to_end(session, module_loc, module_org): """Perform end to end testing for compute profile component :id: 5445fc7e-7b3f-472f-8a94-93f89aca6c22 :expectedresults: All expected CRUD actions finished successfully :CaseLevel: Integration :CaseImportance: High """ name = gen_string('alpha') new_name = gen_string('alpha') compute_resource = entities.LibvirtComputeResource( location=[module_loc], organization=[module_org], url='qemu+ssh://root@test/system').create() with session: session.computeprofile.create({'name': name}) assert entities.ComputeProfile().search( query={'search': 'name={0}'.format(name)} ), ('Compute profile {0} expected to exist, but is not included in the search ' 'results'.format(name)) compute_resource_list = session.computeprofile.list_resources(name) assert '{} (Libvirt)'.format(compute_resource.name) in [ resource['Compute Resource'] for resource in compute_resource_list ] session.computeprofile.rename(name, {'name': new_name}) assert entities.ComputeProfile().search( query={'search': 'name={0}'.format(new_name)} ), ('Compute profile {0} expected to exist, but is not included in the search ' 'results'.format(new_name)) session.computeprofile.delete(new_name) assert not entities.ComputeProfile( ).search(query={'search': 'name={0}'.format(new_name)}), ( 'Compute profile {0} expected to be deleted, but is included in the search ' 'results'.format(new_name))
def test_negative_create(name): """Attempt to create Compute Profile using invalid names only :id: 2d34a1fd-70a5-4e59-b2e2-86fbfe8e31ab :expectedresults: Compute Profile is not created :CaseImportance: Critical :CaseLevel: Component :parametrized: yes """ with pytest.raises(HTTPError): entities.ComputeProfile(name=name).create()
def test_positive_create_with_name(name): """Create new Compute Profile using different names :id: 97d04911-9368-4674-92c7-1e3ff114bc18 :expectedresults: Compute Profile is created :CaseImportance: Critical :CaseLevel: Component :parametrized: yes """ profile = entities.ComputeProfile(name=name).create() assert name == profile.name
def test_positive_create_and_update_with_compute_profile(module_compute_profile): """Create and update a host with a compute profile specified :id: 94be25e8-035d-42c5-b1f3-3aa20030410d :expectedresults: A host is created and updated with expected compute profile assigned :CaseLevel: Integration """ host = entities.Host(compute_profile=module_compute_profile).create() assert host.compute_profile.read().name == module_compute_profile.name new_cprofile = entities.ComputeProfile().create() host.compute_profile = new_cprofile host = host.update(['compute_profile']) assert host.compute_profile.read().name == new_cprofile.name
def test_positive_create_by_type(): """Create entities of different types and check audit logs for these events using entity type as search criteria :id: 6c7ea7fc-6728-447f-9655-26fe0a2881bc :customerscenario: true :expectedresults: Audit logs contain corresponding entries per each create event :BZ: 1426742, 1492668, 1492696 :CaseImportance: Medium """ for entity_item in [ { 'entity': entities.Architecture() }, { 'entity': entities.AuthSourceLDAP(), 'entity_type': 'auth_source', 'value_template': 'LDAP-{entity.name}', }, { 'entity': entities.ComputeProfile(), 'entity_type': 'compute_profile' }, { 'entity': entities.LibvirtComputeResource(), 'entity_type': 'compute_resource', 'value_template': '{entity.name} (Libvirt)', }, { 'entity': entities.ConfigGroup(), 'entity_type': 'config_group' }, { 'entity': entities.Domain() }, { 'entity': entities.Host() }, { 'entity': entities.HostGroup() }, { 'entity': entities.Image( compute_resource=entities.LibvirtComputeResource().create()) }, { 'entity': entities.Location() }, { 'entity': entities.Media(), 'entity_type': 'medium' }, { 'entity': entities.Organization() }, { 'entity': entities.OperatingSystem(), 'entity_type': 'os', 'value_template': '{entity.name} {entity.major}', }, { 'entity': entities.PartitionTable(), 'entity_type': 'ptable' }, { 'entity': entities.PuppetClass() }, { 'entity': entities.Role() }, { 'entity': entities.Subnet(), 'value_template': '{entity.name} ({entity.network}/{entity.cidr})', }, { 'entity': entities.ProvisioningTemplate(), 'entity_type': 'provisioning_template' }, { 'entity': entities.User(), 'value_template': '{entity.login}' }, { 'entity': entities.UserGroup() }, { 'entity': entities.ContentView(), 'entity_type': 'katello/content_view' }, { 'entity': entities.LifecycleEnvironment(), 'entity_type': 'katello/kt_environment' }, { 'entity': entities.ActivationKey(), 'entity_type': 'katello/activation_key' }, { 'entity': entities.HostCollection(), 'entity_type': 'katello/host_collection' }, { 'entity': entities.Product(), 'entity_type': 'katello/product' }, { 'entity': entities.GPGKey(), 'entity_type': 'katello/gpg_key', 'value_template': 'content credential (gpg_key - {entity.name})', }, { 'entity': entities.SyncPlan(organization=entities.Organization(id=1)), 'entity_type': 'katello/sync_plan', }, ]: created_entity = entity_item['entity'].create() entity_type = entity_item.get( 'entity_type', created_entity.__class__.__name__.lower()) value_template = entity_item.get('value_template', '{entity.name}') entity_value = value_template.format(entity=created_entity) audits = entities.Audit().search( query={'search': f'type={entity_type}'}) entity_audits = [ entry for entry in audits if entry.auditable_name == entity_value ] assert entity_audits, ( f'audit not found by name "{entity_value}" for entity: ' f'{created_entity.__class__.__name__.lower()}') audit = entity_audits[0] assert audit.auditable_id == created_entity.id assert audit.action == 'create' assert audit.version == 1
def test_positive_create_by_type(self): """Create entities of different types and check audit logs for these events using entity type and performed action as search criteria :id: 26197b39-4d56-4aab-8df8-f0fcedbffdb7 :expectedresults: Audit logs contain corresponding entries per each create event :CaseImportance: Critical """ with Session(self): for entity_item in [ { 'entity': entities.Architecture(), 'entity_type': 'architecture' }, { 'entity': entities.AuthSourceLDAP(), 'entity_type': 'auth_source', 'value_template': 'LDAP-{entity.name}' }, { 'entity': entities.ComputeProfile(), 'entity_type': 'compute_profile' }, { 'entity': entities.LibvirtComputeResource(), 'entity_type': 'compute_resource', 'value_template': '{entity.name} (Libvirt)' }, { 'entity': entities.ConfigGroup(), 'entity_type': 'config_group' }, { 'entity': entities.Domain(), 'entity_type': 'domain' }, { 'entity': entities.Host(), 'entity_type': 'host' }, { 'entity': entities.HostGroup(), 'entity_type': 'hostgroup' }, { 'entity': entities.Image(compute_resource=entities. LibvirtComputeResource().create()), 'entity_type': 'image' }, { 'entity': entities.Location(), 'entity_type': 'location' }, { 'entity': entities.Media(), 'entity_type': 'medium', 'custom_operation': 'added', }, { 'entity': entities.Organization(), 'entity_type': 'organization' }, { 'entity': entities.OperatingSystem(), 'entity_type': 'os', 'value_template': '{entity.name} {entity.major}' }, { 'entity': entities.PartitionTable(), 'entity_type': 'ptable', }, { 'entity': entities.PuppetClass(), 'entity_type': 'puppetclass' }, { 'entity': entities.Role(), 'entity_type': 'role' }, { 'entity': entities.Subnet(), 'entity_type': 'subnet', 'value_template': '{entity.name} ' '({entity.network}/{entity.cidr})' }, { 'entity': entities.ProvisioningTemplate(), 'entity_type': 'template', }, { 'entity': entities.User(), 'value_template': '{entity.login}', 'entity_type': 'user', }, { 'entity': entities.UserGroup(), 'entity_type': 'usergroup' }, ]: created_entity = entity_item['entity'].create() value_template = entity_item.get('value_template', '{entity.name}') operation_type = entity_item.get('custom_operation', 'created') entity_value = value_template.format(entity=created_entity) self.audit.filter('type={} and action=create'.format( entity_item['entity_type'])) result = self.audit.get_last_entry() self.assertIn(operation_type, result['full_statement']) self.assertEqual(entity_value, result['entity_name'])
def test_positive_delete(session): name = gen_string('alpha') entities.ComputeProfile(name=name).create() with session: session.computeprofile.delete(name) assert not session.computeprofile.search(name)
def test_positive_create_by_type(self): """Create entities of different types and check audit logs for these events using entity type as search criteria :id: 6c7ea7fc-6728-447f-9655-26fe0a2881bc :customerscenario: true :expectedresults: Audit logs contain corresponding entries per each create event :BZ: 1426742, 1492668, 1492696 :CaseImportance: Critical """ for entity_item in [ {'entity': entities.Architecture()}, { 'entity': entities.AuthSourceLDAP(), 'entity_type': 'auth_source', 'value_template': 'LDAP-{entity.name}' }, { 'entity': entities.ComputeProfile(), 'entity_type': 'compute_profile' }, { 'entity': entities.LibvirtComputeResource(), 'entity_type': 'compute_resource', 'value_template': '{entity.name} (Libvirt)' }, {'entity': entities.ConfigGroup(), 'entity_type': 'config_group'}, {'entity': entities.Domain()}, {'entity': entities.Host()}, {'entity': entities.HostGroup()}, {'entity': entities.Image( compute_resource=entities.LibvirtComputeResource().create())}, {'entity': entities.Location()}, {'entity': entities.Media(), 'entity_type': 'medium'}, {'entity': entities.Organization()}, { 'entity': entities.OperatingSystem(), 'entity_type': 'os', 'value_template': '{entity.name} {entity.major}' }, { 'entity': entities.PartitionTable(), 'entity_type': 'ptable', }, {'entity': entities.PuppetClass()}, {'entity': entities.Role()}, { 'entity': entities.Subnet(), 'value_template': '{entity.name} ' '({entity.network}/{entity.cidr})' }, { 'entity': entities.ProvisioningTemplate(), 'entity_type': 'template', }, {'entity': entities.User(), 'value_template': '{entity.login}'}, {'entity': entities.UserGroup()}, ]: created_entity = entity_item['entity'].create() entity_type = entity_item.get( 'entity_type', created_entity.__class__.__name__.lower()) value_template = entity_item.get('value_template', '{entity.name}') entity_value = value_template.format(entity=created_entity) audits = entities.Audit().search( query={'search': 'type={0}'.format(entity_type)}) entity_audits = [entry for entry in audits if entry.auditable_name == entity_value] if not entity_audits: self.fail('audit not found by name "{}"'.format(entity_value)) audit = entity_audits[0] self.assertEqual(audit.auditable_id, created_entity.id) self.assertEqual(audit.action, 'create') self.assertEqual(audit.version, 1)