def test_positive_update_2(self): """@Test: Check if Subnet network and mask can be updated @Feature: Subnet - Update @Assert: Subnet network and mask are updated """ network = gen_ipaddr() mask = '255.255.255.0' try: subnet = make_subnet({ u'network': network, u'mask': mask, }) except CLIFactoryError as err: self.fail(err) new_network = gen_ipaddr() new_mask = '255.255.192.0' result = Subnet.update({ u'id': subnet['id'], u'network': new_network, u'mask': new_mask, }) self.assertEqual(result.return_code, 0) # check - subnet is updated result = Subnet.info({u'id': subnet['id']}) self.assertEqual(result.stdout['network'], new_network) self.assertEqual(result.stdout['mask'], new_mask)
def test_positive_update_network_mask(self): """Check if Subnet network and mask can be updated :id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4 :expectedresults: Subnet network and mask are updated :CaseImportance: Critical """ network = gen_ipaddr() mask = '255.255.255.0' subnet = make_subnet({ u'mask': mask, u'network': network, }) new_network = gen_ipaddr() new_mask = '255.255.192.0' Subnet.update({ u'id': subnet['id'], u'mask': new_mask, u'network': new_network, }) # check - subnet is updated subnet = Subnet.info({u'id': subnet['id']}) self.assertEqual(subnet['network-addr'], new_network) self.assertEqual(subnet['network-mask'], new_mask)
def test_positive_update_2(self): """@Test: Check if Subnet network and mask can be updated @Feature: Subnet - Update @Assert: Subnet network and mask are updated """ network = gen_ipaddr() mask = '255.255.255.0' subnet = make_subnet({ u'mask': mask, u'network': network, }) new_network = gen_ipaddr() new_mask = '255.255.192.0' Subnet.update({ u'id': subnet['id'], u'mask': new_mask, u'network': new_network, }) # check - subnet is updated subnet = Subnet.info({u'id': subnet['id']}) self.assertEqual(subnet['network'], new_network) self.assertEqual(subnet['mask'], new_mask)
def test_positive_update_network_mask(self): """Check if Subnet network and mask can be updated :id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4 :expectedresults: Subnet network and mask are updated :CaseImportance: Critical """ network = gen_ipaddr() mask = '255.255.255.0' subnet = make_subnet({ u'mask': mask, u'network': network, }) new_network = gen_ipaddr() new_mask = '255.255.192.0' Subnet.update({ u'id': subnet['id'], u'mask': new_mask, u'network': new_network, }) # check - subnet is updated subnet = Subnet.info({u'id': subnet['id']}) self.assertEqual(subnet['network'], new_network) self.assertEqual(subnet['mask'], new_mask)
def test_gen_ipv4_12(self): """ @Test: Generate a 3 group IPv4 address with prefix too long @Feature: IPAddr Generator @Assert: An exception is raised """ with self.assertRaises(ValueError): gen_ipaddr(ip3=True, ipv6=False, prefix=[10, 10, 10, 10])
def test_gen_ipv4_8(self): """ @Test: Generate a 4 group IPv4 address with prefix disabling randomness @Feature: IPAddr Generator @Assert: An exception is raised """ with self.assertRaises(ValueError): gen_ipaddr(ip3=False, ipv6=False, prefix=[10, 10, 10, 10])
def test_gen_ipv6_6(self): """ @Test: Generate a IPv6 address with even longer prefix @Feature: IPAddr Generator @Assert: ValueError raised """ prefix = 9 * ["e2d3"] with self.assertRaises(ValueError): gen_ipaddr(ipv6=True, prefix=prefix)
def test_positive_update_ip(self): """Update a host with a new IP address @feature: Hosts @assert: A host is updated with a new IP address """ host = entities.Host(ip=gen_ipaddr()).create() new_ip = gen_ipaddr() host.ip = new_ip host = host.update(['ip']) self.assertEqual(host.ip, new_ip)
def test_positive_update_ip(self): """Update a host with a new IP address @id: 4c009db9-d720-429e-8150-bebf246d3a43 @assert: A host is updated with a new IP address """ host = entities.Host(ip=gen_ipaddr()).create() new_ip = gen_ipaddr() host.ip = new_ip host = host.update(['ip']) self.assertEqual(host.ip, new_ip)
def test_positive_sort_by_network(self): """Create some Subnet entities and sort them by network address :id: 63dc846e-7520-4e8c-8875-a0109d7e5df4 :customerscenario: true :expectedresults: Subnet entities are sorted by network address :BZ: 1268085, 1494180 :CaseImportance: Medium """ organization = entities.Organization().create() network_list = [gen_ipaddr(ip3=True) for _ in range(5)] network_list.sort(key=lambda s: map(int, s.split('.')), reverse=True) with Session(self) as session: set_context(session, org=organization.name) for ip in network_list: make_subnet( session, subnet_name=gen_string('alpha'), subnet_network=ip, subnet_mask=gen_netmask(), ) sorted_list_asc = self.subnet.sort_table_by_column( 'Network address') self.assertEqual([el.split('/', 1)[0] for el in sorted_list_asc], network_list[::-1]) sorted_list_desc = self.subnet.sort_table_by_column( 'Network address') self.assertEqual([el.split('/', 1)[0] for el in sorted_list_desc], network_list)
def test_positive_remove_subnet(self): """Remove subnet by using location name and subnet name @feature: Locations @assert: subnet is added then removed """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string("alpha") subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask="255.255.255.0" ).create() self.assertEqual(subnet.name, subnet_name) set_context(session, org=ANY_CONTEXT["org"]) make_loc(session, name=loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.click(tab_locators["context.tab_subnets"]) element = session.nav.wait_until_element((strategy1, value1 % subnet_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() self.location.click(tab_locators["context.tab_subnets"]) element = session.nav.wait_until_element((strategy, value % subnet_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_subnet(self): """Add a subnet using organization name and subnet name. @id: 6736cd82-a2b0-4fc0-a2bc-99c9f13464d7 @assert: subnet is added. @CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): org_name = gen_string('alpha') # Create subnet using nailgun subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0' ).create() self.assertEqual(subnet.name, subnet_name) make_org(session, org_name=org_name) self.assertIsNotNone(self.org.search(org_name)) self.org.update(org_name, new_subnets=[subnet_name]) self.org.search(org_name).click() session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
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) 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_sort_by_network(self): """Create some Subnet entities and sort them by network address :id: 63dc846e-7520-4e8c-8875-a0109d7e5df4 :expectedresults: Subnet entities are sorted by network address :BZ: 1268085, 1494180 :CaseImportance: Medium """ organization = entities.Organization().create() network_list = [gen_ipaddr(ip3=True) for _ in range(5)] network_list.sort(key=lambda s: map(int, s.split('.')), reverse=True) with Session(self) as session: set_context(session, org=organization.name) for ip in network_list: make_subnet( session, subnet_name=gen_string('alpha'), subnet_network=ip, subnet_mask=gen_netmask(), ) sorted_list_asc = self.subnet.sort_table_by_column( 'Network address') self.assertEqual( [el.split('/', 1)[0] for el in sorted_list_asc], network_list[::-1] ) sorted_list_desc = self.subnet.sort_table_by_column( 'Network address') self.assertEqual( [el.split('/', 1)[0] for el in sorted_list_desc], network_list )
def test_control_crud_ansible_playbook_action(request, catalog_item, action_collection): """ Polarion: assignee: mmojzis casecomponent: Control initialEstimate: 1/12h """ action = action_collection.create( fauxfactory.gen_alphanumeric(), action_type="Run Ansible Playbook", action_values={ "run_ansible_playbook": { "playbook_catalog_item": catalog_item.name, "inventory": { "target_machine": True } } } ) request.addfinalizer(action.delete_if_exists) with update(action): ipaddr = fauxfactory.gen_ipaddr() new_descr = "edited_{}".format(fauxfactory.gen_alphanumeric()) action.description = new_descr action.run_ansible_playbook = { "inventory": { "specific_hosts": True, "hosts": ipaddr } } view = navigate_to(action, "Edit") assert view.description.value == new_descr assert view.run_ansible_playbook.inventory.hosts.value == ipaddr action.delete()
def test_remove_subnet(self, subnet_name): """@test: Remove subnet by using organization name and subnet name. @feature: Organizations dis-associate subnet. @assert: subnet is added then removed. """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] org_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) with Session(self.browser) as session: make_org(session, org_name=org_name, subnets=[subnet_name]) self.org.search(org_name).click() session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element((strategy1, value1 % subnet_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.org.update(org_name, subnets=[subnet_name]) self.org.search(org_name).click() session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element((strategy, value % subnet_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_remove_subnet(self, subnet_name): """@test: Remove subnet by using location name and subnet name @feature: Locations @assert: subnet is added then removed """ strategy, value = common_locators['entity_select'] strategy1, value1 = common_locators['entity_deselect'] loc_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) with Session(self.browser) as session: set_context(session, org=ANY_CONTEXT['org']) make_loc(session, name=loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy1, value1 % subnet_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.location.update(loc_name, subnets=[subnet_name]) self.location.search(loc_name).click() self.location.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_add_subnet_1(self, subnet_name): """@test: Add a subnet by using location name and subnet name @feature: Locations @assert: subnet is added """ strategy, value = common_locators["entity_deselect"] loc_name = gen_string("alpha", 8) subnet_network = gen_ipaddr(ip3=True) subnet_mask = "255.255.255.0" subnet = entities.Subnet(name=subnet_name, network=subnet_network, mask=subnet_mask).create() self.assertEqual(subnet['name'], subnet_name) with Session(self.browser) as session: make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.wait_until_element( tab_locators["context.tab_subnets"]).click() element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_positive_update_subnet(session): """Add/Remove subnet from/to location :id: fe70ffba-e594-48d5-b2c5-be93e827cc60 :expectedresults: subnet is added and removed from the location :CaseLevel: Integration """ ip_addres = gen_ipaddr(ip3=True) subnet = entities.Subnet( network=ip_addres, mask='255.255.255.0', ).create() loc = entities.Location().create() with session: subnet_name = '{0} ({1}/{2})'.format(subnet.name, subnet.network, subnet.cidr) session.location.update(loc.name, {'subnets.resources.assigned': [subnet_name]}) loc_values = session.location.read(loc.name) assert loc_values['subnets']['resources']['assigned'][0] == subnet_name session.location.update( loc.name, {'subnets.resources.unassigned': [subnet_name]}) loc_values = session.location.read(loc.name) assert len(loc_values['subnets']['resources']['assigned']) == 0 assert subnet_name in loc_values['subnets']['resources']['unassigned']
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_create_with_address_pool(self): """Create subnet with valid address pool :id: d74a52a7-df56-44ef-89a3-081c14e81e43 :expectedresults: Subnet is created and address pool is set :CaseImportance: Critical """ for pool in valid_addr_pools(): with self.subTest(pool): pool.sort() mask = '255.255.255.0' # generate pool range from network address network = gen_ipaddr() from_ip = re.sub(r'\d+$', str(pool[0]), network) to_ip = re.sub(r'\d+$', str(pool[1]), network) subnet = make_subnet({ u'from': from_ip, u'mask': mask, u'network': network, u'to': to_ip, }) self.assertEqual(subnet['from'], from_ip) self.assertEqual(subnet['to'], to_ip)
def test_positive_sort_by_name(self): """Create some Subnet entities and sort them by name :id: 0b07341c-717e-46a9-86cc-7192f3d8d449 :customerscenario: true :expectedresults: Subnet entities are sorted by name :BZ: 1268085 :CaseImportance: Medium """ organization = entities.Organization().create() name_list = [gen_string('alpha', 20) for _ in range(5)] with Session(self) as session: set_context(session, org=organization.name) for name in name_list: make_subnet( session, subnet_name=name, subnet_network=gen_ipaddr(ip3=True), subnet_mask=gen_netmask(), ) self.assertEqual(self.subnet.sort_table_by_column('Name'), sorted(name_list, key=six.text_type.lower)) self.assertEqual( self.subnet.sort_table_by_column('Name'), sorted(name_list, key=six.text_type.lower, reverse=True))
def test_positive_add_subnet(self): """Add a subnet using organization name and subnet name. @feature: Organizations associate subnet. @assert: subnet is added. """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): org_name = gen_string('alpha') # Create subnet using nailgun subnet = entities.Subnet(name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0').create() self.assertEqual(subnet.name, subnet_name) make_org(session, org_name=org_name) self.assertIsNotNone(self.org.search(org_name)) self.org.update(org_name, new_subnets=[subnet_name]) self.org.search(org_name).click() session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_positive_add_subnet(self): """Add a subnet by using location name and subnet name :id: fe70ffba-e594-48d5-b2c5-be93e827cc60 :expectedresults: subnet is added :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
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 test_create_subnet_3(self): """@Test: 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", 4) network = gen_ipaddr(ip3=True) mask = gen_netmask() domain_name = entities.Domain().create()['name'] with Session(self.browser) as session: make_subnet(session, subnet_name=name, subnet_network=network, subnet_mask=mask, domains=[domain_name]) self.assertIsNotNone(self.subnet.search_subnet(subnet_name=name)) session.nav.search_entity( name, locators['subnet.display_name']).click() session.nav.wait_until_element( tab_locators["subnet.tab_domain"]).click() 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: self.assertIsNotNone(element) elif checkbox_element: self.assertTrue(checkbox_element.is_selected()) else: self.assertIsNotNone()
def test_positive_sort_by_name(self): """Create some Subnet entities and sort them by name :id: 0b07341c-717e-46a9-86cc-7192f3d8d449 :expectedresults: Subnet entities are sorted by name :BZ: 1268085 :CaseImportance: Medium """ organization = entities.Organization().create() name_list = [gen_string('alpha', 20) for _ in range(5)] with Session(self) as session: set_context(session, org=organization.name) for name in name_list: make_subnet( session, subnet_name=name, subnet_network=gen_ipaddr(ip3=True), subnet_mask=gen_netmask(), ) self.assertEqual( self.subnet.sort_table_by_column('Name'), sorted(name_list, key=six.text_type.lower) ) self.assertEqual( self.subnet.sort_table_by_column('Name'), sorted(name_list, key=six.text_type.lower, reverse=True) )
def test_positive_add_subnet(self): """Add a subnet by using location name and subnet name @feature: Locations @assert: subnet is added """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search(loc_name).click() session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_remove_subnet_1(self, subnet_name): """@test: Remove subnet by using organization name and subnet name. @feature: Organizations dis-associate subnet. @assert: subnet is added then removed. """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] org_name = gen_string("alpha", 8) subnet_network = gen_ipaddr(ip3=True) subnet_mask = "255.255.255.0" subnet = entities.Subnet(name=subnet_name, network=subnet_network, mask=subnet_mask).create() self.assertEqual(subnet['name'], subnet_name) with Session(self.browser) as session: make_org(session, org_name=org_name, subnets=[subnet_name]) self.org.search(org_name).click() session.nav.wait_until_element( tab_locators["context.tab_subnets"]).click() element = session.nav.wait_until_element( (strategy1, value1 % subnet_name)) # Item is listed in 'Selected Items' list and not 'All Items' list. self.assertIsNotNone(element) self.org.update(org_name, subnets=[subnet_name]) self.org.search(org_name).click() session.nav.wait_until_element( tab_locators["context.tab_subnets"]).click() element = session.nav.wait_until_element( (strategy, value % subnet_name)) # Item is listed in 'All Items' list and not 'Selected Items' list. self.assertIsNotNone(element)
def test_positive_add_subnet(self): """Add a subnet by using location name and subnet name :id: fe70ffba-e594-48d5-b2c5-be93e827cc60 :expectedresults: subnet is added :CaseLevel: Integration """ strategy, value = common_locators['entity_deselect'] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): loc_name = gen_string('alpha') subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask='255.255.255.0', ).create() self.assertEqual(subnet.name, subnet_name) make_loc(session, name=loc_name) self.assertIsNotNone(self.location.search(loc_name)) self.location.update(loc_name, new_subnets=[subnet_name]) self.location.search_and_click(loc_name) session.nav.click(tab_locators['context.tab_subnets']) element = session.nav.wait_until_element( (strategy, value % subnet_name)) self.assertIsNotNone(element)
def test_control_crud_ansible_playbook_action(request, catalog_item, action_collection): action = action_collection.create(fauxfactory.gen_alphanumeric(), action_type="Run Ansible Playbook", action_values={ "run_ansible_playbook": { "playbook_catalog_item": catalog_item.name, "inventory": { "target_machine": True } } }) request.addfinalizer(action.delete_if_exists) with update(action): ipaddr = fauxfactory.gen_ipaddr() new_descr = "edited_{}".format(fauxfactory.gen_alphanumeric()) action.description = new_descr action.run_ansible_playbook = { "inventory": { "specific_hosts": True, "hosts": ipaddr } } view = navigate_to(action, "Edit") assert view.description.value == new_descr assert view.run_ansible_playbook.inventory.hosts.value == ipaddr action.delete()
def test_add_subnet_1(self, subnet_name): """@test: Add a subnet by using organization name and subnet name. @feature: Organizations associate subnet. @assert: subnet is added. """ strategy, value = common_locators["entity_deselect"] org_name = gen_string("alpha", 8) subnet_network = gen_ipaddr(ip3=True) subnet_mask = "255.255.255.0" subnet = entities.Subnet( name=subnet_name, network=subnet_network, mask=subnet_mask ).create() self.assertEqual(subnet['name'], subnet_name) with Session(self.browser) as session: make_org(session, org_name=org_name) self.assertIsNotNone(self.org.search(org_name)) self.org.update(org_name, new_subnets=[subnet_name]) self.org.search(org_name).click() self.org.wait_until_element( tab_locators["context.tab_subnets"]).click() element = session.nav.wait_until_element((strategy, value % subnet_name)) self.assertIsNotNone(element)
def create_discovered_host(name=None, ip_address=None, mac_address=None, options=None): """Creates a discovered host. :param str name: Name of discovered host. :param str ip_address: A valid ip address. :param str mac_address: A valid mac address. :param dict options: additional facts to add to discovered host :return: dict of ``entities.DiscoveredHost`` facts. """ if name is None: name = gen_string('alpha') if ip_address is None: ip_address = gen_ipaddr() if mac_address is None: mac_address = gen_mac(multicast=False) if options is None: options = {} facts = { 'name': name, 'discovery_bootip': ip_address, 'discovery_bootif': mac_address, 'interfaces': 'eth0', 'ipaddress': ip_address, 'ipaddress_eth0': ip_address, 'macaddress': mac_address, 'macaddress_eth0': mac_address, } facts.update(options) return entities.DiscoveredHost().facts(json={'facts': facts})
def test_positive_remove_subnet(self): """Remove subnet by using organization name and subnet name. @feature: Organizations dis-associate subnet. @assert: subnet is added then removed. """ strategy, value = common_locators["entity_select"] strategy1, value1 = common_locators["entity_deselect"] with Session(self.browser) as session: for subnet_name in generate_strings_list(): with self.subTest(subnet_name): org_name = gen_string("alpha") # Create subnet using nailgun subnet = entities.Subnet( name=subnet_name, network=gen_ipaddr(ip3=True), mask="255.255.255.0" ).create() self.assertEqual(subnet.name, subnet_name) make_org(session, org_name=org_name, subnets=[subnet_name]) self.org.search(org_name).click() session.nav.click(tab_locators["context.tab_subnets"]) element = session.nav.wait_until_element((strategy1, value1 % subnet_name)) # Item is listed in 'Selected Items' list and not # 'All Items' list. self.assertIsNotNone(element) self.org.update(org_name, subnets=[subnet_name]) self.org.search(org_name).click() session.nav.click(tab_locators["context.tab_subnets"]) element = session.nav.wait_until_element((strategy, value % subnet_name)) # Item is listed in 'All Items' list and not # 'Selected Items' list. self.assertIsNotNone(element)
def generate_system_facts(name=None): """Generate random system facts for registration. :param str name: A valid FQDN for a system. If one is not provided, then a random value will be generated. :return: A dictionary with random system facts :rtype: dict """ if name is None: name = f'{gen_alpha().lower()}.example.net' # Make a copy of the system facts 'template' new_facts = copy.deepcopy(SYSTEM_FACTS) # Select a random RHEL version... distro = gen_choice(DISTRO_IDS) # ...and update our facts new_facts['distribution.id'] = distro['id'] new_facts['distribution.version'] = distro['version'] new_facts['dmi.bios.relase_date'] = _bios_date().strftime('%m/%d/%Y') new_facts['dmi.memory.maximum_capacity'] = gen_choice(MEMORY_CAPACITY) new_facts['dmi.memory.size'] = gen_choice(MEMORY_SIZE) new_facts['dmi.system.uuid'] = gen_uuid() new_facts['dmi.system.version'] = 'RHEL' new_facts['lscpu.architecture'] = distro['architecture'] new_facts['net.interface.eth1.hwaddr'] = gen_mac(multicast=False) new_facts['net.interface.eth1.ipaddr'] = gen_ipaddr() new_facts['network.hostname'] = name new_facts['network.ipaddr'] = new_facts['net.interface.eth1.ipaddr'] new_facts['uname.machine'] = distro['architecture'] new_facts['uname.nodename'] = name new_facts['uname.release'] = distro['kernel'] new_facts['virt.uuid'] = new_facts['dmi.system.uuid'] return new_facts
def test_positive_create_and_update_with_ip(): """Create and update host with IP address specified :id: 3f266906-c509-42ce-9b20-def448bf8d86 :expectedresults: A host is created and updated with static IP address :CaseImportance: Critical """ ip_addr = gen_ipaddr() host = entities.Host(ip=ip_addr).create() assert host.ip == ip_addr new_ip_addr = gen_ipaddr() host.ip = new_ip_addr host = host.update(['ip']) assert host.ip == new_ip_addr
def test_positive_create_with_address_pool(self): """Create subnet with valid address pool :id: d74a52a7-df56-44ef-89a3-081c14e81e43 :expectedresults: Subnet is created and address pool is set :CaseImportance: Critical """ for pool in valid_addr_pools(): with self.subTest(pool): pool.sort() mask = '255.255.255.0' # generate pool range from network address network = gen_ipaddr() from_ip = re.sub(r'\d+$', str(pool[0]), network) to_ip = re.sub(r'\d+$', str(pool[1]), network) subnet = make_subnet({ u'from': from_ip, u'mask': mask, u'network': network, u'to': to_ip, }) self.assertEqual(subnet['start-of-ip-range'], from_ip) self.assertEqual(subnet['end-of-ip-range'], to_ip)
def _create_discovered_host(name=None, ipaddress=None, macaddress=None): """Creates discovered host by uploading few fake facts. :param str name: Name of discovered host. If ``None`` then a random value will be generated. :param str ipaddress: A valid ip address. If ``None`` then then a random value will be generated. :param str macaddress: A valid mac address. If ``None`` then then a random value will be generated. :return: A ``dict`` of ``DiscoveredHost`` facts. """ if name is None: name = gen_string('alpha') if ipaddress is None: ipaddress = gen_ipaddr() if macaddress is None: macaddress = gen_mac(multicast=False) return entities.DiscoveredHost().facts(json={ u'facts': { u'name': name, u'discovery_bootip': ipaddress, u'discovery_bootif': macaddress, u'interfaces': 'eth0', u'ipaddress': ipaddress, u'macaddress': macaddress, u'macaddress_eth0': macaddress, u'ipaddress_eth0': ipaddress, } })
def test_positive_update_subnet(session): """Add/Remove subnet from/to location :id: fe70ffba-e594-48d5-b2c5-be93e827cc60 :expectedresults: subnet is added and removed from the location :CaseLevel: Integration """ ip_addres = gen_ipaddr(ip3=True) subnet = entities.Subnet( network=ip_addres, mask='255.255.255.0', ).create() loc = entities.Location().create() with session: subnet_name = '{0} ({1}/{2})'.format( subnet.name, subnet.network, subnet.cidr) session.location.update( loc.name, {'subnets.resources.assigned': [subnet_name]}) loc_values = session.location.read(loc.name) assert loc_values['subnets']['resources']['assigned'][0] == subnet_name session.location.update( loc.name, {'subnets.resources.unassigned': [subnet_name]}) loc_values = session.location.read(loc.name) assert len(loc_values['subnets']['resources']['assigned']) == 0 assert subnet_name in loc_values['subnets']['resources']['unassigned']
def setUp(self): requests_intercept.install() add_wsgi_intercept("httpbin.org", 80, self.get_app) logging.getLogger("requests").setLevel("ERROR") self.fake_target = fauxfactory.gen_ipaddr() self.service = HttpService(self.fake_target)
def _create_discovered_host(name=None, ipaddress=None, macaddress=None): """Creates discovered host by uploading few fake facts. :param str name: Name of discovered host. If ``None`` then a random value will be generated. :param str ipaddress: A valid ip address. If ``None`` then then a random value will be generated. :param str macaddress: A valid mac address. If ``None`` then then a random value will be generated. :return: A ``dict`` of ``DiscoveredHost`` facts. """ if name is None: name = gen_string('alpha') if ipaddress is None: ipaddress = gen_ipaddr() if macaddress is None: macaddress = gen_mac(multicast=False) return entities.DiscoveredHost().facts( json={ u'facts': { u'name': name, u'discovery_bootip': ipaddress, u'discovery_bootif': macaddress, u'interfaces': 'eth0', u'ipaddress': ipaddress, u'macaddress': macaddress, u'macaddress_eth0': macaddress, u'ipaddress_eth0': ipaddress, } })
def create_discovered_host(name=None, ip_address=None, mac_address=None, options=None): """Creates a discovered host. :param str name: Name of discovered host. :param str ip_address: A valid ip address. :param str mac_address: A valid mac address. :param dict options: additional facts to add to discovered host :returns dict of ``entities.DiscoveredHost`` facts. """ if name is None: name = gen_string('alpha') if ip_address is None: ip_address = gen_ipaddr() if mac_address is None: mac_address = gen_mac(multicast=False) if options is None: options = {} facts = { 'name': name, 'discovery_bootip': ip_address, 'discovery_bootif': mac_address, 'interfaces': 'eth0', 'ipaddress': ip_address, 'ipaddress_eth0': ip_address, 'macaddress': mac_address, 'macaddress_eth0': mac_address, } facts.update(options) return entities.DiscoveredHost().facts(json={'facts': facts})
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 test_update_subnet_2(self, name): """@Test: Update Subnet network @Feature: Subnet - Positive Update @Assert: Subnet network is updated """ network = gen_ipaddr(ip3=True) mask = gen_netmask() new_network = gen_ipaddr(ip3=True) with Session(self.browser) as session: make_subnet(session, subnet_name=name, subnet_network=network, subnet_mask=mask) self.subnet.update(name, new_subnet_network=new_network) result_object = self.subnet.search_subnet(name) self.assertEqual(new_network, result_object['network'])
def test_ip_max_valid_character_validation(request): """Test to validate max character for ip address field with valid ip address""" prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), hostname=fauxfactory.gen_alphanumeric(5), ip_address=fauxfactory.gen_ipaddr(prefix=[10])) request.addfinalizer(prov.delete_if_exists) prov.create()
def test_positive_update_network_mask(self): """Check if Subnet network and mask can be updated @id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4 @Assert: Subnet network and mask are updated """ network = gen_ipaddr() mask = "255.255.255.0" subnet = make_subnet({u"mask": mask, u"network": network}) new_network = gen_ipaddr() new_mask = "255.255.192.0" Subnet.update({u"id": subnet["id"], u"mask": new_mask, u"network": new_network}) # check - subnet is updated subnet = Subnet.info({u"id": subnet["id"]}) self.assertEqual(subnet["network"], new_network) self.assertEqual(subnet["mask"], new_mask)
def test_ip_max_valid_character_validation(request): """Test to validate max character for ip address field with valid ip address""" prov = OpenStackProvider( name=fauxfactory.gen_alphanumeric(5), hostname=fauxfactory.gen_alphanumeric(5), ip_address=fauxfactory.gen_ipaddr(prefix=[10])) request.addfinalizer(prov.delete_if_exists) prov.create()
def test_api_port_blank_validation(request): """Test to validate blank api port while adding a provider""" prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), hostname=fauxfactory.gen_alphanumeric(5), ip_address=fauxfactory.gen_ipaddr(prefix=[10]), api_port='') request.addfinalizer(prov.delete_if_exists) prov.create()
def test_api_port_max_character_validation(request): """Test to validate max character for api port field""" prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), hostname=fauxfactory.gen_alphanumeric(5), ip_address=fauxfactory.gen_ipaddr(prefix=[10]), api_port=fauxfactory.gen_alphanumeric(15)) request.addfinalizer(prov.delete_if_exists) prov.create()
def test_host_name_required_validation(request): """Test to validate the hostname while adding a provider""" prov = OpenStackProvider(name=fauxfactory.gen_alphanumeric(5), hostname=None, ip_address=fauxfactory.gen_ipaddr(prefix=[10])) request.addfinalizer(prov.delete_if_exists) with error.expected("Host Name can't be blank"): prov.create()
def test_host_name_required_validation(request): """Test to validate the hostname while adding a provider""" prov = OpenStackProvider( name=fauxfactory.gen_alphanumeric(5), hostname=None, ip_address=fauxfactory.gen_ipaddr(prefix=[10]) ) request.addfinalizer(prov.delete_if_exists) with error.expected("Host Name can't be blank"): prov.create()
def test_positive_create_with_ip(self): """Create a host with IP address specified @id: 3f266906-c509-42ce-9b20-def448bf8d86 @assert: A host is created with expected IP address """ ip_addr = gen_ipaddr() host = entities.Host(ip=ip_addr).create() self.assertEqual(host.ip, ip_addr)
def test_gen_ipv6_2(self): """ @Test: Generate a IPv6 address @Feature: IPAddr Generator @Assert: A IPv6 address is generated """ result = gen_ipaddr(ip3=True, ipv6=True) self.assertTrue( len(result.split(":")) == 8, "Did not generate a IPv6 addrss")