Ejemplo n.º 1
0
    def test_group_remove_on_different_pages(self):
        b1 = self.browser
        b2 = self.get_browser()
        login(b1)
        login(b2)
        b1.get(get_server_base() + 'groups/')
        b1.find_element_by_xpath("//input[@name='group.text']").clear()
        b1.find_element_by_xpath("//input[@name='group.text']").send_keys(
            self.group.group_name)
        b1.find_element_by_id('Search').submit()

        b2.get(get_server_base() + 'groups/')
        b2.find_element_by_xpath("//input[@name='group.text']").clear()
        b2.find_element_by_xpath("//input[@name='group.text']").send_keys(
            self.group.group_name)
        b2.find_element_by_id('Search').submit()

        delete_and_confirm(b1,
                           "//tr[td/a[normalize-space(text())='%s']]" %
                           self.group.group_name,
                           delete_text='Delete Group')
        self.assertEqual(
            b1.find_element_by_class_name('flash').text,
            '%s deleted' % self.group.display_name)

        delete_and_confirm(b2,
                           "//tr[td/a[normalize-space(text())='%s']]" %
                           self.group.group_name,
                           delete_text='Delete Group')
        self.assertEqual(
            b2.find_element_by_class_name('flash').text,
            'Invalid group or already removed')
Ejemplo n.º 2
0
 def test_delete_install_options(self):
     with session.begin():
         self.system.provisions[self.distro_tree.arch] = Provision(
                 arch=self.distro_tree.arch, ks_meta=u'some_ks_meta_var=1',
                 kernel_options=u'some_kernel_option=1',
                 kernel_options_post=u'some_kernel_option=2')
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Install Options')
     delete_and_confirm(b, '//tr[th/text()="Architecture"]')
     b.find_element_by_xpath('//h1[text()="%s"]' % self.system.fqdn)
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
         self.assert_(self.distro_tree.arch not in self.system.provisions)
         self.assertEquals(self.system.activity[0].action, u'Removed')
         self.assertEquals(self.system.activity[0].field_name,
                 u'InstallOption:kernel_options_post:i386')
         self.assertEquals(self.system.activity[1].action, u'Removed')
         self.assertEquals(self.system.activity[1].field_name,
                 u'InstallOption:kernel_options:i386')
         self.assertEquals(self.system.activity[2].action, u'Removed')
         self.assertEquals(self.system.activity[2].field_name,
                 u'InstallOption:ks_meta:i386')
Ejemplo n.º 3
0
    def test_add_and_remove_permission(self):
        b = self.browser
        login(b)

        b.get(get_server_base() + 'groups/edit?group_id=%d' % self.group.group_id)
        b.find_element_by_id('Permissions_permissions_text').send_keys(self.perm1.permission_name)
        b.find_element_by_id('Permissions').submit()
        #Test that permission dynamically updated
        b.find_element_by_xpath('//table[@id="group_permission_grid"]//td[text()="%s"]'
                % self.perm1.permission_name)

        #Test that the permission was persisted by reopening the current page
        b.get(get_server_base() + 'groups/edit?group_id=%d' % self.group.group_id)
        b.find_element_by_xpath('//table[@id="group_permission_grid"]//td[text()="%s"]'
                % self.perm1.permission_name)

        #Let's try and remove it
        delete_and_confirm(b, '//td[preceding-sibling::td/text()="%s"]'
                % self.perm1.permission_name, 'Remove')
        #Check it has been removed from the table
        b.find_element_by_xpath('//table[@id="group_permission_grid" and '
                'not(.//td/text()="%s")]' % self.perm1.permission_name)

        #Reload to make sure it has been removed from the DB
        b.get(get_server_base() + 'groups/edit?group_id=%d' % self.group.group_id)
        b.find_element_by_xpath('//table[@id="group_permission_grid" and '
                'not(.//td/text()="%s")]' % self.perm1.permission_name)
Ejemplo n.º 4
0
 def test_delete_install_options(self):
     with session.begin():
         self.system.provisions[self.distro_tree.arch] = Provision(
             arch=self.distro_tree.arch,
             ks_meta=u'some_ks_meta_var=1',
             kernel_options=u'some_kernel_option=1',
             kernel_options_post=u'some_kernel_option=2')
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Install Options')
     delete_and_confirm(b, '//tr[th/text()="Architecture"]')
     b.find_element_by_xpath('//h1[text()="%s"]' % self.system.fqdn)
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
         self.assert_(self.distro_tree.arch not in self.system.provisions)
         self.assertEquals(self.system.activity[0].action, u'Removed')
         self.assertEquals(self.system.activity[0].field_name,
                           u'InstallOption:kernel_options_post:i386')
         self.assertEquals(self.system.activity[1].action, u'Removed')
         self.assertEquals(self.system.activity[1].field_name,
                           u'InstallOption:kernel_options:i386')
         self.assertEquals(self.system.activity[2].action, u'Removed')
         self.assertEquals(self.system.activity[2].field_name,
                           u'InstallOption:ks_meta:i386')
