예제 #1
0
    def test_loan_request(self):
        mail_capture_thread.start_capturing()
        b = self.browser

        # Test can send loan request succesfully
        b.get(get_server_base() + 'view/%s' % self.system.fqdn)
        b.find_element_by_link_text('Loan').click()
        b.find_element_by_xpath('//button[text()="Request Loan"]').click()
        b.find_element_by_name('message').send_keys('request loan')
        b.find_element_by_xpath('//button[text()="Request"]').click()
        # Wait for our success box
        b.find_element_by_xpath('//div[contains(@class, "alert-success")]'
                '/h4[text()="Request sent"]')
        # Check the email was sent
        captured_mails = mail_capture_thread.stop_capturing()
        self.assertEquals(len(captured_mails), 1)
        sender, rcpts, raw_msg = captured_mails[0]
        payload = 'A Beaker user has requested you loan them the system\n' \
            '%s <%sview/%s>.\n' \
            'Here is a copy of their request:\n' \
            'request loan\n Requested by: %s' \
            % (self.system_fqdn, get_server_base(), self.system_fqdn,
                self.problem_reporter.display_name)
        self._std_check_mail(sender, rcpts, raw_msg, 'loan-request',
            payload, 'Loan request for %s' % self.system.fqdn)
예제 #2
0
    def test_by_key_value_is(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.system_one],
            absent=[self.system_two, self.system_three, self.system_four])

        # Key Value search from "Removed Systems"
        b.get(urljoin(get_server_base(), 'removed'))
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.system_four],
            absent=[self.system_one, self.system_two, self.system_three])
예제 #3
0
    def test_report_problem(self):
        mail_capture_thread.start_capturing()
        b = self.browser

        # Test can send problem report succesfully
        b.get(get_server_base() + 'view/%s' % self.system.fqdn)
        b.find_element_by_xpath('//button[text()="Report problem"]').click()
        b.find_element_by_name('message').send_keys('testing problem')
        b.find_element_by_xpath('//button[text()="Report"]').click()
        # Wait for our success box
        b.find_element_by_xpath('//div[contains(@class, "alert-success")]'
                '/h4[text()="Report sent"]')
        # Check the email was sent
        captured_mails = mail_capture_thread.stop_capturing()
        self.assertEquals(len(captured_mails), 1)
        sender, rcpts, raw_msg = captured_mails[0]
        payload = 'A Beaker user has reported a problem with system \n' \
            '%s <%sview/%s>.\n\n' \
            'Reported by: %s\n\n' \
            'Problem description:\n' \
            'testing problem' \
            % (self.system_fqdn, get_server_base(), self.system_fqdn,
                self.problem_reporter.display_name)
        self._std_check_mail(sender, rcpts, raw_msg, 'system-problem',
            payload, 'Problem reported for %s' % self.system.fqdn)
예제 #4
0
    def test_by_key_value_is(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_one],
                                    absent=[self.system_two, 
                                            self.system_three, 
                                            self.system_four])

        # Key Value search from "Removed Systems"
        b.get(urljoin(get_server_base(), 'removed'))
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Key/Value')
        Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
            .select_by_visible_text('CPUMODEL')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('foocodename')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_four],
                                    absent=[self.system_one, 
                                            self.system_two, 
                                            self.system_three])
예제 #5
0
    def test_loaned_not_free(self):
        with session.begin():
            lc1 = data_setup.create_labcontroller()
            self.system_one.lab_controller = lc1

        b = self.browser
        b.get(get_server_base() + 'free')
        self.assertEquals(b.title, 'Free Systems')
        check_system_search_results(b, present=[], absent=[self.system_one])

        with session.begin():
            self.system_one.loaned = User.by_user_name(data_setup.ADMIN_USER)
        b.get(get_server_base() + 'free')
        self.assertEquals(b.title, 'Free Systems')
        check_system_search_results(b, present=[self.system_one])
예제 #6
0
    def test_loaned_not_free(self):
        with session.begin():
            lc1 = data_setup.create_labcontroller()
            self.system_one.lab_controller=lc1

        b = self.browser
        b.get(get_server_base() + 'free')
        self.assertEquals(b.title, 'Free Systems')
        check_system_search_results(b, present=[], absent=[self.system_one])

        with session.begin():
            self.system_one.loaned = User.by_user_name(data_setup.ADMIN_USER)
        b.get(get_server_base() + 'free')
        self.assertEquals(b.title, 'Free Systems')
        check_system_search_results(b, present=[self.system_one])
