def test_lab_controller_add(self): b = self.browser lc_name = data_setup.unique_name('lc%s.com') lc_email = data_setup.unique_name('me@my%s.com') self._add_lc(b, lc_name, lc_email, data_setup.ADMIN_USER) self.assert_('%s saved' % lc_name in b.find_element_by_css_selector('.flash').text) # Search in activity b.get(get_server_base() + 'activity/labcontroller') b.find_element_by_id('advancedsearch').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/" "option[@value='LabController/Name']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/" "option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']"). \ send_keys(lc_name) b.find_element_by_xpath("//input[@name='Search']").click() self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='FQDN', action='Changed', new_value=lc_name)) self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='User', action='Changed', new_value=data_setup.ADMIN_USER)) self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='Disabled', action='Changed', new_value='False'))
def test_can_search_by_distro_tree_specifics(self): b = self.browser b.get(get_server_base() + 'activity/distrotree') b.find_element_by_link_text('Show Search Options').click() # Make sure only distrotree1 is returned b.find_element_by_xpath("//select[@id='activitysearch_0_table']/option[@value='DistroTree/Arch']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']").send_keys(self.distro_tree1.arch.arch) b.find_element_by_link_text('Add').click() b.find_element_by_xpath("//select[@id='activitysearch_1_table']/option[@value='DistroTree/Variant']").click() b.find_element_by_xpath("//select[@id='activitysearch_1_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_1_value']").send_keys(self.distro_tree1.variant) b.find_element_by_link_text('Add').click() b.find_element_by_xpath("//select[@id='activitysearch_2_table']/option[@value='DistroTree/Distro Name']").click() b.find_element_by_xpath("//select[@id='activitysearch_2_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_2_value']").send_keys(self.distro_tree1.distro.name) b.find_element_by_id('searchform').submit() self.assert_(is_activity_row_present(b, object_='DistroTree: %s' % self.distro_tree1)) self.assert_(not is_activity_row_present(b, object_='DistroTree: %s' % self.distro_tree2))
def test_lab_controller_add(self): b = self.browser lc_name = data_setup.unique_name('lc%s.com') lc_email = data_setup.unique_name('me@my%s.com') self._add_lc(lc_name, lc_email) self.assert_('%s saved' % lc_name in b.find_element_by_css_selector('.flash').text) # Search in activity b.get(get_server_base() + 'activity/labcontroller') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/" "option[@value='LabController/Name']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/" "option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']"). \ send_keys(lc_name) b.find_element_by_id('searchform').submit() self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='FQDN', action='Changed', new_value=lc_name)) self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='User', action='Changed', new_value='host/' + lc_name)) self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='Disabled', action='Changed', new_value='False'))
def test_group_removal_is_noticed(self): self.group.systems.append(self.system) session.flush() b = self.browser login(b) b.get(get_server_base() + 'groups/') b.find_element_by_xpath("//input[@name='group.text']").clear() b.find_element_by_xpath("//input[@name='group.text']").send_keys(self.group.group_name) b.find_element_by_id('Search').submit() delete_and_confirm(b, "//tr[td/a[normalize-space(text())='%s']]" % self.group.group_name, 'Remove') should_have_deleted_msg = b.find_element_by_xpath('//body').text self.assert_('%s deleted' % self.group.display_name in should_have_deleted_msg) # Check it's recorded in System Activity b.get(get_server_base() + 'activity/system') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/option[@value='Action']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']").send_keys('Removed') b.find_element_by_link_text('Add').click() b.find_element_by_xpath("//select[@id='activitysearch_1_table']/option[@value='Old Value']").click() b.find_element_by_xpath("//select[@id='activitysearch_1_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_1_value']").send_keys(self.group.display_name) b.find_element_by_id('searchform').submit() self.assert_(is_activity_row_present(b,via='WEBUI', action='Removed', old_value=self.group.display_name, new_value='', object_='System: %s' % self.system.fqdn))
def test_can_search_by_distro_tree_specifics(self): b = self.browser b.get(get_server_base() + 'activity/distrotree') b.find_element_by_link_text('Show Search Options').click() # Make sure only distrotree1 is returned b.find_element_by_xpath( "//select[@id='activitysearch_0_table']/option[@value='DistroTree/Arch']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_0_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_0_value']").send_keys( self.distro_tree1.arch.arch) b.find_element_by_link_text('Add').click() b.find_element_by_xpath( "//select[@id='activitysearch_1_table']/option[@value='DistroTree/Variant']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_1_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_1_value']").send_keys( self.distro_tree1.variant) b.find_element_by_link_text('Add').click() b.find_element_by_xpath( "//select[@id='activitysearch_2_table']/option[@value='DistroTree/Distro Name']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_2_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_2_value']").send_keys( self.distro_tree1.distro.name) b.find_element_by_id('searchform').submit() self.assert_( is_activity_row_present(b, object_='DistroTree: %s' % self.distro_tree1)) self.assert_(not is_activity_row_present( b, object_='DistroTree: %s' % self.distro_tree2))
def test_lab_controller_remove(self): b = self.browser lc_name = data_setup.unique_name('lc%s.com') lc_email = data_setup.unique_name('me@my%s.com') self._add_lc(b, lc_name, lc_email, data_setup.ADMIN_USER) with session.begin(): sys = data_setup.create_system() sys.lab_controller = LabController.by_name(lc_name) b.get(get_server_base() + 'labcontrollers') b.find_element_by_xpath("//table[@id='widget']/tbody/tr/" "td[preceding-sibling::td/a[normalize-space(text())='%s']]" "/a[normalize-space(text())='Remove (-)']" % lc_name).click() self.assert_('%s removed' % lc_name in b.find_element_by_css_selector('.flash').text) # Search in LC activity b.get(get_server_base() + 'activity/labcontroller') b.find_element_by_id('advancedsearch').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/" "option[@value='LabController/Name']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/" "option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']"). \ send_keys(lc_name) b.find_element_by_xpath("//input[@name='Search']").click() self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='Disabled', action='Changed', new_value='True')) self.assert_(is_activity_row_present(b, object_='LabController: %s' % lc_name, via='WEBUI', property_='Removed', action='Changed', new_value='True')) # Ensure System Actvity has been updated to note removal of LC b.get(get_server_base() + 'activity/system') b.find_element_by_id('advancedsearch').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/" "option[@value='System/Name']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/" "option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']"). \ send_keys(sys.fqdn) b.find_element_by_xpath("//input[@name='Search']").click() self.assert_(is_activity_row_present(b, object_='System: %s' % sys.fqdn, via='WEBUI', property_='lab_controller', action='Changed', new_value=''))
def test_can_search_custom_service(self): with session.begin(): self.distro_tree1.activity.append( DistroTreeActivity(user=User.by_user_name( data_setup.ADMIN_USER), service=u'TESTSERVICE', field_name=u'Nonesente', old_value=u'sdfas', new_value=u'sdfa', action='Removed')) self.distro_tree2.activity.append( DistroTreeActivity(user=User.by_user_name( data_setup.ADMIN_USER), service=u'TESTSERVICE2', field_name=u'Noneseonce', old_value=u'bsdf', new_value=u'sdfas', action='Removed')) b = self.browser b.get(get_server_base() + 'activity/distrotree') b.find_element_by_link_text('Show Search Options').click() # Make sure only distrotree1 is returned b.find_element_by_xpath( "//select[@id='activitysearch_0_table']/option[@value='Via']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_0_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_0_value']").send_keys('TESTSERVICE') b.find_element_by_id('searchform').submit() self.assertTrue( is_activity_row_present(b, via='TESTSERVICE', action='Removed', object_='DistroTree: %s' % self.distro_tree1)) self.assertFalse( is_activity_row_present(b, via='TESTSERVICE2', action='Removed', object_='DistroTree: %s' % self.distro_tree2))
def test_can_search_by_group_name(self): b = self.browser b.get(get_server_base() + 'activity/group') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/option[@value='Group/Name']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']").send_keys(self.group.display_name) b.find_element_by_id('searchform').submit() self.assert_(is_activity_row_present(b, object_='Group: %s' % self.group.display_name))
def test_can_search_by_distro_name(self): b = self.browser b.get(get_server_base() + 'activity/distro') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath('//select[@id="activitysearch_0_table"]/option[@value="Distro/Name"]').click() b.find_element_by_xpath('//select[@id="activitysearch_0_operation"]/option[@value="is"]').click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']").send_keys(self.distro.name) b.find_element_by_id('searchform').submit() self.assert_(is_activity_row_present(b, object_='Distro: %s' % self.distro.name))
def test_can_search_by_system_name(self): b = self.browser b.get(get_server_base() + 'activity/system') b.find_element_by_link_text('Toggle Search').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/option[@value='System/Name']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']").send_keys(self.system.fqdn) b.find_element_by_xpath("//input[@name='Search']").click() self.assert_(is_activity_row_present(b, object_='System: %s' % self.system.fqdn))
def test_can_search_custom_service(self): with session.begin(): self.distro_tree1.activity.append(DistroTreeActivity( user=User.by_user_name(data_setup.ADMIN_USER), service=u'TESTSERVICE', field_name=u'Nonesente', old_value=u'sdfas', new_value=u'sdfa', action='Removed')) self.distro_tree2.activity.append(DistroTreeActivity( user=User.by_user_name(data_setup.ADMIN_USER), service=u'TESTSERVICE2', field_name=u'Noneseonce', old_value=u'bsdf', new_value=u'sdfas', action='Removed')) b = self.browser b.get(get_server_base() + 'activity/distrotree') b.find_element_by_link_text('Show Search Options').click() # Make sure only distrotree1 is returned b.find_element_by_xpath("//select[@id='activitysearch_0_table']/option[@value='Via']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']").send_keys('TESTSERVICE') b.find_element_by_id('searchform').submit() self.assertTrue(is_activity_row_present(b, via='TESTSERVICE', action='Removed', object_='DistroTree: %s' % self.distro_tree1)) self.assertFalse(is_activity_row_present(b, via='TESTSERVICE2', action='Removed', object_='DistroTree: %s' % self.distro_tree2))
def test_group_removal_is_noticed(self): self.group.systems.append(self.system) session.flush() b = self.browser login(b) b.get(get_server_base() + 'groups/') b.find_element_by_xpath("//input[@name='group.text']").clear() b.find_element_by_xpath("//input[@name='group.text']").send_keys( self.group.group_name) b.find_element_by_id('Search').submit() delete_and_confirm( b, "//tr[td/a[normalize-space(text())='%s']]" % self.group.group_name, 'Delete Group') should_have_deleted_msg = b.find_element_by_xpath('//body').text self.assert_('%s deleted' % self.group.display_name in should_have_deleted_msg) # Check it's recorded in System Activity b.get(get_server_base() + 'activity/system') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath( "//select[@id='activitysearch_0_table']/option[@value='Action']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_0_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_0_value']").send_keys('Removed') b.find_element_by_link_text('Add').click() b.find_element_by_xpath( "//select[@id='activitysearch_1_table']/option[@value='Old Value']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_1_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_1_value']").send_keys( self.group.display_name) b.find_element_by_id('searchform').submit() self.assert_( is_activity_row_present(b, via='WEBUI', action='Removed', old_value=self.group.display_name, new_value='', object_='System: %s' % self.system.fqdn))
def test_can_search_by_distro_name(self): b = self.browser b.get(get_server_base() + 'activity/distro') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath( '//select[@id="activitysearch_0_table"]/option[@value="Distro/Name"]' ).click() b.find_element_by_xpath( '//select[@id="activitysearch_0_operation"]/option[@value="is"]' ).click() b.find_element_by_xpath( "//input[@id='activitysearch_0_value']").send_keys( self.distro.name) b.find_element_by_id('searchform').submit() self.assert_( is_activity_row_present(b, object_='Distro: %s' % self.distro.name))
def test_can_search_by_system_name(self): b = self.browser b.get(get_server_base() + 'activity/system') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath( "//select[@id='activitysearch_0_table']/option[@value='System/Name']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_0_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_0_value']").send_keys( self.system.fqdn) b.find_element_by_id('searchform').submit() self.assert_( is_activity_row_present(b, object_='System: %s' % self.system.fqdn))
def test_group_has_access_policy_rule_remove(self): with session.begin(): user = data_setup.create_user(password='******') system = data_setup.create_system(owner=user, shared=False) system.custom_access_policy = SystemAccessPolicy() group = data_setup.create_group(owner=user) p = system.custom_access_policy p.add_rule(permission=SystemPermission.edit_system, group=group) p.add_rule(permission=SystemPermission.edit_policy, group=group) b = self.browser login(b, user=user.user_name, password='******') # check current rules self.assertEquals(len(p.rules), 2) self.assert_(p.rules[0].user is None) self.assertEquals(p.rules[0].group, group) self.assert_(p.rules[1].user is None) self.assertEquals(p.rules[1].group, group) # save current rules for later use access_policy_rule_1 = repr(p.rules[0]) access_policy_rule_2 = repr(p.rules[1]) # delete the group b.get(get_server_base() + 'groups/mine') delete_and_confirm(b, "//tr[td/a[normalize-space(text())='%s']]" % group.group_name, delete_text='Delete Group') self.assertEqual( b.find_element_by_class_name('flash').text, '%s deleted' % group.display_name) # check if the access policy rule has been removed session.refresh(p) self.assertEquals(len(p.rules), 0) # Check whether the rules deleted have been recorded in the # Activity table b.get(get_server_base() + 'activity/') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath("//select[@id='activitysearch_0_table']/option[@value='Action']").click() b.find_element_by_xpath("//select[@id='activitysearch_0_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_0_value']").send_keys('Removed') b.find_element_by_link_text('Add').click() b.find_element_by_xpath("//select[@id='activitysearch_1_table']/option[@value='Property']").click() b.find_element_by_xpath("//select[@id='activitysearch_1_operation']/option[@value='is']").click() b.find_element_by_xpath("//input[@id='activitysearch_1_value']").send_keys('Access Policy Rule') b.find_element_by_id('searchform').submit() self.assert_(is_activity_row_present(b,via='WEBUI', action='Removed', object_ = 'System: %s' % system.fqdn, property_='Access Policy Rule', old_value=access_policy_rule_1, new_value='')) self.assert_(is_activity_row_present(b,via='WEBUI', action='Removed', object_ = 'System: %s' % system.fqdn, property_='Access Policy Rule', old_value=access_policy_rule_2, new_value=''))
def test_group_has_access_policy_rule_remove(self): with session.begin(): user = data_setup.create_user(password='******') system = data_setup.create_system(owner=user, shared=False) system.custom_access_policy = SystemAccessPolicy() group = data_setup.create_group(owner=user) p = system.custom_access_policy p.add_rule(permission=SystemPermission.edit_system, group=group) p.add_rule(permission=SystemPermission.edit_policy, group=group) b = self.browser login(b, user=user.user_name, password='******') # check current rules self.assertEquals(len(p.rules), 2) self.assert_(p.rules[0].user is None) self.assertEquals(p.rules[0].group, group) self.assert_(p.rules[1].user is None) self.assertEquals(p.rules[1].group, group) # save current rules for later use access_policy_rule_1 = repr(p.rules[0]) access_policy_rule_2 = repr(p.rules[1]) # delete the group b.get(get_server_base() + 'groups/mine') delete_and_confirm(b, "//tr[td/a[normalize-space(text())='%s']]" % group.group_name, delete_text='Delete Group') self.assertEqual( b.find_element_by_class_name('flash').text, '%s deleted' % group.display_name) # check if the access policy rule has been removed session.refresh(p) self.assertEquals(len(p.rules), 0) # Check whether the rules deleted have been recorded in the # Activity table b.get(get_server_base() + 'activity/') b.find_element_by_link_text('Show Search Options').click() b.find_element_by_xpath( "//select[@id='activitysearch_0_table']/option[@value='Action']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_0_operation']/option[@value='is']" ).click() b.find_element_by_xpath( "//input[@id='activitysearch_0_value']").send_keys('Removed') b.find_element_by_link_text('Add').click() b.find_element_by_xpath( "//select[@id='activitysearch_1_table']/option[@value='Property']" ).click() b.find_element_by_xpath( "//select[@id='activitysearch_1_operation']/option[@value='is']" ).click() b.find_element_by_xpath("//input[@id='activitysearch_1_value']" ).send_keys('Access Policy Rule') b.find_element_by_id('searchform').submit() self.assert_( is_activity_row_present(b, via='WEBUI', action='Removed', object_='System: %s' % system.fqdn, property_='Access Policy Rule', old_value=access_policy_rule_1, new_value='')) self.assert_( is_activity_row_present(b, via='WEBUI', action='Removed', object_='System: %s' % system.fqdn, property_='Access Policy Rule', old_value=access_policy_rule_2, new_value=''))