Ejemplo n.º 5
0
    def test_deleted_job_results_not_shown(self):
        with session.begin():
            data_setup.create_completed_job(
                    whiteboard=self.job_whiteboard, result=TaskResult.fail,
                    recipe_whiteboard=self.recipe_whiteboard)
            data_setup.create_completed_job(
                    whiteboard=self.job_whiteboard, result=TaskResult.warn,
                    recipe_whiteboard=self.recipe_whiteboard)
            owner = data_setup.create_user(password='******')
            self.passed_job.owner = owner
        b = self.browser
        login(b, user=owner.user_name, password='******')
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath("//select[@name='whiteboard']/option[@value='%s']" % self.job_whiteboard).click()
        b.find_element_by_xpath('//input[@value="Generate"]').click()
        report_text = b.find_element_by_xpath("//div[@id='matrix-report']").text
        self.assert_('Pass: 1' in report_text)

        # Delete Job
        b.get(get_server_base() + 'jobs/%s' % self.passed_job.id)
        delete_and_confirm(b, "//form[@action='delete_job_page']")

        # Assert it is no longer there
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath("//select[@name='whiteboard']/option[@value='%s']" % self.job_whiteboard).click()
        b.find_element_by_xpath('//input[@value="Generate"]').click()
        report_text = b.find_element_by_xpath("//div[@id='matrix-report']").text
        self.assert_('Pass: 1' not in report_text)
Ejemplo n.º 6
0
    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))
Ejemplo n.º 7
0
 def test_group_remove_should_not_remove_system_pool(self):
     with session.begin():
         user = data_setup.create_user(password='******')
         group = data_setup.create_group(owner=user)
         pool = data_setup.create_system_pool(owning_group=group)
     b = self.browser
     login(b, user=user.user_name, password='******')
     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(group.group_name)
     b.find_element_by_id('Search').submit()
     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)
     with session.begin():
         session.refresh(pool)
         self.assertFalse(pool.owning_group)
         self.assertEquals(pool.owning_user, user)
         self.assertEquals(pool.activity[-1].action, u'Changed')
         self.assertEquals(pool.activity[-1].field_name, u'Owner')
         self.assertEquals(pool.activity[-1].old_value, 'Group %s' % group.group_name)
         self.assertEquals(pool.activity[-1].new_value, user.user_name)
         self.assertEquals(pool.activity[-1].service, u'WEBUI')
Ejemplo n.º 8
0
 def job_delete_jobpage(self, job):
     b = self.browser
     b.get(get_server_base() + 'jobs/%d' % \
         job.id)
     delete_and_confirm(b, "//form[@action='delete_job_page']")
     self.assertTrue(is_text_present(b, "Succesfully deleted J:%s" %
         job.id))
Ejemplo n.º 9
0
 def job_delete_jobpage(self, job):
     b = self.browser
     b.get(get_server_base() + 'jobs/%d' % \
         job.id)
     delete_and_confirm(b, "//form[@action='delete_job_page']")
     self.assertTrue(is_text_present(b,
                                     "Succesfully deleted J:%s" % job.id))
Ejemplo n.º 10
0
    def test_labcontroller(self):
        # Add
        with session.begin():
            lc = data_setup.create_labcontroller()
            distro_tree = data_setup.create_distro_tree()
        b = self.browser
        login(b)
        go_to_distro_tree_view(b, distro_tree)
        b.find_element_by_xpath("//select[@id='lab_controller_id']/"
                                "option[normalize-space(text())='%s']" %
                                lc.fqdn).click()
        b.find_element_by_xpath("//input[@id='url']"). \
            send_keys('http://blah.com')
        b.find_element_by_name('lab_controller_add_form').submit()
        # A trailing '/' is added automatically if it's not present. RHBZ#912242
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            'Added %s http://blah.com/' % lc.fqdn)

        # Delete
        delete_and_confirm(
            b, "//td[preceding-sibling::td/a[@href='http://blah.com/']]/form")
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            'Deleted %s http://blah.com/' % lc.fqdn)
Ejemplo n.º 11
0
    def test_group_remove_on_different_pages(self):
        b1 = self.browser
        b2 = self.get_browser()
        login(b1)
        login(b2)
        b1.get(get_server_base() + 'groups/')
        b1.find_element_by_xpath("//input[@name='group.text']").clear()
        b1.find_element_by_xpath("//input[@name='group.text']").send_keys(self.group.group_name)
        b1.find_element_by_id('Search').submit()

        b2.get(get_server_base() + 'groups/')
        b2.find_element_by_xpath("//input[@name='group.text']").clear()
        b2.find_element_by_xpath("//input[@name='group.text']").send_keys(self.group.group_name)
        b2.find_element_by_id('Search').submit()

        delete_and_confirm(b1, "//tr[td/a[normalize-space(text())='%s']]" %
            self.group.group_name, delete_text='Delete Group')
        self.assertEqual(
            b1.find_element_by_class_name('flash').text,
            '%s deleted' % self.group.display_name)

        delete_and_confirm(b2, "//tr[td/a[normalize-space(text())='%s']]" %
            self.group.group_name, delete_text='Delete Group')
        self.assertEqual(
            b2.find_element_by_class_name('flash').text,
            'Invalid group or already removed')
Ejemplo n.º 12
0
 def delete_note(self, note):
     b = self.browser
     b.find_element_by_link_text('Notes').click()
     delete_and_confirm(b, '//tr[td/p/text()="%s"]' % note)
     # Test that it is hidden
     wait_for_condition(lambda: not b.find_element_by_xpath(
             '//tr[td/p/text()="%s"]' % note).is_displayed())