예제 #7
0
 def test_numa_column(self):
     with session.begin():
         system_with_numa = data_setup.create_system()
         system_with_numa.numa = Numa(nodes=2)
         system_without_numa = data_setup.create_system()
         system_without_numa.numa = None
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/NumaNodes')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is not')
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/NumaNodes').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[system_with_numa],
                                 absent=[system_without_numa])
     b.find_element_by_xpath('//table[@id="widget"]'
                             '//td[2][normalize-space(text())="2"]')
예제 #8
0
def perform_search(browser, searchcriteria, search_url=''):
    b = browser
    b.get(get_server_base() + search_url)
    b.find_element_by_link_text('Show Search Options').click()
    wait_for_animation(b, '#searchform')

    for fieldid, criteria in enumerate(searchcriteria):
        if criteria[0] == 'Key/Value':
            assert len(criteria) == 4, "Key/Value criteria must be specified as" \
                    " ('Key/Value', keyname, operation, value)"
            fieldname, keyvalue, operation, value = criteria
        else:
            fieldname, operation, value = criteria
        if fieldid > 0:
            # press the add button to add a new row
            b.find_element_by_id('doclink').click()
        Select(b.find_element_by_name('systemsearch-%i.table' % fieldid))\
            .select_by_visible_text(fieldname)
        if criteria[0] == 'Key/Value':
            Select(browser.find_element_by_name('systemsearch-%i.keyvalue' % fieldid))\
                .select_by_visible_text(keyvalue)
        Select(b.find_element_by_name('systemsearch-%i.operation' % fieldid))\
            .select_by_visible_text(operation)
        b.find_element_by_name('systemsearch-%i.value' % fieldid).clear()
        b.find_element_by_name('systemsearch-%i.value' % fieldid).send_keys(value)

    b.find_element_by_id('searchform').submit()
예제 #9
0
 def test_serial_number_column(self):
     with session.begin():
         system_with_serial = data_setup.create_system()
         system_with_serial.serial = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         system_without_serial = data_setup.create_system()
         system_without_serial.serial = None
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/SerialNumber')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     # This also tests that whitespace does not foil us
     b.find_element_by_name('systemsearch-0.value').send_keys(
         ' %s ' % system_with_serial.serial)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name(
         'systemsearch_column_System/SerialNumber').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[system_with_serial],
                                 absent=[system_without_serial])
     b.find_element_by_xpath('//table[@id="widget"]'
                             '//td[2][normalize-space(text())="%s"]' %
                             system_with_serial.serial)
예제 #10
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))
예제 #11
0
 def test_simple_search(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_name('simplesearch').send_keys(self.distro_one.name)
     b.find_element_by_id('simpleform').submit()
     check_distro_search_results(b, present=[self.distro_one],
                                 absent=[self.distro_two, self.distro_three])
예제 #12
0
 def test_sort_grid_doesnt_blow_up(self):
     b = self.browser
     b.get(get_server_base() + 'distros/')
     # See if they blow up (They shouldn't)
     b.find_element_by_xpath("//th/a[normalize-space(text())='OS Major Version']").click()
     b.find_element_by_xpath("//th/a[normalize-space(text())='OS Minor Version']").click()
     b.find_element_by_xpath("//title[text()='Distros']")
예제 #13
0
 def test_anonymous_cant_contact_owner(self):
     b = self.browser
     logout(b)
     # Test can't access when not logged in
     b.get(get_server_base() + 'view/%s' % self.system.fqdn)
     b.find_element_by_link_text('Loan').click()
     b.find_element_by_xpath('//div[@id="loan" and not(.//button[text()="Request Loan"])]')
예제 #14
0
 def test_simple_search(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_name('simplesearch').send_keys(self.distro_one.name)
     b.find_element_by_id('simpleform').submit()
     check_distro_search_results(b, present=[self.distro_one],
                                 absent=[self.distro_two, self.distro_three])
예제 #15
0
 def test_serial_number_column(self):
     with session.begin():
         system_with_serial = data_setup.create_system()
         system_with_serial.serial = u'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
         system_without_serial = data_setup.create_system()
         system_without_serial.serial = None
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/SerialNumber')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     # This also tests that whitespace does not foil us
     b.find_element_by_name('systemsearch-0.value').send_keys(
             ' %s ' % system_with_serial.serial)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/SerialNumber').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[system_with_serial],
             absent=[system_without_serial])
     b.find_element_by_xpath('//table[@id="widget"]'
             '//td[2][normalize-space(text())="%s"]' % system_with_serial.serial)
예제 #16
0
 def test_simple_search(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_name('simplesearch').send_keys(self.distro_one.name)
     b.find_element_by_name('search').click()
     self.check_search_results(present=[self.distro_one],
             absent=[self.distro_two, self.distro_three])
예제 #17
0
 def test_pool_column(self):
     with session.begin():
         pool = data_setup.create_system_pool()
         system_in_pool = data_setup.create_system()
         system_in_pool.pools.append(pool)
         system_outside_pool = data_setup.create_system()
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Pools')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys(pool.name)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/Pools').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[system_in_pool],
                                 absent=[system_outside_pool])
     b.find_element_by_xpath('//table[@id="widget"]'
                             '//td[2][normalize-space(text())="%s"]' %
                             pool.name)
