def test_positive_update_domain(self): """Update a hostgroup with a new domain :id: db7b79e9-a833-4d93-96e2-d9adc9f35c21 :expectedresults: A hostgroup is updated with expected domain :CaseLevel: Integration """ domain = entities.Domain( location=[self.loc], organization=[self.org], ).create() hostgroup = entities.HostGroup( domain=domain, location=[self.loc], organization=[self.org], ).create() new_domain = entities.Domain( location=[self.loc], organization=[self.org], ).create() hostgroup.domain = new_domain hostgroup = hostgroup.update(['domain']) self.assertEqual(hostgroup.domain.read().name, new_domain.name)
def default_domain(default_smart_proxy): domain_name = settings.server.hostname.partition('.')[-1] dom = entities.Domain().search( query={'search': 'name={}'.format(domain_name)})[0] dom.dns = default_smart_proxy dom.update(['dns']) return entities.Domain(id=dom.id).read()
def gce_domain(module_org, module_location, default_smart_proxy, default_sat): """Sets Domain for GCE Host Provisioning""" _, _, dom = default_sat.hostname.partition('.') domain = entities.Domain().search(query={'search': f'name="{dom}"'}) domain = domain[0].read() domain.location.append(module_location) domain.organization.append(module_org) domain.dns = default_smart_proxy domain.update(['dns', 'location', 'organization']) return entities.Domain(id=domain.id).read()
def gce_domain(module_org, module_location, module_smart_proxy): """Sets Domain for GCE Host Provisioning""" _, _, dom = settings.server.hostname.partition('.') domain = entities.Domain().search( query={'search': 'name="{0}"'.format(dom)}) domain = domain[0].read() domain.location.append(module_location) domain.organization.append(module_org) domain.dns = module_smart_proxy domain.update(['dns', 'location', 'organization']) return entities.Domain(id=domain.id).read()
def test_positive_update_domain(self): """Update location with new domain @Assert: Location updated successfully and has correct domain assigned @Feature: Location - Update """ location = entities.Location( domain=[entities.Domain().create()], ).create() domain = entities.Domain().create() location.domain = [domain] self.assertEqual(location.update(['domain']).domain[0].id, domain.id)
def test_positive_update_domain(self): """Update location with new domain @id: 1016dfb9-8103-45f1-8738-0579fa9754c1 @Assert: Location updated successfully and has correct domain assigned @CaseLevel: Integration """ location = entities.Location(domain=[entities.Domain().create() ], ).create() domain = entities.Domain().create() location.domain = [domain] self.assertEqual(location.update(['domain']).domain[0].id, domain.id)
def test_negative_update_domain(self): """Try to update existing location with incorrect domain. Use domain id :id: e26c92f2-42cb-4706-9e03-3e00a134cb9f :expectedresults: Location is not updated :CaseLevel: Integration """ location = entities.Location(domain=[entities.Domain().create()]).create() domain = entities.Domain().create() location.domain[0].id = gen_integer(10000, 99999) with pytest.raises(HTTPError): assert location.update(['domain']).domain[0].id != domain.id
def setUpClass(cls): """Set up reusable entities for tests.""" super().setUpClass() cls.subnet = entities.Subnet().create() cls.env = entities.Environment().create() cls.env2 = entities.Environment().create() cls.domain = entities.Domain().create() cls.domain2 = entities.Domain().create() cls.medium = make_medium() cls.host_group = entities.HostGroup().create() cls.host_group2 = entities.HostGroup().create() cls.host_group3 = entities.HostGroup().create() cls.comp_resource = entities.LibvirtComputeResource().create() cls.template = entities.ProvisioningTemplate().create() cls.user = entities.User().create()
def setupScenario(self): """Create hostgroup and its dependant entities """ self.org = entities.Organization().create() self.loc = entities.Location(organization=[self.org]).create() self.parent_hostgroup = entities.HostGroup( location=[self.loc.id], organization=[self.org.id], name=self.parent_name).create() self.lc_env = entities.LifecycleEnvironment( name=gen_string('alpha'), organization=self.org, ).create() self.domain = entities.Domain(name=self.domain_name).create() self.architecture = entities.Architecture().create() self.ptable = entities.PartitionTable().create() self.operatingsystem = entities.OperatingSystem( architecture=[self.architecture], ptable=[self.ptable], name=self.os_name).create() self.medium = entities.Media( operatingsystem=[self.operatingsystem]).create() self.subnet = entities.Subnet(location=[self.loc], organization=[self.org], name=self.subnet_name).create()
def test_positive_delete_by_type(): """Delete some entities of different types and check audit logs for these events using entity type as search criteria :id: de9b056f-10da-485a-87ce-b02a9efff15c :expectedresults: Audit logs contain corresponding entries per each delete event :CaseImportance: Medium """ for entity in [ entities.Architecture(), entities.Domain(), entities.Host(), entities.HostGroup(), entities.Location(), entities.Role(), entities.UserGroup(), ]: created_entity = entity.create() created_entity.delete() audits = entities.Audit().search( query={ 'search': f'type={created_entity.__class__.__name__.lower()}' }) entity_audits = [ entry for entry in audits if entry.auditable_name == created_entity.name ] assert entity_audits, f'audit not found by name "{created_entity.name}"' audit = entity_audits[0] assert audit.auditable_id == created_entity.id assert audit.action == 'destroy' assert audit.version == 2
def test_positive_update_by_type(self): """Update some entities of different types and check audit logs for these events using entity type as search criteria :id: 43e73a11-b241-4b91-bdf6-e966366014e8 :expectedresults: Audit logs contain corresponding entries per each update event """ for entity in [ entities.Architecture(), entities.Domain(), entities.HostGroup(), entities.Location(), entities.Organization(), entities.Role(), entities.UserGroup(), ]: created_entity = entity.create() name = created_entity.name new_name = gen_string('alpha') created_entity.name = new_name created_entity = created_entity.update(['name']) audit = entities.Audit().search( query={'search': 'type={0}'.format( created_entity.__class__.__name__.lower()) } )[0] self.assertEqual(audit.auditable_name, name) self.assertEqual(audit.auditable_id, created_entity.id) self.assertEqual( audit.audited_changes['name'], [name, new_name]) self.assertEqual(audit.action, 'update') self.assertEqual(audit.version, 2)
def test_positive_add_domain(self): """Create new subnet and associate domain with it :id: adbc7189-b451-49df-aa10-2ae732832dfe :expectedresults: Subnet is created with domain associated :CaseLevel: Integration """ name = gen_string('alpha') domain = entities.Domain( organization=[self.organization] ).create() with Session(self.browser) as session: make_subnet( session, org=self.organization.name, subnet_name=name, subnet_network=gen_ipaddr(ip3=True), subnet_mask=gen_netmask(), domains=[domain.name], ) self.subnet.search_and_click(name) self.subnet.click(tab_locators['subnet.tab_domain']) element = self.subnet.wait_until_element( common_locators['entity_deselect'] % domain.name) checkbox_element = self.subnet.wait_until_element( common_locators['entity_checkbox'] % domain.name) # Depending upon the number of domains either, checkbox or # selection list appears. if element is None and checkbox_element is None: raise UIError('Neither checkbox or select list is present') if checkbox_element: self.assertTrue(checkbox_element.is_selected())
def test_positive_remove_domain(self): """Add a domain to an organization and remove it by organization name and domain name. @feature: Organizations Disassociate domain. @assert: the domain is removed from the organization """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] with Session(self.browser) as session: for domain_name in generate_strings_list(): with self.subTest(domain_name): org_name = gen_string('alpha') domain = entities.Domain(name=domain_name).create() self.assertEqual(domain.name, domain_name) make_org(session, org_name=org_name, domains=[domain_name]) self.org.search(org_name).click() session.nav.click(tab_locators['context.tab_domains']) element = session.nav.wait_until_element( (strategy1, value1 % domain_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.org.update(org_name, domains=[domain_name]) self.org.search(org_name).click() session.nav.click(tab_locators['context.tab_domains']) element = session.nav.wait_until_element( (strategy, value % domain_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_remove_domain(self): """Add a domain to an location and remove it by location name and domain name @feature: Locations @assert: the domain is removed from the location """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] with Session(self.browser) as session: for domain_name in generate_strings_list(): with self.subTest(domain_name): loc_name = gen_string('alpha') domain = entities.Domain(name=domain_name).create() self.assertEqual(domain.name, domain_name) set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_domains']) element = session.nav.wait_until_element( (strategy1, value1 % domain_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, domains=[domain_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_domains']) element = session.nav.wait_until_element( (strategy, value % domain_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_delete_by_type(self): """Delete some entities of different types and check audit logs for these events using entity type as search criteria :id: de9b056f-10da-485a-87ce-b02a9efff15c :expectedresults: Audit logs contain corresponding entries per each delete event """ for entity in [ entities.Architecture(), entities.Domain(), entities.Host(), entities.HostGroup(), entities.Location(), entities.Organization(), entities.Role(), entities.UserGroup(), ]: created_entity = entity.create() created_entity.delete() audits = entities.Audit().search( query={'search': 'type={0}'.format( created_entity.__class__.__name__.lower()) } ) entity_audits = [entry for entry in audits if entry.auditable_name == created_entity.name] if not entity_audits: self.fail('audit not found by name "{}"'.format( created_entity.name)) audit = entity_audits[0] self.assertEqual(audit.auditable_id, created_entity.id) self.assertEqual(audit.action, 'destroy') self.assertEqual(audit.version, 2)
def test_positive_update_domain(self): """Add a domain to an organization and remove it by organization name and domain name. :id: a49e86c7-f859-4120-b59e-3f89e99a9054 :expectedresults: the domain is added and removed from the organization :CaseLevel: Integration """ with Session(self.browser) as session: org_name = gen_string('alpha') make_org(session, org_name=org_name) for domain_name in generate_strings_list(): with self.subTest(domain_name): domain = entities.Domain(name=domain_name).create() self.assertEqual(domain.name, domain_name) kwargs = { 'org_name': org_name, 'entity_type': 'domains', 'entity_name': domain_name } self.assertIsNotNone(self.org.add_entity(**kwargs)) self.assertIsNotNone(self.org.remove_entity(**kwargs))
def test_positive_add_domain(self): """Create new subnet and associate domain with it @Feature: Subnet - Positive Create @Assert: Subnet is created with domain associated """ strategy1, value1 = common_locators['entity_deselect'] strategy2, value2 = common_locators['entity_checkbox'] name = gen_string('alpha') domain = entities.Domain(organization=[self.organization]).create() with Session(self.browser) as session: make_subnet( session, org=self.organization.name, subnet_name=name, subnet_network=gen_ipaddr(ip3=True), subnet_mask=gen_netmask(), domains=[domain.name], ) subnet = self.subnet.search(name) session.nav.click(subnet) session.nav.click(tab_locators['subnet.tab_domain']) element = session.nav.wait_until_element( (strategy1, value1 % domain.name)) checkbox_element = session.nav.wait_until_element( (strategy2, value2 % domain.name)) # Depending upon the number of domains either, checkbox or # selection list appears. if element is None and checkbox_element is None: raise UIError('Neither checkbox or select list is present') if checkbox_element: self.assertTrue(checkbox_element.is_selected())
def setUpClass(cls): """Import some parametrized puppet classes. This is required to make sure that we have smart class parameter available. Read all available smart class parameters for imported puppet class to be able to work with unique entity for each specific test. """ super(SmartClassParametersTestCase, cls).setUpClass() cls.pm_name = 'ui_test_classparameters' cls.puppet_modules = [ {'author': 'robottelo', 'name': cls.pm_name}, ] cv = publish_puppet_module( cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.session_org) cls.env = entities.Environment().search( query={'search': u'content_view="{0}"'.format(cv.name)} )[0].read() cls.puppet_class = entities.PuppetClass().search(query={ 'search': u'name = "{0}" and environment = "{1}"'.format( cls.puppet_modules[0]['name'], cls.env.name) })[0] cls.sc_params_list = entities.SmartClassParameters().search( query={ 'search': 'puppetclass="{0}"'.format(cls.puppet_class.name), 'per_page': 1000 }) cls.host = entities.Host(organization=cls.session_org).create() cls.host.environment = cls.env cls.host.update(['environment']) cls.host.add_puppetclass(data={'puppetclass_id': cls.puppet_class.id}) cls.domain_name = entities.Domain(id=cls.host.domain.id).read().name
def api_components(cls, id=None): """Components for which the post upgrade existence will be validated from API end :param str id: The id of an entity to get its data :returns dict: The dict of entities, where each key is component name and value is a list. In list the first item will be used to get list of a component entities and second will be used to get particular component entity data """ api_comps = { 'domain': [entities.Domain(), entities.Domain(id=id)], 'subnet': [entities.Subnet(), entities.Subnet(id=id)], 'contentview': [ entities.ContentView(), entities.ContentView(id=id)] } return api_comps
def test_negative_update_domain(self): """Try to update existing location with incorrect domain. Use domain id @id: e26c92f2-42cb-4706-9e03-3e00a134cb9f @Assert: Location is not updated @CaseLevel: Integration """ location = entities.Location(domain=[entities.Domain().create() ], ).create() domain = entities.Domain().create() location.domain[0].id = gen_integer(10000, 99999) with self.assertRaises(HTTPError): self.assertNotEqual( location.update(['domain']).domain[0].id, domain.id)
def test_negative_assign_taxonomies_by_org_admin(self): """Org Admin doesn't have permissions to assign org to any of its entities :id: d8586573-70df-4438-937f-4869583a3d58 :steps: 1. Create Org Admin role by cloning 'Organization admin' role 2. Assign an organization A,B and Location A,B to the Org Admin role 3. Create user and assign above Org Admin role 4. Assign Organization A,B and Location A,B to the user 5. Login from the new user and attempt to assign organization(s) to any resource :expectedresults: Org Admin should not be able to assign the organizations to any of its resources :CaseLevel: Integration """ org_admin = self.create_org_admin_role(orgs=[self.role_org.id], locs=[self.role_loc.id]) # Creating resource dom_name = gen_string('alpha') dom = entities.Domain(name=dom_name, organization=[self.role_org], location=[self.role_loc]).create() self.assertEqual(dom_name, dom.name) user_login = gen_string('alpha') user_pass = gen_string('alphanumeric') user = entities.User(login=user_login, password=user_pass, role=[org_admin.id], organization=[self.role_org], location=[self.role_loc]).create() self.assertEqual(user_login, user.login) sc = ServerConfig(auth=(user_login, user_pass), url=self.sat_url, verify=False) # Getting the domain from user1 dom = entities.Domain(sc, id=dom.id).read() dom.organization = [self.filter_org] with self.assertRaises(HTTPError): dom.update(['organization'])
def test_negative_update_domain(self): """Try to update existing location with incorrect domain. Use domain id @Assert: Location is not updated @Feature: Location - Update """ location = entities.Location( domain=[entities.Domain().create()], ).create() domain = entities.Domain().create() location.domain[0].id = gen_integer(10000, 99999) with self.assertRaises(HTTPError): self.assertNotEqual( location.update(['domain']).domain[0].id, domain.id )
def make_entities(self): """Set up reusable entities for tests.""" return dict( domain=entities.Domain().create(), subnet=entities.Subnet().create(), env=entities.Environment().create(), host_group=entities.HostGroup().create(), template=entities.ProvisioningTemplate().create(), test_cr=entities.LibvirtComputeResource().create(), new_user=entities.User().create(), )
def test_pre_create_hostgroup(self, request): """Hostgroup with different data type are created :id: preupgrade-79958754-94b6-4bfe-af12-7d4031cd2dd2 :steps: In Preupgrade Satellite, Create hostgroup with different entities. :expectedresults: Hostgroup should be create successfully. """ proxy = entities.SmartProxy().search( query={'search': f'url = https://{settings.server.hostname}:9090' })[0] test_name = request.node.name org = entities.Organization(name=f"{test_name}_org").create() loc = entities.Location(organization=[org], name=f"{test_name}_loc").create() parent_hostgroup = entities.HostGroup( location=[loc.id], organization=[org.id], name=f'{test_name}_parent_host_grp').create() lc_env = entities.LifecycleEnvironment(name=f"{test_name}_lce", organization=org).create() domain = entities.Domain(name=f"{test_name}_domain").create() architecture = entities.Architecture().create() ptable = entities.PartitionTable().create() operatingsystem = entities.OperatingSystem( architecture=[architecture], ptable=[ptable], name=f"{test_name}_os").create() medium = entities.Media(operatingsystem=[operatingsystem]).create() subnet = entities.Subnet(location=[loc], organization=[org], name=f"{test_name}_subnet").create() host_group = entities.HostGroup( architecture=architecture, domain=domain, location=[loc.id], medium=medium, name=f"{test_name}_host_grp", operatingsystem=operatingsystem, organization=[org.id], ptable=ptable, puppet_proxy=proxy, puppet_ca_proxy=proxy, subnet=subnet, parent=parent_hostgroup, lifecycle_environment=lc_env, content_source=proxy, root_pass='******', ).create() assert host_group.name == f"{test_name}_host_grp"
def compute_resource_setup(self, default_org): self.libvirt_vm = settings.libvirt.libvirt_hostname self.default_org_id = default_org.id self.org = default_org self.bridge = settings.vlan_networking.bridge self.subnet = settings.vlan_networking.subnet self.gateway = settings.vlan_networking.gateway self.netmask = settings.vlan_networking.netmask self.vm_domain_name = settings.upgrade.vm_domain self.vm_domain = entities.Domain().search(query={'search': f'name="{self.vm_domain_name}"'}) self.proxy_name = settings.upgrade.capsule_hostname
def setUpClass(cls): cls.libvirt_vm = os.environ.get('LIBVIRT_HOSTNAME') cls.org = entities.Organization(id=1).read() cls.bridge = os.environ.get('BRIDGE') cls.subnet = os.environ.get('SUBNET') cls.gateway = os.environ.get('GATEWAY') cls.netmask = os.environ.get('NETMASK') cls.vm_domain_name = os.environ.get('VM_DOMAIN') cls.vm_domain = entities.Domain().search(query={'search': 'name="{}"' .format(cls.vm_domain_name)}) cls.proxy_name = os.environ.get('RHEV_CAP_HOST')
def test_positive_create_with_domain(self): """Create new location with assigned domain to it @Assert: Location created successfully and has correct and expected domain assigned to it @Feature: Location """ domain = entities.Domain().create() location = entities.Location(domain=[domain]).create() self.assertEqual(location.domain[0].id, domain.id)
def setUpClass(cls): """Set up reusable entities for tests.""" super(LocationTestCase, cls).setUpClass() cls.org = entities.Organization().create() cls.org2 = entities.Organization().create() cls.domain = entities.Domain().create() cls.subnet = entities.Subnet().create() cls.env = entities.Environment().create() cls.host_group = entities.HostGroup().create() cls.template = entities.ProvisioningTemplate().create() cls.test_cr = entities.LibvirtComputeResource().create() cls.new_user = entities.User().create()
def test_positive_end_to_end(session, module_org, module_loc): """Perform end to end testing for host group component :id: 537d95f2-fe32-4e06-a2cb-21c80fe8e2e2 :expectedresults: All expected CRUD actions finished successfully :CaseLevel: Integration :CaseImportance: High """ name = gen_string('alpha') new_name = gen_string('alpha') description = gen_string('alpha') architecture = entities.Architecture().create() os = entities.OperatingSystem(architecture=[architecture]).create() os_name = u'{0} {1}'.format(os.name, os.major) domain = entities.Domain(organization=[module_org], location=[module_loc]).create() with session: # Create host group with some data session.hostgroup.create({ 'host_group.name': name, 'host_group.description': description, 'host_group.lce': ENVIRONMENT, 'host_group.content_view': DEFAULT_CV, 'network.domain': domain.name, 'operating_system.architecture': architecture.name, 'operating_system.operating_system': os_name, }) hostgroup_values = session.hostgroup.read(name) assert hostgroup_values['host_group']['name'] == name assert hostgroup_values['host_group']['description'] == description assert hostgroup_values['host_group']['lce'] == ENVIRONMENT assert hostgroup_values['host_group']['content_view'] == DEFAULT_CV assert hostgroup_values['operating_system'][ 'architecture'] == architecture.name assert hostgroup_values['operating_system'][ 'operating_system'] == os_name # Update host group with new name session.hostgroup.update(name, {'host_group.name': new_name}) assert session.hostgroup.search(new_name)[0]['Name'] == new_name # Delete host group session.hostgroup.delete(new_name) assert not session.hostgroup.search(new_name)
def test_positive_create_with_domain(self): """Create new location with assigned domain to it @id: 3f79a584-e195-4f1d-a978-777bae200251 @Assert: Location created successfully and has correct and expected domain assigned to it @CaseLevel: Integration """ domain = entities.Domain().create() location = entities.Location(domain=[domain]).create() self.assertEqual(location.domain[0].id, domain.id)