Ejemplo n.º 13
0
 def delete_group_from_system(self, b, system=None, group=None):
     if not system:
         system = self.system
     if not group:
         group = self.group
     b.get(get_server_base() + 'view/%s' % system.fqdn)
     b.find_element_by_link_text('Groups').click()
     delete_and_confirm(b, '//table[@id="systemgroups"]')
     self.assert_(is_text_present(b, '%s Removed' % group.display_name))
Ejemplo n.º 14
0
 def delete_group_from_system(self, b, system=None, group=None):
     if not system:
         system = self.system
     if not group:
         group = self.group
     b.get(get_server_base() + "view/%s" % system.fqdn)
     b.find_element_by_link_text("Groups").click()
     delete_and_confirm(b, '//table[@id="systemgroups"]')
     self.assert_(is_text_present(b, "%s Removed" % group.display_name))
Ejemplo n.º 15
0
 def test_add_then_immediately_remove_permission(self):
     b = self.browser
     login(b)
     b.get(get_server_base() + 'groups/edit?group_id=%d' % self.group.group_id)
     b.find_element_by_id('Permissions_permissions_text').send_keys(self.perm1.permission_name)
     b.find_element_by_id('Permissions').submit()
     delete_and_confirm(b, '//td[preceding-sibling::td/text()="%s"]'
             % self.perm1.permission_name, 'Remove')
     b.find_element_by_xpath('//table[@id="group_permission_grid" and '
             'not(.//td/text()="%s")]' % self.perm1.permission_name)
Ejemplo n.º 16
0
 def test_can_delete(self):
     b = self.browser
     login(b)
     self._insert(b, 'ToDelete', 'http://unique1', 'UniqueDescription1')
     delete_and_confirm(b, "//div[@class='external-report']"
             "/form[preceding-sibling::h3/a[text()='ToDelete']]")
     page_text = b.find_element_by_xpath('//body').text
     # This should cover determining if the report is really gone
     self.assertTrue('UniqueDescription1' not in page_text)
     b.find_element_by_xpath('//h2[text()="External Reports"]')
     self.assertEquals(b.find_element_by_class_name('flash').text, 'Deleted report ToDelete')
Ejemplo n.º 17
0
 def test_group_remove(self):
     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_text='Delete Group')
     self.assertEqual(
         b.find_element_by_class_name('flash').text,
         '%s deleted' % self.group.display_name)
Ejemplo n.º 18
0
 def test_group_remove(self):
     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_xpath("//input[@value='Search']").submit()
     delete_and_confirm(
         b,
         "//td[preceding-sibling::td/a[normalize-space(text())='%s']]/form" % self.group.group_name,
         delete_text="Remove (-)",
     )
     self.assertEqual(b.find_element_by_xpath('//div[@class="flash"]').text, "%s deleted" % self.group.display_name)
Ejemplo n.º 19
0
 def test_add_then_immediately_remove_permission(self):
     b = self.browser
     login(b)
     b.get(get_server_base() +
           'groups/edit?group_id=%d' % self.group.group_id)
     b.find_element_by_id('Permissions_permissions_text').send_keys(
         self.perm1.permission_name)
     b.find_element_by_id('Permissions').submit()
     delete_and_confirm(
         b, '//td[preceding-sibling::td/text()="%s"]' %
         self.perm1.permission_name, 'Remove')
     b.find_element_by_xpath('//table[@id="group_permission_grid" and '
                             'not(.//td/text()="%s")]' %
                             self.perm1.permission_name)
Ejemplo n.º 20
0
    def test_group_has_submitted_job_remove(self):
        with session.begin():
            user = data_setup.create_user(password='******')
            group = data_setup.create_group(owner=user)
            job = data_setup.create_job(owner=user, group=group)

        b = self.browser
        login(b, user=user.user_name, password='******')
        b.get(get_server_base() + 'groups/mine')
        delete_and_confirm(b, "//td[preceding-sibling::td/a[normalize-space(text())='%s']]/form" % \
                               group.group_name, delete_text='Delete Group')

        flash_text = b.find_element_by_class_name('flash').text
        self.assert_('Cannot delete a group which has associated jobs' in flash_text, flash_text)
Ejemplo n.º 21
0
    def test_group_has_submitted_job_remove(self):
        with session.begin():
            user = data_setup.create_user(password='******')
            group = data_setup.create_group(owner=user)
            job = data_setup.create_job(owner=user, group=group)

        b = self.browser
        login(b, user=user.user_name, password='******')
        b.get(get_server_base() + 'groups/mine')
        delete_and_confirm(b, "//td[preceding-sibling::td/a[normalize-space(text())='%s']]/form" % \
                               group.group_name, delete_text='Delete Group')

        flash_text = b.find_element_by_class_name('flash').text
        self.assert_('Cannot delete a group which has associated jobs' in flash_text, flash_text)
Ejemplo n.º 22
0
 def test_can_delete(self):
     b = self.browser
     login(b)
     self._insert(b, 'ToDelete', 'http://unique1', 'UniqueDescription1')
     delete_and_confirm(
         b, "//div[@class='external-report']"
         "/form[preceding-sibling::h3/a[text()='ToDelete']]")
     page_text = b.find_element_by_xpath('//body').text
     # This should cover determining if the report is really gone
     self.assertTrue('UniqueDescription1' not in page_text)
     b.find_element_by_xpath('//h2[text()="External Reports"]')
     self.assertEquals(
         b.find_element_by_class_name('flash').text,
         'Deleted report ToDelete')