예제 #18
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))
예제 #19
0
 def test_by_multiple_key_values_again(self):
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('Key/Value')
     Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
         .select_by_visible_text('HVM')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys('1')
     b.find_element_by_id('doclink').click()
     Select(b.find_element_by_name('systemsearch-1.table'))\
         .select_by_visible_text('Key/Value')
     Select(b.find_element_by_name('systemsearch-1.keyvalue'))\
         .select_by_visible_text('DISKSPACE')
     Select(b.find_element_by_name('systemsearch-1.operation'))\
         .select_by_visible_text('greater than')
     b.find_element_by_name('systemsearch-1.value').send_keys('1000')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(
         b,
         present=[self.system_one],
         absent=[self.system_two, self.system_three])
예제 #20
0
    def test_by_device(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('1112')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b,
                                    present=[self.system_three],
                                    absent=[self.system_one, self.system_two])

        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_vendor_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is not')
        b.find_element_by_name('systemsearch-0.value').send_keys('1111')
        b.find_element_by_id('doclink').click()
        Select(b.find_element_by_name('systemsearch-1.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-1.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-1.value').send_keys('2224')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.system_two],
            absent=[self.system_one, self.system_three])
예제 #21
0
    def test_by_device(self):
        b = self.browser
        b.get(get_server_base())
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-0.value').send_keys('1112')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_three],
                absent=[self.system_one, self.system_two])

        Select(b.find_element_by_name('systemsearch-0.table'))\
            .select_by_visible_text('Devices/Subsys_vendor_id')
        Select(b.find_element_by_name('systemsearch-0.operation'))\
            .select_by_visible_text('is not')
        b.find_element_by_name('systemsearch-0.value').send_keys('1111')
        b.find_element_by_id('doclink').click()
        Select(b.find_element_by_name('systemsearch-1.table'))\
            .select_by_visible_text('Devices/Subsys_device_id')
        Select(b.find_element_by_name('systemsearch-1.operation'))\
            .select_by_visible_text('is')
        b.find_element_by_name('systemsearch-1.value').send_keys('2224')
        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.system_two],
                absent=[self.system_one, self.system_three])
예제 #22
0
    def test_inventoried_search_range(self):

        b = self.browser
        b.get(get_server_base() + 'mine')
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')

        #after
        Select(b.find_element_by_id('systemsearch_0_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_0_operation'))\
            .select_by_visible_text('after')
        b.find_element_by_id('systemsearch_0_value').clear()
        b.find_element_by_id('systemsearch_0_value').send_keys(
            self.date_yesterday)

        b.find_element_by_id('doclink').click()

        #before
        Select(b.find_element_by_id('systemsearch_1_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_1_operation'))\
            .select_by_visible_text('before')
        b.find_element_by_id('systemsearch_1_value').clear()
        b.find_element_by_id('systemsearch_1_value').send_keys(
            self.date_tomorrow)

        b.find_element_by_id('searchform').submit()
        check_system_search_results(
            b,
            present=[self.inv1, self.inv2],
            absent=[self.not_inv, self.inv3, self.inv4])
