def test_vuln_grouped_route(live_server, sl_operator, vuln): # pylint: disable=unused-argument """test grouped vulns view""" sl_operator.get(url_for('storage.vuln_grouped_route', _external=True)) dt_wait_processing(sl_operator, 'vuln_grouped_table') assert len( sl_operator.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 1
def test_job_list_route_inrow_repeat(live_server, sl_operator, job): # pylint: disable=unused-argument """job list inrow requeue button""" dt_id = 'job_list_table' sl_operator.get(url_for('scheduler.job_list_route', _external=True)) dt_wait_processing(sl_operator, dt_id) sl_operator.find_element_by_id(dt_id).find_element_by_class_name('abutton_submit_dataurl_jobrepeat').click() webdriver_waituntil(sl_operator, EC.alert_is_present()) sl_operator.switch_to.alert.accept() dt_wait_processing(sl_operator, dt_id) assert len(json.loads(job.assignment)['targets']) == Target.query.count()
def test_queue_list_route_inrow_flush(live_server, sl_operator, test_target): # pylint: disable=unused-argument """flush queue inrow button""" dt_id = 'queue_list_table' sl_operator.get(url_for('scheduler.queue_list_route', _external=True)) dt_wait_processing(sl_operator, dt_id) sl_operator.find_element_by_id(dt_id).find_element_by_class_name( 'abutton_submit_dataurl_queueflush').click() webdriver_waituntil(sl_operator, EC.alert_is_present()) sl_operator.switch_to.alert.accept() dt_wait_processing(sl_operator, dt_id) assert not Queue.query.get(test_target.queue_id).targets
def check_select_rows(sclnt, dt_id): """check first-cols and toolbar button selections; there must be exactly 2 rows in the tested table""" # there should be two rows in total dt_elem = dt_wait_processing(sclnt, dt_id) toolbar_elem = sclnt.find_element_by_id('%s_toolbar' % dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 2 # user must be able to select only one dt_elem.find_element_by_xpath( '(//tr[@role="row"]/td[contains(@class, "select-checkbox")])[1]' ).click() assert len( dt_elem.find_elements_by_xpath( '//tbody/tr[@role="row"][contains(@class, "selected")]')) == 1 # select all toolbar_elem.find_element_by_xpath('//a[text()="All"]').click() assert len( dt_elem.find_elements_by_xpath( '//tbody/tr[@role="row"][contains(@class, "selected")]')) == 2 # or deselect any of them toolbar_elem.find_element_by_xpath('//a[text()="None"]').click() assert len( dt_elem.find_elements_by_xpath( '//tbody/tr[@role="row"][contains(@class, "selected")]')) == 0 # pylint: disable=len-as-condition
def check_vulns_multiactions(sclnt, dt_id): """check vuln toolbar actions; there must be 2 rows to perform the test""" # there should be two rows in total dt_elem = dt_wait_processing(sclnt, dt_id) toolbar_elem = sclnt.find_element_by_id('%s_toolbar' % dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 2 # one cloud be be tagged dt_elem.find_element_by_xpath('(//tr[@role="row"]/td[contains(@class, "select-checkbox")])[1]').click() toolbar_elem.find_element_by_xpath('//a[contains(@class, "abutton_tag_multiid") and text()="Info"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert Vuln.query.filter(Vuln.name == 'vuln 1', Vuln.tags.any('info')).one() # or the other one dt_elem.find_element_by_xpath('(//tr[@role="row"]/td[contains(@class, "select-checkbox")])[2]').click() toolbar_elem.find_element_by_xpath('//a[contains(@class, "abutton_tag_multiid") and text()="Report"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert Vuln.query.filter(Vuln.name == 'vuln 2', Vuln.tags.any('report')).one() # both might be tagged at the same time toolbar_elem.find_element_by_xpath('//a[text()="All"]').click() toolbar_elem.find_element_by_xpath('//a[contains(@class, "abutton_tag_multiid") and text()="Todo"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert Vuln.query.filter(Vuln.tags.any('todo')).count() == 2 # or deleted toolbar_elem.find_element_by_xpath('//a[text()="All"]').click() toolbar_elem.find_element_by_xpath('//a[contains(@class, "abutton_delete_multiid")]').click() webdriver_waituntil(sclnt, EC.alert_is_present()) sclnt.switch_to.alert.accept() dt_wait_processing(sclnt, dt_id) assert not Vuln.query.all()
def check_vulns_filtering(sclnt, dt_id): """test vuln views filtering functions""" toolbar_id = '%s_toolbar' % dt_id # there should be 4 rows in total dt_elem = dt_wait_processing(sclnt, dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 4 # one not tagged sclnt.find_element_by_id(toolbar_id).find_element_by_xpath( '//a[text()="Not tagged"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 1 assert dt_elem.find_element_by_xpath('//td/a[text()="vuln 1"]') # three tagged sclnt.find_element_by_id(toolbar_id).find_element_by_xpath( '//a[text()="Tagged"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 3 assert not dt_elem.find_elements_by_xpath('//td/a[text()="vuln 1"]') # two already reviewed sclnt.find_element_by_id(toolbar_id).find_element_by_xpath( '//a[text()="Exclude reviewed"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 2 assert dt_elem.find_element_by_xpath('//td/a[text()="vuln 1"]') assert dt_elem.find_element_by_xpath('//td/a[text()="vuln 2"]') # one should go directly to report sclnt.find_element_by_id(toolbar_id).find_element_by_xpath( '//a[text()="Only Report"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 1 assert dt_elem.find_element_by_xpath('//td/a[text()="vuln 4"]') # and user must be able to loose the filter sclnt.find_element_by_xpath('//a[text()="Unfilter"]').click() dt_elem = dt_wait_processing(sclnt, dt_id) assert len(dt_elem.find_elements_by_xpath('//tbody/tr[@role="row"]')) == 4