Ejemplo n.º 23
0
 def test_remove_system(self):
     with session.begin():
         system = data_setup.create_system()
         self.group.systems.append(system)
     b = self.browser
     login(b)
     b.get(get_server_base() + 'groups/edit?group_id=%s' % self.group.group_id)
     delete_and_confirm(b, '//td[preceding-sibling::td[.//text()="%s"]]' % system.fqdn,
             'Remove (-)')
     self.assertEquals(b.find_element_by_class_name('flash').text,
             '%s Removed' % system.fqdn)
     with session.begin():
         session.expire_all()
         self.assert_(system not in self.group.systems)
Ejemplo n.º 24
0
    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)

        with session.begin():
            session.expire_all()
            # check if the access policy rule has been removed
            self.assertEquals(len(p.rules), 0)

            # Check whether the rules deleted have been recorded in the
            # Activity table
            self.assertEquals(system.activity[0].field_name, u'Access Policy Rule')
            self.assertEquals(system.activity[0].action, u'Removed')
            self.assertEquals(system.activity[0].old_value, access_policy_rule_2)
            self.assertEquals(system.activity[1].field_name, u'Access Policy Rule')
            self.assertEquals(system.activity[1].action, u'Removed')
            self.assertEquals(system.activity[1].old_value, access_policy_rule_1)
Ejemplo n.º 25
0
 def test_group_remove(self):
     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_text='Delete Group')
     self.assertEqual(
         b.find_element_by_class_name('flash').text,
         '%s deleted' % self.group.display_name)
Ejemplo n.º 26
0
    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))
Ejemplo n.º 27
0
    def test_labcontroller(self):
        def select_labcontroller_and_submit(lab_controller_fqdn, url):
            self.browser.find_element_by_xpath(
                "//select[@id='lab_controller_id']/"
                "option[normalize-space(text())='%s']" %
                lab_controller_fqdn).click()
            self.browser.find_element_by_xpath("//input[@id='url']"). \
                send_keys(url)
            self.browser.find_element_by_name(
                'lab_controller_add_form').submit()

        # Add
        with session.begin():
            lc = data_setup.create_labcontroller()
            distro_tree = data_setup.create_distro_tree()
        b = self.browser
        login(b)
        go_to_distro_tree_view(b, distro_tree)
        select_labcontroller_and_submit(lab_controller_fqdn=lc.fqdn,
                                        url='http://blah.com/')
        # A trailing '/' is added automatically if it's not present. RHBZ#912242
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            'Changed/Added %s http://blah.com/' % lc.fqdn)
        b.find_element_by_xpath(
            "//td[preceding-sibling::td/a[@href='http://blah.com/']]/form")

        # Test same schema replace
        select_labcontroller_and_submit(lab_controller_fqdn=lc.fqdn,
                                        url='http://domain.com/')
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            'Changed/Added %s http://domain.com/' % lc.fqdn)
        b.find_element_by_xpath(
            "//td[preceding-sibling::td/a[@href='http://domain.com/']]/form")
        # verify that http://blah.com got replaced and is no longer present
        self.assertFalse(
            b.find_elements_by_xpath(
                "//td[preceding-sibling::td/a[@href='http://blah.com/']]/form")
        )

        # Delete
        delete_and_confirm(
            b,
            "//td[preceding-sibling::td/a[@href='http://domain.com/']]/form")
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            'Deleted %s http://domain.com/' % lc.fqdn)
Ejemplo n.º 28
0
 def test_remove_arch(self):
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view()
     b.find_element_by_xpath('//ul[@class="nav nav-tabs"]//a[text()="Arch(s)"]').click()
     b.find_element_by_xpath(
             '//div[@id="arches"]'
             '//td[normalize-space(text())="i386"]')
     delete_and_confirm(b, '//tr[normalize-space(td[1]/text())="i386"]')
     self.assertEquals(b.find_element_by_class_name('flash').text, 'i386 Removed')
     b.find_element_by_xpath(
             '//div[@id="arches" and not(.//td[normalize-space(text())="i386"])]')
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
Ejemplo n.º 29
0
    def test_group_has_submitted_job_remove(self):
        with session.begin():
            user = data_setup.create_user(password="******")
            group = data_setup.create_group(owner=user)
            job = data_setup.create_job(owner=user, group=group)

        b = self.browser
        login(b, user=user.user_name, password="******")
        b.get(get_server_base() + "groups/mine")
        delete_and_confirm(
            b,
            "//td[preceding-sibling::td/a[normalize-space(text())='%s']]/form" % group.group_name,
            delete_text="Remove (-)",
        )

        flash_text = b.find_element_by_xpath('//div[@class="flash"]').text
        self.assert_("Cannot delete a group which has associated jobs" in flash_text, flash_text)