예제 #23
0
    def test_search_by_tag(self):
        with session.begin():
            released_distro = data_setup.create_distro(
                tags=[u'STABLE', u'RELEASED'])
            data_setup.create_distro_tree(distro=released_distro)
            unreleased_distro = data_setup.create_distro(tags=[u'STABLE'])
            data_setup.create_distro_tree(distro=unreleased_distro)

        b = self.browser
        b.get(get_server_base() + 'distros')
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')
        Select(b.find_element_by_name(
            'distrosearch-0.table')).select_by_visible_text('Tag')
        Select(b.find_element_by_name(
            'distrosearch-0.operation')).select_by_visible_text('is')
        Select(b.find_element_by_name(
            'distrosearch-0.value')).select_by_visible_text('RELEASED')
        b.find_element_by_name('distrosearch').submit()
        check_distro_search_results(b,
                                    present=[released_distro],
                                    absent=[unreleased_distro])

        Select(b.find_element_by_name(
            'distrosearch-0.operation')).select_by_visible_text('is not')
        b.find_element_by_name('distrosearch').submit()
        check_distro_search_results(b,
                                    present=[unreleased_distro],
                                    absent=[released_distro])
예제 #24
0
 def test_group_column(self):
     with session.begin():
         group = data_setup.create_group()
         system_with_group = data_setup.create_system()
         system_with_group.groups.append(group)
         system_without_group = data_setup.create_system()
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Group')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     b.find_element_by_name('systemsearch-0.value').send_keys(group.group_name)
     b.find_element_by_link_text('Toggle Result Columns').click()
     wait_for_animation(b, '#selectablecolumns')
     b.find_element_by_link_text('Select None').click()
     b.find_element_by_name('systemsearch_column_System/Name').click()
     b.find_element_by_name('systemsearch_column_System/Group').click()
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[system_with_group],
             absent=[system_without_group])
     b.find_element_by_xpath('//table[@id="widget"]'
             '//td[2][normalize-space(text())="%s"]' % group.group_name)
예제 #25
0
 def test_sort_grid_doesnt_blow_up(self):
     b = self.browser
     b.get(get_server_base() + 'distros/')
     # See if they blow up (They shouldn't)
     b.find_element_by_xpath("//th/a[normalize-space(text())='OS Major Version']").click()
     b.find_element_by_xpath("//th/a[normalize-space(text())='OS Minor Version']").click()
     b.find_element_by_xpath("//title[text()='Distros']")
예제 #26
0
 def test_no_value(self):
     # This is just a bizarre edge case in how the existing search bar
     # handles adding new rows to the search, causing the value control to
     # be "unsuccessful" in HTML forms parlance.
     # Just delete this test when the search bar is improved in future.
     with session.begin():
         not_virtualised = data_setup.create_system(
             fqdn=u'bz1498804.notvirtualised')
         not_virtualised.hypervisor = None
         virtualised = data_setup.create_system(
             fqdn=u'bz1498804.virtualised')
         virtualised.hypervisor = Hypervisor.by_name(u'KVM')
     b = self.browser
     # Open a page with an existing search filled in.
     b.get(get_server_base() + '?systemsearch-0.table=System%2FName'
           '&systemsearch-0.operation=contains'
           '&systemsearch-0.value=bz1498804')
     # Add a new row to the search
     b.find_element_by_id('doclink').click()
     # Select a field, but don't type anything into the value
     Select(b.find_element_by_name('systemsearch-1.table'))\
         .select_by_visible_text('System/Hypervisor')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b,
                                 present=[not_virtualised],
                                 absent=[virtualised])
예제 #27
0
def perform_search(browser, searchcriteria, search_url=''):
    b = browser
    b.get(get_server_base() + search_url)
    b.find_element_by_link_text('Show Search Options').click()
    wait_for_animation(b, '#searchform')

    for fieldid, criteria in enumerate(searchcriteria):
        if criteria[0] == 'Key/Value':
            assert len(criteria) == 4, "Key/Value criteria must be specified as" \
                    " ('Key/Value', keyname, operation, value)"
            fieldname, keyvalue, operation, value = criteria
        else:
            fieldname, operation, value = criteria
        if fieldid > 0:
            # press the add button to add a new row
            b.find_element_by_id('doclink').click()
        Select(b.find_element_by_name('systemsearch-%i.table' % fieldid))\
            .select_by_visible_text(fieldname)
        if criteria[0] == 'Key/Value':
            Select(browser.find_element_by_name('systemsearch-%i.keyvalue' % fieldid))\
                .select_by_visible_text(keyvalue)
        Select(b.find_element_by_name('systemsearch-%i.operation' % fieldid))\
            .select_by_visible_text(operation)
        b.find_element_by_name('systemsearch-%i.value' % fieldid).clear()
        b.find_element_by_name('systemsearch-%i.value' %
                               fieldid).send_keys(value)

    b.find_element_by_id('searchform').submit()
