diff --git a/tests/base_test_class.py b/tests/base_test_class.py index b9ccf352905..3ffb6f8a050 100644 --- a/tests/base_test_class.py +++ b/tests/base_test_class.py @@ -215,6 +215,10 @@ def goto_all_engagements_overview(self, driver): def goto_all_engagements_by_product_overview(self, driver): return self.goto_engagements_internal(driver, "engagements_all") + def goto_add_template(self, driver): + driver.get(self.base_url + "template/add") + return driver + def goto_engagements_internal(self, driver, rel_url): driver.get(self.base_url + rel_url) self.wait_for_datatable_if_content("no_engagements", "engagements_wrapper") diff --git a/tests/finding_test.py b/tests/finding_test.py index ec59e6a5796..189e4a5cce4 100644 --- a/tests/finding_test.py +++ b/tests/finding_test.py @@ -173,7 +173,7 @@ def test_add_note_to_finding(self): # "Click" the submit button to complete the transaction driver.find_element(By.XPATH, "//input[@value='Add Note']").click() - # Assert ot the query to dtermine status of failure + # Assert ot the query to determine status of failure self.assertTrue(self.is_success_message_present(text='Note saved.')) def test_mark_finding_for_review(self): @@ -185,7 +185,7 @@ def test_mark_finding_for_review(self): driver.find_element(By.LINK_TEXT, "App Vulnerable to XSS").click() # Click on the 'dropdownMenu1 button' driver.find_element(By.ID, "dropdownMenu1").click() - # Click on `Request Peer Reveiw` + # Click on `Request Peer Review` driver.find_element(By.LINK_TEXT, "Request Peer Review").click() # select Reviewer # Let's make the first user in the list a reviewer @@ -318,7 +318,7 @@ def test_simple_accept_finding(self): # Click on `Close Finding` driver.find_element(By.LINK_TEXT, "Accept Risk").click() # Query the site to determine if the finding has been added - # Assert ot the query to dtermine status of failure + # Assert ot the query to determine status of failure self.assertTrue(self.is_success_message_present(text='Finding risk accepted.')) # Check to see if the endpoint was mitigated # Select and click on the particular finding to edit @@ -398,14 +398,14 @@ def test_apply_template_to_a_finding(self): self.assertNoConsoleErrors() # Query the site to determine if the finding has been added - # Assert ot the query to dtermine status of failure + # Assert ot the query to determine status of failure self.assertTrue(self.is_text_present_on_page(text='App Vulnerable to XSS')) @on_exception_html_source_logger def test_create_finding_from_template(self): driver = self.driver # Navigate to All Finding page - # goto engagemnent list (and wait for javascript to load) + # goto engagement list (and wait for javascript to load) self.goto_all_engagements_overview(driver) # Select a previously created engagement title @@ -481,6 +481,30 @@ def test_import_scan_result(self): # Assert ot the query to dtermine status of failure self.assertTrue(self.is_success_message_present(text='ZAP Scan processed a total of 4 findings')) + def test_create_finding_template(self): + # Go to add a new template + driver = self.driver + self.goto_add_template(driver) + # Enter Title + driver.find_element(By.ID, "id_title").send_keys("Template for App Vulnerable to XSS") + # Select List replace + driver.find_element(By.ID, "id_list_replace").click() + # Enter Findings to replace + driver.find_element(By.ID, "id_findings_to_replace").send_keys("App Vulnerable to XSS") + # Save Template + driver.find_element(By.NAME, "add_template").click() + # Template created successfully + self.assertTrue(self.is_text_present_on_page(text='Template created successfully.')) + + + def test_check_if_template_applied(self): + # Go to all findings + driver = self.driver + self.goto_all_findings_list(driver) + # Check if the template is applied + self.assertTrue(self.is_text_present_on_page(text="Template for App Vulnerable to XSS")) + + @on_exception_html_source_logger def test_delete_finding(self): # The Name of the Finding created by test_add_product_finding => 'App Vulnerable to XSS' @@ -492,7 +516,7 @@ def test_delete_finding(self): self.goto_all_findings_list(driver) # Select and click on the particular finding to edit - driver.find_element(By.LINK_TEXT, "App Vulnerable to XSS").click() + driver.find_element(By.LINK_TEXT, "Template for App Vulnerable to XSS").click() # Click on the 'dropdownMenu1 button' driver.find_element(By.ID, "dropdownMenu1").click() # Click on `Delete Finding` @@ -516,7 +540,7 @@ def add_finding_tests_to_suite(suite, jira=False, github=False, block_execution= suite.addTest(BaseTestCase('test_login')) set_suite_settings(suite, jira=jira, github=github, block_execution=block_execution) - # Add each test the the suite to be run + # Add each test the suite to be run # success and failure is output by the test suite.addTest(BaseTestCase('delete_finding_template_if_exists')) suite.addTest(ProductTest('test_create_product')) @@ -546,6 +570,8 @@ def add_finding_tests_to_suite(suite, jira=False, github=False, block_execution= suite.addTest(FindingTest('test_apply_template_to_a_finding')) suite.addTest(FindingTest('test_create_finding_from_template')) suite.addTest(FindingTest('test_import_scan_result')) + suite.addTest(FindingTest('test_create_finding_template')) + suite.addTest(FindingTest('test_check_if_template_applied')) suite.addTest(FindingTest('test_delete_finding')) suite.addTest(FindingTest('test_delete_finding_template')) suite.addTest(ProductTest('test_delete_product'))