Ejemplo n.º 30
0
 def test_remove_system(self):
     with session.begin():
         system = data_setup.create_system()
         self.group.systems.append(system)
     b = self.browser
     login(b)
     b.get(get_server_base() +
           'groups/edit?group_id=%s' % self.group.group_id)
     delete_and_confirm(
         b, '//td[preceding-sibling::td[.//text()="%s"]]' % system.fqdn,
         'Remove')
     self.assertEquals(
         b.find_element_by_class_name('flash').text,
         '%s Removed' % system.fqdn)
     with session.begin():
         session.expire_all()
         self.assert_(system not in self.group.systems)
Ejemplo n.º 31
0
    def test_group_remove(self):
        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_text='Delete Group')
        self.assertEqual(
            b.find_element_by_class_name('flash').text,
            '%s deleted' % self.group.display_name)

        with session.begin():
            self.assertEquals(1, Activity.query
                .filter(Activity.field_name == u'Group')
                .filter(Activity.action == u'Removed')
                .filter(Activity.old_value == self.group.display_name).count(),
                'Expected to find activity record for group removal')
Ejemplo n.º 32
0
    def test_labcontroller(self):
        # Add
        with session.begin():
            lc = data_setup.create_labcontroller(fqdn=data_setup.unique_name(u"lc%s"))
            distro_tree = data_setup.create_distro_tree()
        b = self.browser
        login(b)
        go_to_distro_tree_view(b, distro_tree)
        b.find_element_by_xpath(
            "//select[@id='lab_controller_id']/" "option[normalize-space(text())='%s']" % lc.fqdn
        ).click()
        b.find_element_by_xpath("//input[@id='url']").send_keys("http://blah.com")
        b.find_element_by_name("lab_controller_add_form").submit()
        # A trailing '/' is added automatically if it's not present. RHBZ#912242
        self.assertEqual(b.find_element_by_class_name("flash").text, "Added %s http://blah.com/" % lc.fqdn)

        # Delete
        delete_and_confirm(b, "//td[preceding-sibling::td/a[@href='http://blah.com/']]/form")
        self.assertEqual(b.find_element_by_class_name("flash").text, "Deleted %s http://blah.com/" % lc.fqdn)
Ejemplo n.º 33
0
    def job_delete(self, job):
        b = self.browser
        b.get(get_server_base() + 'jobs')
        b.find_element_by_link_text("Show Search Options").click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('jobsearch-0.table'))\
                .select_by_visible_text('Id')
        Select(b.find_element_by_name('jobsearch-0.operation'))\
                .select_by_visible_text('is')
        b.find_element_by_name('jobsearch-0.value').clear()
        b.find_element_by_name('jobsearch-0.value'). \
            send_keys('%s' % job.id)
        b.find_element_by_id('searchform').submit()

        delete_and_confirm(b, "//tr[td/a[normalize-space(text())='%s']]" % job.t_id)
        # table should have no remaining rows, since we searched by id
        b.find_element_by_xpath("//table[@id='widget']/tbody[not(./tr)]")
        b.get(get_server_base() + 'jobs/%d' % job.id)
        self.assertIn('This job has been deleted.',
                b.find_element_by_class_name('alert-warning').text)
Ejemplo n.º 34
0
 def test_can_remove_tag_from_distro(self):
     b = self.browser
     login(b, data_setup.ADMIN_USER, data_setup.ADMIN_PASSWORD)
     go_to_distro_view(b, self.distro)
     delete_and_confirm(b, '//td[normalize-space(preceding-sibling::td[1]/text())="SAD"]')
     self.assertEquals(b.find_element_by_class_name('flash').text,
             'Removed Tag SAD')
     b.find_element_by_xpath('//div[@class="tags"]//table[not('
             './/td[normalize-space(text())="SAD"])]')
     with session.begin():
         session.refresh(self.distro)
         self.assert_(u'SAD' not in self.distro.tags)
     with session.begin():
         session.refresh(self.distro)
         activity = self.distro.activity[0]
         self.assertEquals(activity.field_name, u'Tag')
         self.assertEquals(activity.service, u'WEBUI')
         self.assertEquals(activity.action, u'Removed')
         self.assertEquals(activity.old_value, u'SAD')
         self.assertEquals(activity.new_value, None)
Ejemplo n.º 35
0
 def test_remove_group(self):
     with session.begin():
         group = data_setup.create_group()
         self.system.groups.append(group)
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Groups')
     b.find_element_by_xpath(
             '//td[normalize-space(text())="%s"]' % group.group_name)
     delete_and_confirm(b, '//tr[normalize-space(td[1]/text())="%s"]'
             % group.group_name)
     self.assertEquals(b.find_element_by_class_name('flash').text,
             '%s Removed' % group.display_name)
     b.find_element_by_xpath(
             '//div[@id="groups" and not(.//td[normalize-space(text())="%s"])]'
             % group.group_name)
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
Ejemplo n.º 36
0
 def test_removing_submission_delegate(self):
     with session.begin():
         submission_delegate = data_setup.create_user()
         self.user.submission_delegates[:] = [submission_delegate]
     b = self.browser
     b.get(get_server_base() + 'prefs')
     delete_and_confirm(b, '//td[preceding-sibling::td/text()="%s"]'
             % submission_delegate, 'Remove (-)')
     self.assertEquals(b.find_element_by_class_name('flash').text,
         '%s removed as a submission delegate' % submission_delegate)
     # Check they have been removed in DB
     session.expire(self.user)
     with session.begin():
         self.assertEquals(self.user.submission_delegates, [])
         activity = self.user.user_activity[-1]
         self.assertEqual(activity.action, u'Removed')
         self.assertEqual(activity.field_name, u'Submission delegate')
         self.assertEqual(activity.user.user_id, self.user.user_id)
         self.assertEqual(activity.old_value, submission_delegate.user_name)
         self.assertEqual(activity.new_value, None)