예제 #28
0
    def test_inventoried_search_range(self):

        b = self.browser
        b.get(get_server_base() + 'mine')
        b.find_element_by_link_text('Show Search Options').click()
        wait_for_animation(b, '#searchform')

        #after
        Select(b.find_element_by_id('systemsearch_0_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_0_operation'))\
            .select_by_visible_text('after')
        b.find_element_by_id('systemsearch_0_value').clear()
        b.find_element_by_id('systemsearch_0_value').send_keys(self.date_yesterday)

        b.find_element_by_id('doclink').click()

        #before
        Select(b.find_element_by_id('systemsearch_1_table'))\
            .select_by_visible_text('System/LastInventoried')
        Select(b.find_element_by_id('systemsearch_1_operation'))\
            .select_by_visible_text('before')
        b.find_element_by_id('systemsearch_1_value').clear()
        b.find_element_by_id('systemsearch_1_value').send_keys(self.date_tomorrow)

        b.find_element_by_id('searchform').submit()
        check_system_search_results(b, present=[self.inv1, self.inv2],
                absent=[self.not_inv, self.inv3, self.inv4])
예제 #29
0
 def test_secret_system_not_visible(self):
     with session.begin():
         secret_system = data_setup.create_system(shared=False, private=True)
     b = self.browser
     login(b, user=self.user.user_name, password=u'password')
     b.get(get_server_base())
     search_for_system(b, secret_system)
     # results grid should be empty
     b.find_element_by_xpath('//table[@id="widget" and not(.//td)]')
예제 #30
0
 def test_secret_system_not_visible(self):
     with session.begin():
         secret_system = data_setup.create_system(shared=False, private=True)
     b = self.browser
     login(b, user=self.user.user_name, password=u'password')
     b.get(get_server_base())
     search_for_system(b, secret_system)
     # results grid should be empty
     b.find_element_by_xpath('//table[@id="widget" and not(.//td)]')
예제 #31
0
 def test_closing_script_tag_from_simplesearch_is_escaped(self):
     bad_string = u"</script><script>alert('hi')</script>"
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_name('simplesearch').send_keys(bad_string)
     b.find_element_by_name('systemsearch_simple').submit()
     # System simplesearch matches on FQDN but we can never have an FQDN 
     # containing </script> so we can only expect empty results. The 
     # important thing is that there should not be a JS alert present.
     b.find_element_by_xpath('//span[@class="item-count" and text()="Items found: 0"]')
예제 #32
0
 def test_secret_system_visible_when_loaned(self):
     with session.begin():
         secret_system = data_setup.create_system(shared=False, private=True)
         secret_system.loaned = self.user
     b = self.browser
     login(b, user=self.user.user_name, password=u'password')
     b.get(get_server_base())
     search_for_system(b, secret_system)
     b.find_element_by_xpath('//table[@id="widget"]'
             '//tr/td[1][./a/text()="%s"]' % secret_system.fqdn)
예제 #33
0
 def test_secret_system_visible_when_loaned(self):
     with session.begin():
         secret_system = data_setup.create_system(shared=False, private=True)
         secret_system.loaned = self.user
     b = self.browser
     login(b, user=self.user.user_name, password=u'password')
     b.get(get_server_base())
     search_for_system(b, secret_system)
     b.find_element_by_xpath('//table[@id="widget"]'
             '//tr/td[1][./a/text()="%s"]' % secret_system.fqdn)
예제 #34
0
 def test_secret_system_visible_to_users_with_view_permission(self):
     with session.begin():
         secret_system = data_setup.create_system(shared=False, private=True)
         secret_system.custom_access_policy.add_rule(SystemPermission.view,
                 user=self.user)
     b = self.browser
     login(b, user=self.user.user_name, password=u'password')
     b.get(get_server_base())
     search_for_system(b, secret_system)
     b.find_element_by_xpath('//table[@id="widget"]'
             '//tr/td[1][./a/text()="%s"]' % secret_system.fqdn)
예제 #35
0
 def test_closing_script_tag_escaped_in_search_bar(self):
     with session.begin():
         Key.lazy_create(key_name=u'</script>')
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('Key/Value')
     Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
         .select_by_visible_text('</script>')
예제 #36
0
 def test_secret_system_visible_to_users_with_view_permission(self):
     with session.begin():
         secret_system = data_setup.create_system(shared=False, private=True)
         secret_system.custom_access_policy.add_rule(SystemPermission.view,
                 user=self.user)
     b = self.browser
     login(b, user=self.user.user_name, password=u'password')
     b.get(get_server_base())
     search_for_system(b, secret_system)
     b.find_element_by_xpath('//table[@id="widget"]'
             '//tr/td[1][./a/text()="%s"]' % secret_system.fqdn)
