def test_create_with_config_group(session, module_org, module_loc): """Create new host group with assigned config group to it :id: 05a64d6b-113b-4652-86bf-19bc65b70131 :expectedresults: Host group created and contains proper config group :CaseLevel: Integration :CaseImportance: High """ name = gen_string('alpha') environment = entities.Environment(organization=[module_org], location=[module_loc]).create() config_group = entities.ConfigGroup().create() with session: # Create host group with config group session.hostgroup.create({ 'host_group.name': name, 'host_group.puppet_environment': environment.name, 'puppet_classes.config_groups.assigned': [config_group.name], }) hostgroup_values = session.hostgroup.read( name, widget_names='puppet_classes') assert len(hostgroup_values['puppet_classes']['config_groups'] ['assigned']) == 1 assert hostgroup_values['puppet_classes']['config_groups']['assigned'][ 0] == config_group.name
def test_positive_create_with_config_group(session, module_host_template): """Create new Host with config group assigned to it :id: 8834011e-f920-43de-8f28-1f370b2b8d69 :expectedresults: Host is created and contains correct config group :CaseLevel: System """ config_group = entities.ConfigGroup().create() with session: host_name = create_fake_host( session, module_host_template, extra_values={ 'puppet_classes.config_groups.assigned': [config_group.name] }) assert session.host.search(host_name)[0]['Name'] == host_name values = session.host.read(host_name, widget_names='puppet_classes') assert len(values['puppet_classes']['config_groups']['assigned']) == 1 assert values['puppet_classes']['config_groups']['assigned'][ 0] == config_group.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_update_by_type(self): """Update entities of different types and check audit logs for these events using entity type and performed action as search criteria :id: fef54686-4c13-4f36-a616-51dc9b58be19 :expectedresults: Audit logs contain corresponding entries per each update event """ with Session(self): for entity_item in [ { 'entity': entities.Architecture(), 'entity_type': 'architecture' }, { 'entity': entities.ConfigGroup(), 'entity_type': 'config_group' }, { 'entity': entities.Domain(), 'entity_type': 'domain' }, { 'entity': entities.HostGroup(), 'entity_type': 'hostgroup' }, { 'entity': entities.Location(), 'entity_type': 'location' }, { 'entity': entities.PartitionTable(), 'entity_type': 'ptable', }, { 'entity': entities.Role(), 'entity_type': 'role' }, { 'entity': entities.ProvisioningTemplate(), 'entity_type': 'template', }, { 'entity': entities.UserGroup(), 'entity_type': 'usergroup' }, ]: entity = entity_item['entity'].create() name = entity.name new_name = gen_string('alpha') entity.name = new_name entity.update(['name']) self.audit.filter('type={} and action=update'.format( entity_item['entity_type'])) result = self.audit.get_last_entry() self.assertIn('updated', result['full_statement']) self.assertEqual(result['entity_name'], name) self.assertEqual( result['update_list'][0], 'Name changed from {} to {}'.format(name, new_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)