Ejemplo n.º 37
0
 def test_can_remove_tag_from_distro(self):
     b = self.browser
     login(b, data_setup.ADMIN_USER, data_setup.ADMIN_PASSWORD)
     go_to_distro_view(b, self.distro)
     delete_and_confirm(b, '//td[normalize-space(preceding-sibling::td[1]/text())="SAD"]')
     self.assertEquals(b.find_element_by_class_name('flash').text,
             'Removed Tag SAD')
     b.find_element_by_xpath('//div[@class="tags"]//table[not('
             './/td[normalize-space(text())="SAD"])]')
     with session.begin():
         session.refresh(self.distro)
         self.assert_(u'SAD' not in self.distro.tags)
     with session.begin():
         session.refresh(self.distro)
         activity = self.distro.activity[0]
         self.assertEquals(activity.field_name, u'Tag')
         self.assertEquals(activity.service, u'WEBUI')
         self.assertEquals(activity.action, u'Removed')
         self.assertEquals(activity.old_value, u'SAD')
         self.assertEquals(activity.new_value, None)
Ejemplo n.º 38
0
 def test_remove_group(self):
     with session.begin():
         group = data_setup.create_group()
         self.system.groups.append(group)
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Groups')
     b.find_element_by_xpath('//td[normalize-space(text())="%s"]' %
                             group.group_name)
     delete_and_confirm(
         b, '//tr[normalize-space(td[1]/text())="%s"]' % group.group_name)
     self.assertEquals(
         b.find_element_by_class_name('flash').text,
         '%s Removed' % group.display_name)
     b.find_element_by_xpath(
         '//div[@id="groups" and not(.//td[normalize-space(text())="%s"])]'
         % group.group_name)
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
Ejemplo n.º 39
0
 def test_delete_install_options(self):
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view()
     b.find_element_by_xpath('//ul[@class="nav nav-tabs"]//a[text()="Install Options"]').click()
     delete_and_confirm(b, '//tr[th/text()="Architecture"]')
     b.find_element_by_xpath('//h1[text()="%s"]' % self.system.fqdn)
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
         self.assert_(self.distro_tree.arch not in self.system.provisions)
         self.assertEquals(self.system.activity[0].action, u'Removed')
         self.assertEquals(self.system.activity[0].field_name,
                 u'InstallOption:kernel_options_post:i386')
         self.assertEquals(self.system.activity[1].action, u'Removed')
         self.assertEquals(self.system.activity[1].field_name,
                 u'InstallOption:kernel_options:i386')
         self.assertEquals(self.system.activity[2].action, u'Removed')
         self.assertEquals(self.system.activity[2].field_name,
                 u'InstallOption:ks_meta:i386')
Ejemplo n.º 40
0
    def test_deleted_whiteboard_not_shown(self):
        b = self.browser
        with session.begin():
            owner = data_setup.create_user(password='******')
            whiteboard = u'To be deleted %d' % int(time.time() * 1000)
            self.passed_job.owner = owner
            self.passed_job.whiteboard = whiteboard
        login(b, user=owner.user_name, password='******')
        b.get(get_server_base() + 'matrix')
        whiteboard_options = b.find_element_by_xpath("//select[@name='whiteboard']").text

        # Confirm the whitebaoard is there before we delete it
        self.assert_(self.passed_job.whiteboard in whiteboard_options)

        #Now delete the only job with that whiteboard
        b.get(get_server_base() + 'jobs/%s' % self.passed_job.id)
        delete_and_confirm(b, "//form[@action='delete_job_page']")

        # Confirm it is no longer there
        b.get(get_server_base() + 'matrix')
        whiteboard_options = b.find_element_by_xpath("//select[@name='whiteboard']").text
        self.assert_(self.passed_job.whiteboard not in whiteboard_options)
Ejemplo n.º 41
0
    def job_delete(self, job):
        b = self.browser
        b.get(get_server_base() + 'jobs')
        b.find_element_by_link_text("Show Search Options").click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('jobsearch-0.table'))\
                .select_by_visible_text('Id')
        Select(b.find_element_by_name('jobsearch-0.operation'))\
                .select_by_visible_text('is')
        b.find_element_by_name('jobsearch-0.value').clear()
        b.find_element_by_name('jobsearch-0.value'). \
            send_keys('%s' % job.id)
        b.find_element_by_id('searchform').submit()

        delete_and_confirm(b, "//tr[td/a[normalize-space(text())='%s']]" % job.t_id)
        b.find_element_by_xpath("//table[@id='widget']//"
            "a[not(normalize-space(text())='%s')]" % job.t_id)
        recipe = job.recipesets[0].recipes[0]
        b.get(get_server_base() + 'recipes/%d' % recipe.id)
        warn_text = b.find_element_by_class_name('flash').text
        self.assertTrue('Invalid R:%s, has been deleted' %
            recipe.id in warn_text)