예제 #37
0
 def job_delete_jobpage(self, job):
     b = self.browser
     b.get(get_server_base() + 'jobs/%d' % \
         job.id)
     b.find_element_by_xpath('//button[normalize-space(string(.))="Delete"]').click()
     modal = b.find_element_by_class_name('modal')
     modal.find_element_by_xpath('.//p[text()="Are you sure you want to '
             'delete this job?"]')
     modal.find_element_by_xpath('.//button[text()="OK"]').click()
     # once it's deleted we are returned to My Jobs grid
     b.find_element_by_xpath('.//title[text()="My Jobs"]')
예제 #38
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)
예제 #39
0
 def test_system_activity_entry_is_correctly_truncated(self):
     with session.begin():
         system = data_setup.create_system()
     b = self.browser
     b.get(get_server_base() + 'view/%s' % system.fqdn)
     b.find_element_by_xpath('//button[text()="Report problem"]').click()
     b.find_element_by_name('message').send_keys(u'a' + u'\u044f' * 100)
     b.find_element_by_xpath('//button[text()="Report"]').click()
     # Wait for our success box
     b.find_element_by_xpath('//div[contains(@class, "alert-success")]'
             '/h4[text()="Report sent"]')
예제 #40
0
 def test_closing_script_tag_escaped_in_search_bar(self):
     with session.begin():
         Key.lazy_create(key_name=u'</script>')
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('Key/Value')
     Select(b.find_element_by_name('systemsearch-0.keyvalue'))\
         .select_by_visible_text('</script>')
예제 #41
0
 def test_system_activity_entry_is_correctly_truncated(self):
     with session.begin():
         system = data_setup.create_system()
     b = self.browser
     b.get(get_server_base() + 'view/%s' % system.fqdn)
     b.find_element_by_link_text('Contact Owner').click()
     b.find_element_by_xpath('//button[.//text()=\'Report Problem\']').click()
     b.find_element_by_name('problem.description').send_keys(u'a' + u'\u044f' * 100)
     b.find_element_by_xpath('//input[@value=\'Report\']').click()
     # Wait for our success box
     SeleniumTestCase.wait_and_try(lambda: b.find_element_by_xpath('//div/span[text()=\'Success\']'))
예제 #42
0
    def test_submission_delegate(self):
        with session.begin():
            submission_delegate = data_setup.create_user(password='******')
            self.user.submission_delegates[:] = [submission_delegate]
        login(self.browser, submission_delegate.user_name, 'password')
        # Go to the jobs page and search for our job
        job = self.job_to_delete
        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()
        # We are only a submission delegate, not the submitter,
        # check we cannot delete
        action_text = b.find_element_by_xpath(
            "//td[preceding-sibling::td/"
            "a[normalize-space(text())='%s']]/"
            "div[contains(@class, 'job-action-container')]" % job.t_id).text
        self.assertTrue('Delete' not in action_text)
        # Now go to the individual job page to test for the lack
        # of a 'Delete' link
        b.get(get_server_base() + 'jobs/%d' % \
            job.id)
        action_text = b. \
            find_element_by_xpath("//div[contains(@class, 'job-action-container')]").text
        self.assertTrue('Delete' not in action_text)

        # Ok add our delegates as the submitters
        with session.begin():
            self.job_to_delete.submitter = submission_delegate
            self.job_to_delete_2.submitter = submission_delegate
        # Now let's see if we can do some deleting
        self.job_delete_jobpage(self.job_to_delete_2)
        self.job_delete(self.job_to_delete)
예제 #43
0
 def test_search_by_osminor(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     b.find_element_by_xpath("//select[@id='distrosearch_0_table']/option[@value='OSMinor']").click()
     b.find_element_by_xpath("//select[@id='distrosearch_0_operation']/option[@value='is']").click()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').clear()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').send_keys('1')
     b.find_element_by_id('searchform').submit()
     check_distro_search_results(b, present=[self.distro_one],
                                 absent=[self.distro_two, self.distro_three])
예제 #44
0
 def test_search_by_osminor(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     b.find_element_by_xpath("//select[@id='distrosearch_0_table']/option[@value='OSMinor']").click()
     b.find_element_by_xpath("//select[@id='distrosearch_0_operation']/option[@value='is']").click()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').clear()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').send_keys('1')
     b.find_element_by_id('searchform').submit()
     check_distro_search_results(b, present=[self.distro_one],
                                 absent=[self.distro_two, self.distro_three])