Ejemplo n.º 42
0
 def test_removing_submission_delegate(self):
     with session.begin():
         submission_delegate = data_setup.create_user()
         self.user.submission_delegates[:] = [submission_delegate]
     b = self.browser
     b.get(get_server_base() + 'prefs')
     delete_and_confirm(
         b, '//td[preceding-sibling::td/text()="%s"]' % submission_delegate,
         'Remove (-)')
     self.assertEquals(
         b.find_element_by_class_name('flash').text,
         '%s removed as a submission delegate' % submission_delegate)
     # Check they have been removed in DB
     session.expire(self.user)
     with session.begin():
         self.assertEquals(self.user.submission_delegates, [])
         activity = self.user.user_activity[-1]
         self.assertEqual(activity.action, u'Removed')
         self.assertEqual(activity.field_name, u'Submission delegate')
         self.assertEqual(activity.user.user_id, self.user.user_id)
         self.assertEqual(activity.old_value, submission_delegate.user_name)
         self.assertEqual(activity.new_value, None)
Ejemplo n.º 43
0
 def test_remove_key_value(self):
     with session.begin():
         self.system.key_values_int.append(
                 Key_Value_Int(Key.by_name(u'NR_DISKS'), 100))
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Key/Values')
     b.find_element_by_xpath(
             '//td[normalize-space(preceding-sibling::td[1]/text())'
             '="NR_DISKS" and '
             'normalize-space(text())="100"]')
     delete_and_confirm(b, '//tr[normalize-space(td[1]/text())="NR_DISKS" and '
             'normalize-space(td[2]/text())="100"]')
     self.assertEquals(b.find_element_by_class_name('flash').text,
             'removed NR_DISKS/100')
     b.find_element_by_xpath('//div[@id="keys" and not(.//tr['
             'normalize-space(td[1]/text())="NR_DISKS" and '
             'normalize-space(td[2]/text())="100"])]')
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
Ejemplo n.º 44
0
    def test_deleted_job_results_not_shown(self):
        with session.begin():
            data_setup.create_completed_job(
                whiteboard=self.job_whiteboard,
                result=TaskResult.fail,
                recipe_whiteboard=self.recipe_whiteboard)
            data_setup.create_completed_job(
                whiteboard=self.job_whiteboard,
                result=TaskResult.warn,
                recipe_whiteboard=self.recipe_whiteboard)
            owner = data_setup.create_user(password='******')
            self.passed_job.owner = owner
        b = self.browser
        login(b, user=owner.user_name, password='******')
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath(
            "//select[@name='whiteboard']/option[@value='%s']" %
            self.job_whiteboard).click()
        b.find_element_by_xpath(
            '//button[@type="submit" and text()="Generate"]').click()
        report_text = b.find_element_by_xpath(
            "//div[@id='matrix-report']").text
        self.assert_('Pass: 1' in report_text)

        # Delete Job
        b.get(get_server_base() + 'jobs/%s' % self.passed_job.id)
        delete_and_confirm(b, "//form[@action='delete_job_page']")

        # Assert it is no longer there
        b.get(get_server_base() + 'matrix')
        b.find_element_by_xpath(
            "//select[@name='whiteboard']/option[@value='%s']" %
            self.job_whiteboard).click()
        b.find_element_by_xpath(
            '//button[@type="submit" and text()="Generate"]').click()
        report_text = b.find_element_by_xpath(
            "//div[@id='matrix-report']").text
        self.assert_('Pass: 1' not in report_text)
Ejemplo n.º 45
0
 def test_remove_key_value(self):
     with session.begin():
         self.system.key_values_int.append(
             Key_Value_Int(Key.by_name(u'NR_DISKS'), 100))
     orig_date_modified = self.system.date_modified
     b = self.browser
     login(b)
     self.go_to_system_view(tab='Key/Values')
     b.find_element_by_xpath(
         '//td[normalize-space(preceding-sibling::td[1]/text())'
         '="NR_DISKS" and '
         'normalize-space(text())="100"]')
     delete_and_confirm(
         b, '//tr[normalize-space(td[1]/text())="NR_DISKS" and '
         'normalize-space(td[2]/text())="100"]')
     self.assertEquals(
         b.find_element_by_class_name('flash').text, 'removed NR_DISKS/100')
     b.find_element_by_xpath('//div[@id="keys" and not(.//tr['
                             'normalize-space(td[1]/text())="NR_DISKS" and '
                             'normalize-space(td[2]/text())="100"])]')
     with session.begin():
         session.refresh(self.system)
         self.assert_(self.system.date_modified > orig_date_modified)
Ejemplo n.º 46
0
    def job_delete(self, job):
        b = self.browser
        b.get(get_server_base() + 'jobs')
        b.find_element_by_link_text("Toggle Search").click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('jobsearch-0.table'))\
                .select_by_visible_text('Id')
        Select(b.find_element_by_name('jobsearch-0.operation'))\
                .select_by_visible_text('is')
        b.find_element_by_name('jobsearch-0.value').clear()
        b.find_element_by_name('jobsearch-0.value'). \
            send_keys('%s' % job.id)
        b.find_element_by_xpath("//input[@value='Search']").click()

        delete_and_confirm(b, "//td[preceding-sibling::td/"
            "a[normalize-space(text())='%s']]/div" % job.t_id)
        b.find_element_by_xpath("//table[@id='widget']//"
            "a[not(normalize-space(text())='%s')]" % job.t_id)
        recipe = job.recipesets[0].recipes[0]
        b.get(get_server_base() + 'recipes/%d' % recipe.id)
        warn_text = b.find_element_by_xpath('//div[@class="flash"]').text
        self.assertTrue('Invalid R:%s, has been deleted' %
            recipe.id in warn_text)
Ejemplo n.º 47
0
    def job_delete(self, job):
        b = self.browser
        b.get(get_server_base() + 'jobs')
        b.find_element_by_link_text("Show Search Options").click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('jobsearch-0.table'))\
                .select_by_visible_text('Id')
        Select(b.find_element_by_name('jobsearch-0.operation'))\
                .select_by_visible_text('is')
        b.find_element_by_name('jobsearch-0.value').clear()
        b.find_element_by_name('jobsearch-0.value'). \
            send_keys('%s' % job.id)
        b.find_element_by_id('searchform').submit()

        delete_and_confirm(
            b, "//tr[td/a[normalize-space(text())='%s']]" % job.t_id)
        # table should have no remaining rows, since we searched by id
        b.find_element_by_xpath("//table[@id='widget']/tbody[not(./tr)]")
        recipe = job.recipesets[0].recipes[0]
        b.get(get_server_base() + 'recipes/%d' % recipe.id)
        warn_text = b.find_element_by_class_name('flash').text
        self.assertTrue('Invalid R:%s, has been deleted' %
                        recipe.id in warn_text)
Ejemplo n.º 48
0
    def test_add_and_remove_permission(self):
        b = self.browser
        login(b)

        b.get(get_server_base() +
              'groups/edit?group_id=%d' % self.group.group_id)
        b.find_element_by_id('Permissions_permissions_text').send_keys(
            self.perm1.permission_name)
        b.find_element_by_id('Permissions').submit()
        #Test that permission dynamically updated
        b.find_element_by_xpath(
            '//table[@id="group_permission_grid"]//td[text()="%s"]' %
            self.perm1.permission_name)

        #Test that the permission was persisted by reopening the current page
        b.get(get_server_base() +
              'groups/edit?group_id=%d' % self.group.group_id)
        b.find_element_by_xpath(
            '//table[@id="group_permission_grid"]//td[text()="%s"]' %
            self.perm1.permission_name)

        #Let's try and remove it
        delete_and_confirm(
            b, '//td[preceding-sibling::td/text()="%s"]' %
            self.perm1.permission_name, 'Remove')
        #Check it has been removed from the table
        b.find_element_by_xpath('//table[@id="group_permission_grid" and '
                                'not(.//td/text()="%s")]' %
                                self.perm1.permission_name)

        #Reload to make sure it has been removed from the DB
        b.get(get_server_base() +
              'groups/edit?group_id=%d' % self.group.group_id)
        b.find_element_by_xpath('//table[@id="group_permission_grid" and '
                                'not(.//td/text()="%s")]' %
                                self.perm1.permission_name)
Ejemplo n.º 49
0
    def test_deleted_whiteboard_not_shown(self):
        b = self.browser
        with session.begin():
            owner = data_setup.create_user(password='******')
            whiteboard = u'To be deleted %d' % int(time.time() * 1000)
            self.passed_job.owner = owner
            self.passed_job.whiteboard = whiteboard
        login(b, user=owner.user_name, password='******')
        b.get(get_server_base() + 'matrix')
        whiteboard_options = b.find_element_by_xpath(
            "//select[@name='whiteboard']").text

        # Confirm the whitebaoard is there before we delete it
        self.assert_(self.passed_job.whiteboard in whiteboard_options)

        #Now delete the only job with that whiteboard
        b.get(get_server_base() + 'jobs/%s' % self.passed_job.id)
        delete_and_confirm(b, "//form[@action='delete_job_page']")

        # Confirm it is no longer there
        b.get(get_server_base() + 'matrix')
        whiteboard_options = b.find_element_by_xpath(
            "//select[@name='whiteboard']").text
        self.assert_(self.passed_job.whiteboard not in whiteboard_options)
Ejemplo n.º 50
0
    def test_labcontroller(self):
        # Add
        with session.begin():
            lc = data_setup.create_labcontroller(fqdn=data_setup. \
                                                 unique_name(u'lc%s'))
            distro_tree = data_setup.create_distro_tree()
        b = self.browser
        login(b)
        go_to_distro_tree_view(b, distro_tree)
        b.find_element_by_xpath("//select[@id='lab_controller_id']/"
            "option[normalize-space(text())='%s']" % lc.fqdn).click()
        b.find_element_by_xpath("//input[@id='url']"). \
            send_keys('http://blah.com')
        b.find_element_by_link_text('Add ( + )').click()
        # A trailing '/' is added automatically if it's not present. RHBZ#912242
        self.assertEqual(
            b.find_element_by_xpath('//div[@class="flash"]').text,
            'Added %s http://blah.com/' % lc.fqdn)

        # Delete
        delete_and_confirm(b, "//td[preceding-sibling::td/a[@href='http://blah.com/']]/form", delete_text='Delete ( - )')
        self.assertEqual(
            b.find_element_by_xpath('//div[@class="flash"]').text,
            'Deleted %s http://blah.com/' % lc.fqdn)
Ejemplo n.º 51
0
    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=''))