예제 #45
0
    def test_report_problem_via_job_and_recipe(self):
        with session.begin():
            owner = data_setup.create_user()
            job = data_setup.create_completed_job(owner=owner)
        # Completing a job creates an email which we don't need
        self.mail_capture.captured_mails[:] = []
        b = self.browser
        b.get(get_server_base() + 'jobs/%s' % job.id)
        b.find_element_by_link_text('Report Problem with System').click()
        b.find_element_by_id('problem_description').send_keys('I broke it')
        b.find_element_by_xpath('//input[@value=\'Report\']').click()
        SeleniumTestCase.wait_and_try(lambda: b.find_element_by_xpath('//div/span[text()=\'Success\']'))
        self.assertEqual(len(self.mail_capture.captured_mails), 1)

        self.mail_capture.captured_mails[:] = []
        b.get(get_server_base() + 'recipes/%s' % job.recipesets[0].recipes[0].id)
        b.find_element_by_link_text('Report Problem with System').click()
        b.find_element_by_id('problem_description').send_keys('I broke it')
        b.find_element_by_xpath('//input[@value=\'Report\']').click()
        SeleniumTestCase.wait_and_try(lambda: b.find_element_by_xpath('//div/span[text()=\'Success\']'))
        self.assertEqual(len(self.mail_capture.captured_mails), 1)
예제 #46
0
 def test_can_cancel_delete_modal_successfully(self):
     login(self.browser)
     b = self.browser
     job = self.job_to_delete
     b.get(get_server_base() + 'jobs/%d' % job.id)
     b.find_element_by_xpath('//button[normalize-space(string(.))="Delete"]').click()
     modal = b.find_element_by_class_name('modal')
     modal.find_element_by_xpath('.//p[text()="Are you sure you want to '
             'delete this job?"]')
     modal.find_element_by_xpath('.//button[text()="Cancel"]').click()
     # if delete action is cancelled, the modal is dismissed
     b.find_element_by_xpath('//body[not(.//div[contains(@class, "modal")])]')
예제 #47
0
 def test_can_search_by_numa_node_count(self):
     with session.begin():
         self.system.numa = Numa(nodes=1)
         self.another_system.numa = Numa(nodes=2)
     b = self.browser
     perform_search(b, [('System/NumaNodes', 'greater than', '1')])
     check_system_search_results(b, present=[self.another_system],
             absent=[self.system])
     b.get(get_server_base())
     perform_search(b, [('System/NumaNodes', 'less than', '2')])
     check_system_search_results(b, present=[self.system],
             absent=[self.another_system])
예제 #48
0
    def test_submission_delegate(self):
        with session.begin():
            submission_delegate = data_setup.create_user(password='******')
            self.user.submission_delegates[:] = [submission_delegate]
        login(self.browser, submission_delegate.user_name, 'password')
        # Go to the jobs page and search for our job
        job = self.job_to_delete
        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()
        # We are only a submission delegate, not the submitter,
        # check we cannot delete
        action_text = b.find_element_by_xpath("//td[preceding-sibling::td/"
            "a[normalize-space(text())='%s']]/"
            "div[contains(@class, 'job-action-container')]" % job.t_id).text
        self.assertTrue('Delete' not in action_text)
        # Now go to the individual job page to test for the lack
        # of a 'Delete' link
        b.get(get_server_base() + 'jobs/%d' % \
            job.id)
        action_text = b. \
            find_element_by_xpath("//div[contains(@class, 'job-action-container')]").text
        self.assertTrue('Delete' not in action_text)

        # Ok add our delegates as the submitters
        with session.begin():
            self.job_to_delete.submitter = submission_delegate
            self.job_to_delete_2.submitter = submission_delegate
        # Now let's see if we can do some deleting
        self.job_delete_jobpage(self.job_to_delete_2)
        self.job_delete(self.job_to_delete)
예제 #49
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)
예제 #50
0
 def test_report_problem_via_recipe(self):
     with session.begin():
         owner = data_setup.create_user()
         job = data_setup.create_completed_job(owner=owner)
     # Completing a job creates an email which we don't need
     self.mail_capture.captured_mails[:] = []
     b = self.browser
     b.get(get_server_base() + 'recipes/%s' % job.recipesets[0].recipes[0].id)
     b.find_element_by_link_text('Report Problem with System').click()
     b.find_element_by_id('problem_description').send_keys('I broke it')
     b.find_element_by_xpath('//input[@value=\'Report\']').click()
     b.find_element_by_xpath('//div/span[text()=\'Success\']')
     self.assertEqual(len(self.mail_capture.captured_mails), 1)
예제 #51
0
 def test_search_by_osmajor(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_id('advancedsearch').click()
     wait_for_animation(b, '#searchform')
     b.find_element_by_xpath("//select[@id='distrosearch_0_table']/option[@value='OSMajor']").click()
     b.find_element_by_xpath("//select[@id='distrosearch_0_operation']/option[@value='is']").click()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').clear()
     # This also tests that whitespace does not foil us
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').send_keys('  osmajortest1 ')
     b.find_element_by_name('Search').click()
     self.check_search_results(present=[self.distro_one],
             absent=[self.distro_two, self.distro_three])
예제 #52
0
    def test_loan_request(self):
        b = self.browser

        # Test can send loan request succesfully
        b.get(get_server_base() + 'view/%s' % self.system.fqdn)
        b.find_element_by_link_text('Contact Owner').click()
        b.find_element_by_xpath('//button[.//text()=\'Request Loan\']').click()
        b.find_element_by_name('loan.message').send_keys('request loan')
        b.find_element_by_xpath('//input[@value=\'Request\']').click()
        # Wait for our success box
        SeleniumTestCase.wait_and_try(lambda: b.find_element_by_xpath('//div/span[text()=\'Success\']'))
        # Check the email was sent
        SeleniumTestCase.wait_and_try(lambda: self.assertEqual(len(self.mail_capture.captured_mails), 1))
        sender, rcpts, raw_msg = self.mail_capture.captured_mails[0]
        payload = 'A Beaker user has requested you loan them the system\n' \
            '%s <%sview/%s>.\n' \
            'Here is a copy of their request:\n' \
            'request loan\n Requested by: %s' \
            % (self.system_fqdn, get_server_base(), self.system_fqdn,
                self.problem_reporter.display_name)
        self._std_check_mail(sender, rcpts, raw_msg, 'loan-request',
            payload, 'Loan request for %s' % self.system.fqdn)
예제 #53
0
 def test_search_by_name(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     b.find_element_by_xpath("//select[@id='distrosearch_0_table']/option[@value='Name']").click()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value" and '
                         'not(contains(@title, "date in YYYY-MM-DD format"))]')
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').clear()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').send_keys(self.distro_one.name)
     b.find_element_by_id('searchform').submit()
     check_distro_search_results(b, present=[self.distro_one],
                 absent=[self.distro_two, self.distro_three])
예제 #54
0
 def test_search_by_name(self):
     b = self.browser
     b.get(get_server_base() + 'distros')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     b.find_element_by_xpath("//select[@id='distrosearch_0_table']/option[@value='Name']").click()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value" and '
                         'not(contains(@title, "date in YYYY-MM-DD format"))]')
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').clear()
     b.find_element_by_xpath('//input[@id="distrosearch_0_value"]').send_keys(self.distro_one.name)
     b.find_element_by_id('searchform').submit()
     check_distro_search_results(b, present=[self.distro_one],
                 absent=[self.distro_two, self.distro_three])
예제 #55
0
 def test_search_hypervisor_is_blank(self):
     b = self.browser
     b.get(get_server_base() + 'mine')
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('System/Hypervisor')
     Select(b.find_element_by_name('systemsearch-0.operation'))\
         .select_by_visible_text('is')
     Select(b.find_element_by_name('systemsearch-0.value'))\
         .select_by_visible_text('')
     b.find_element_by_id('searchform').submit()
     check_system_search_results(b, present=[self.phys], absent=[self.kvm, self.xen])
예제 #56
0
 def test_searchbar_dropdowns_are_sorted(self):
     b = self.browser
     b.get(get_server_base())
     b.find_element_by_link_text('Show Search Options').click()
     wait_for_animation(b, '#searchform')
     table_options = b.find_element_by_name('systemsearch-0.table')\
             .find_elements_by_tag_name('option')
     assert_sorted([option.text for option in table_options])
     Select(b.find_element_by_name('systemsearch-0.table'))\
         .select_by_visible_text('Key/Value')
     keyvalue_options = b.find_element_by_name('systemsearch-0.keyvalue')\
             .find_elements_by_tag_name('option')
     assert_sorted([option.text for option in keyvalue_options])