forked from DefectDojo/django-DefectDojo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdedupe_unit_test.py
493 lines (426 loc) · 27.6 KB
/
dedupe_unit_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import unittest
import sys
import os
from base_test_class import BaseTestCase, on_exception_html_source_logger
from Product_unit_test import ProductTest
import time
dir_path = os.path.dirname(os.path.realpath(__file__))
class DedupeTest(BaseTestCase):
# --------------------------------------------------------------------------------------------------------
# Initialization
# --------------------------------------------------------------------------------------------------------
def setUp(self):
super().setUp()
self.relative_path = dir_path = os.path.dirname(os.path.realpath(__file__))
def check_nb_duplicates(self, expected_number_of_duplicates):
print("checking duplicates...")
retries = 0
for i in range(0, 18):
time.sleep(5) # wait bit for celery dedupe task which can be slow on travis
driver = self.login_page()
self.goto_all_findings_list(driver)
dupe_count = 0
# iterate over the rows of the findings table and concatenates all columns into td.text
trs = driver.find_elements_by_xpath('//*[@id="open_findings"]/tbody/tr')
for row in trs:
concatRow = ' '.join([td.text for td in row.find_elements_by_xpath(".//td")])
# print(concatRow)
if '(DUPE)' and 'Duplicate' in concatRow:
dupe_count += 1
if (dupe_count != expected_number_of_duplicates):
print("duplicate count mismatch, let's wait a bit for the celery dedupe task to finish and try again (5s)")
else:
break
if (dupe_count != expected_number_of_duplicates):
findings_table = driver.find_element_by_id('open_findings')
print(findings_table.get_attribute('innerHTML'))
self.assertEqual(dupe_count, expected_number_of_duplicates)
@on_exception_html_source_logger
def test_enable_deduplication(self):
print("enabling deduplication...")
driver = self.login_page()
driver.get(self.base_url + 'system_settings')
if not driver.find_element_by_id('id_enable_deduplication').is_selected():
driver.find_element_by_xpath('//*[@id="id_enable_deduplication"]').click()
# save settings
driver.find_element_by_css_selector("input.btn.btn-primary").click()
# check if it's enabled after reload
driver.get(self.base_url + 'system_settings')
self.assertTrue(driver.find_element_by_id('id_enable_deduplication').is_selected())
@on_exception_html_source_logger
def test_delete_findings(self):
print("removing previous findings...")
driver = self.login_page()
driver.get(self.base_url + "finding?page=1")
if self.element_exists_by_id("no_findings"):
text = driver.find_element_by_id("no_findings").text
if 'No findings found.' in text:
return
driver.find_element_by_id("select_all").click()
driver.find_element_by_css_selector("i.fa.fa-trash").click()
try:
WebDriverWait(driver, 1).until(EC.alert_is_present(),
'Timed out waiting for PA creation ' +
'confirmation popup to appear.')
driver.switch_to.alert.accept()
except TimeoutException:
self.fail('Confirmation dialogue not shown, cannot delete previous findings')
text = None
if self.element_exists_by_id("no_findings"):
text = driver.find_element_by_id("no_findings").text
self.assertTrue('No findings found.' in text)
# check that user was redirect back to url where it came from based on return_url
self.assertTrue(driver.current_url.endswith('page=1'))
# --------------------------------------------------------------------------------------------------------
# Same scanner deduplication - Deduplication on engagement
# Test deduplication for Bandit SAST scanner
# --------------------------------------------------------------------------------------------------------
@on_exception_html_source_logger # noqa: E301
def test_add_path_test_suite(self):
print("Same scanner deduplication - Deduplication on engagement - static. Creating tests...")
# Create engagement
driver = self.login_page()
self.goto_product_overview(driver)
driver.find_element_by_class_name("pull-left").click()
driver.find_element_by_link_text("Add New Engagement").click()
driver.find_element_by_id("id_name").send_keys("Dedupe Path Test")
driver.find_element_by_xpath('//*[@id="id_deduplication_on_engagement"]').click()
driver.find_element_by_name("_Add Tests").click()
self.assertTrue(self.is_success_message_present(text='Engagement added successfully.'))
# Add the tests
# Test 1
driver.find_element_by_id("id_title").send_keys("Path Test 1")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Bandit Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_name("_Add Another Test").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
# Test 2
driver.find_element_by_id("id_title").send_keys("Path Test 2")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Bandit Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_css_selector("input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
@on_exception_html_source_logger
def test_import_path_tests(self):
print("importing reports...")
# First test
driver = self.login_page()
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Path Test").click()
driver.find_element_by_partial_link_text("Path Test 1").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
# active and verified:
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_path_1.json")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
# Second test
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Path Test").click()
driver.find_element_by_partial_link_text("Path Test 2").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_path_2.json")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
@on_exception_html_source_logger
def test_check_path_status(self):
# comparing tests/dedupe_scans/dedupe_path_1.json and tests/dedupe_scans/dedupe_path_2.json
# Counts the findings that have on the same line "(DUPE)" (in the title) and "Duplicate" (marked as duplicate by DD)
# We have imported 3 findings twice, but one only is a duplicate because for the 2 others, we have changed either the line number or the file_path
self.check_nb_duplicates(1)
# --------------------------------------------------------------------------------------------------------
# Same scanner deduplication - Deduplication on engagement
# Test deduplication for Immuniweb dynamic scanner
# --------------------------------------------------------------------------------------------------------
@on_exception_html_source_logger
def test_add_endpoint_test_suite(self):
print("Same scanner deduplication - Deduplication on engagement - dynamic. Creating tests...")
# Create engagement
driver = self.login_page()
self.goto_product_overview(driver)
driver.find_element_by_class_name("pull-left").click()
driver.find_element_by_link_text("Add New Engagement").click()
driver.find_element_by_id("id_name").send_keys("Dedupe Endpoint Test")
driver.find_element_by_xpath('//*[@id="id_deduplication_on_engagement"]').click()
driver.find_element_by_name("_Add Tests").click()
self.assertTrue(self.is_success_message_present(text='Engagement added successfully.'))
# Add the tests
# Test 1
driver.find_element_by_id("id_title").send_keys("Endpoint Test 1")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Immuniweb Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_name("_Add Another Test").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
# Test 2
driver.find_element_by_id("id_title").send_keys("Endpoint Test 2")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Immuniweb Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_css_selector("input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
@on_exception_html_source_logger
def test_import_endpoint_tests(self):
print("Importing reports...")
# First test : Immuniweb Scan (dynamic)
driver = self.login_page()
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Endpoint Test").click()
driver.find_element_by_partial_link_text("Endpoint Test 1").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
# active and verified
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_endpoint_1.xml")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
# Second test : Immuniweb Scan (dynamic)
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Endpoint Test").click()
driver.find_element_by_partial_link_text("Endpoint Test 2").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
# active and verified
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_endpoint_2.xml")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
@on_exception_html_source_logger
def test_check_endpoint_status(self):
# comparing dedupe_endpoint_1.xml and dedupe_endpoint_2.xml
# Counts the findings that have on the same line "(DUPE)" (in the title) and "Duplicate" (marked as duplicate by DD)
# We have imported 3 findings twice, but one only is a duplicate because for the 2 others, we have changed either (the URL) or (the name and cwe)
self.check_nb_duplicates(1)
@on_exception_html_source_logger
def test_add_same_eng_test_suite(self):
print("Test different scanners - same engagement - dynamic; Adding tests on the same engagement...")
# Create engagement
driver = self.login_page()
self.goto_product_overview(driver)
driver.find_element_by_class_name("pull-left").click()
driver.find_element_by_link_text("Add New Engagement").click()
driver.find_element_by_id("id_name").send_keys("Dedupe Same Eng Test")
driver.find_element_by_xpath('//*[@id="id_deduplication_on_engagement"]').click()
driver.find_element_by_name("_Add Tests").click()
self.assertTrue(self.is_success_message_present(text='Engagement added successfully.'))
# Add the tests
# Test 1
driver.find_element_by_id("id_title").send_keys("Same Eng Test 1")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Immuniweb Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_name("_Add Another Test").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
# Test 2
driver.find_element_by_id("id_title").send_keys("Same Eng Test 2")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Generic Findings Import")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_css_selector("input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
@on_exception_html_source_logger
def test_import_same_eng_tests(self):
print("Importing reports")
# First test : Immuniweb Scan (dynamic)
driver = self.login_page()
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Same Eng Test").click()
driver.find_element_by_partial_link_text("Same Eng Test 1").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_endpoint_1.xml")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
# Second test : Generic Findings Import with Url (dynamic)
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Same Eng Test").click()
driver.find_element_by_partial_link_text("Same Eng Test 2").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_cross_1.csv")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
@on_exception_html_source_logger
def test_check_same_eng_status(self):
# comparing dedupe_endpoint_1.xml and dedupe_endpoint_2.xml
# Counts the findings that have on the same line "(DUPE)" (in the title) and "Duplicate" (marked as duplicate by DD)
# We have imported 3 findings twice, but one only is a duplicate because for the 2 others, we have changed either (the URL) or (the name and cwe)
self.check_nb_duplicates(1)
# --------------------------------------------------------------------------------------------------------
# Same scanner deduplication - Deduplication on engagement
# Test deduplication for Checkmarx SAST Scan with custom hash_code computation
# Upon import, Checkmarx Scan aggregates on : categories, cwe, name, sinkFilename
# That test shows that the custom hash_code (excluding line number, see settings.py)
# makes it possible to detect the duplicate even if the line number has changed (which will occur in a normal software lifecycle)
# --------------------------------------------------------------------------------------------------------
def test_add_path_test_suite_checkmarx_scan(self):
print("Same scanner deduplication - Deduplication on engagement. Test dedupe on checkmarx aggregated with custom hash_code computation")
# Create engagement
driver = self.login_page()
self.goto_product_overview(driver)
driver.find_element_by_class_name("pull-left").click()
driver.find_element_by_link_text("Add New Engagement").click()
driver.find_element_by_id("id_name").send_keys("Dedupe on hash_code only")
driver.find_element_by_xpath('//*[@id="id_deduplication_on_engagement"]').click()
driver.find_element_by_name("_Add Tests").click()
self.assertTrue(self.is_success_message_present(text='Engagement added successfully.'))
# Add the tests
# Test 1
driver.find_element_by_id("id_title").send_keys("Path Test 1")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Checkmarx Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_name("_Add Another Test").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
# Test 2
driver.find_element_by_id("id_title").send_keys("Path Test 2")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Checkmarx Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_css_selector("input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
def test_import_path_tests_checkmarx_scan(self):
# First test
driver = self.login_page()
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe on hash_code only").click()
driver.find_element_by_partial_link_text("Path Test 1").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
# os.path.realpath makes the path canonical
driver.find_element_by_id('id_file').send_keys(os.path.realpath(self.relative_path + "/dedupe_scans/multiple_findings.xml"))
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 2 findings were processed'))
# Second test
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe on hash_code only").click()
driver.find_element_by_partial_link_text("Path Test 2").click()
driver.find_element_by_id("dropdownMenu1").click()
driver.find_element_by_link_text("Re-Upload Scan").click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(os.path.realpath(self.relative_path + "/dedupe_scans/multiple_findings_line_changed.xml"))
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 2 findings were processed'))
def test_check_path_status_checkmarx_scan(self):
# After aggregation, it's only two findings. Both are duplicates even though the line number has changed
# because we ignore the line number when computing the hash_code for this scanner
# (so that findings keep being found as duplicate even if the code changes slightly)
self.check_nb_duplicates(2)
# --------------------------------------------------------------------------------------------------------
# Cross scanners deduplication - product-wide deduplication
# Test deduplication for Generic Findings Import with URL (dynamic) vs Immuniweb dynamic scanner
# --------------------------------------------------------------------------------------------------------
def test_add_cross_test_suite(self):
print("Cross scanners deduplication dynamic; generic finding vs immuniweb. Creating tests...")
# Create generic engagement
driver = self.login_page()
self.goto_product_overview(driver)
driver.find_element_by_class_name("pull-left").click()
driver.find_element_by_link_text("Add New Engagement").click()
driver.find_element_by_id("id_name").send_keys("Dedupe Generic Test")
# driver.find_element_by_xpath('//*[@id="id_deduplication_on_engagement"]').click()
driver.find_element_by_name("_Add Tests").click()
self.assertTrue(self.is_success_message_present(text='Engagement added successfully.'))
# Test
driver.find_element_by_id("id_title").send_keys("Generic Test")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Generic Findings Import")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_css_selector("input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
# Create immuniweb engagement
self.goto_product_overview(driver)
driver.find_element_by_class_name("pull-left").click()
driver.find_element_by_link_text("Add New Engagement").click()
driver.find_element_by_id("id_name").send_keys("Dedupe Immuniweb Test")
# driver.find_element_by_xpath('//*[@id="id_deduplication_on_engagement"]').click()
driver.find_element_by_name("_Add Tests").click()
self.assertTrue(self.is_success_message_present(text='Engagement added successfully.'))
# Test
driver.find_element_by_id("id_title").send_keys("Immuniweb Test")
Select(driver.find_element_by_id("id_test_type")).select_by_visible_text("Immuniweb Scan")
Select(driver.find_element_by_id("id_environment")).select_by_visible_text("Development")
driver.find_element_by_css_selector("input.btn.btn-primary").click()
self.assertTrue(self.is_success_message_present(text='Test added successfully'))
def test_import_cross_test(self):
print("Importing findings...")
# First test : Immuniweb Scan (dynamic)
driver = self.login_page()
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Immuniweb Test").click()
driver.find_element_by_partial_link_text("Immuniweb Test").click()
driver.find_element_by_css_selector("b.fa.fa-ellipsis-v").click()
driver.find_element_by_link_text("Re-Upload Scan Results").click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_endpoint_1.xml")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
# Second test : generic scan with url (dynamic)
self.goto_active_engagements_overview(driver)
driver.find_element_by_partial_link_text("Dedupe Generic Test").click()
driver.find_element_by_partial_link_text("Generic Test").click()
driver.find_element_by_css_selector("b.fa.fa-ellipsis-v").click()
driver.find_element_by_link_text("Re-Upload Scan Results").click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[3]/div/div').click()
driver.find_element_by_xpath('//*[@id="base-content"]/form/div[4]/div/div').click()
driver.find_element_by_id('id_file').send_keys(self.relative_path + "/dedupe_scans/dedupe_cross_1.csv")
driver.find_elements_by_css_selector("button.btn.btn-primary")[1].click()
self.assertTrue(self.is_success_message_present(text='a total of 3 findings were processed'))
def test_check_cross_status(self):
self.check_nb_duplicates(1)
def add_dedupe_tests_to_suite(suite):
suite.addTest(ProductTest('test_create_product'))
suite.addTest(DedupeTest('test_enable_deduplication'))
# Test same scanners - same engagement - static - dedupe
suite.addTest(DedupeTest('test_delete_findings'))
suite.addTest(DedupeTest('test_add_path_test_suite'))
suite.addTest(DedupeTest('test_import_path_tests'))
suite.addTest(DedupeTest('test_check_path_status'))
# Test same scanners - same engagement - dynamic - dedupe
suite.addTest(DedupeTest('test_delete_findings'))
suite.addTest(DedupeTest('test_add_endpoint_test_suite'))
suite.addTest(DedupeTest('test_import_endpoint_tests'))
suite.addTest(DedupeTest('test_check_endpoint_status'))
# Test different scanners - same engagement - dynamic - dedupe
suite.addTest(DedupeTest('test_delete_findings'))
suite.addTest(DedupeTest('test_add_same_eng_test_suite'))
suite.addTest(DedupeTest('test_import_same_eng_tests'))
suite.addTest(DedupeTest('test_check_same_eng_status'))
# Test same scanners - same engagement - static - dedupe with custom hash_code
suite.addTest(DedupeTest('test_delete_findings'))
suite.addTest(DedupeTest('test_add_path_test_suite_checkmarx_scan'))
suite.addTest(DedupeTest('test_import_path_tests_checkmarx_scan'))
suite.addTest(DedupeTest('test_check_path_status_checkmarx_scan'))
# Test different scanners - different engagement - dynamic - dedupe
suite.addTest(DedupeTest('test_delete_findings'))
suite.addTest(DedupeTest('test_add_cross_test_suite'))
suite.addTest(DedupeTest('test_import_cross_test'))
suite.addTest(DedupeTest('test_check_cross_status'))
# Clean up
suite.addTest(ProductTest('test_delete_product'))
return suite
def suite():
suite = unittest.TestSuite()
add_dedupe_tests_to_suite(suite)
suite.addTest(DedupeTest('enable_jira'))
suite.addTest(DedupeTest('enable_github'))
suite.addTest(DedupeTest('enable_block_execution'))
add_dedupe_tests_to_suite(suite)
return suite
if __name__ == "__main__":
runner = unittest.TextTestRunner(descriptions=True, failfast=True, verbosity=2)
ret = not runner.run(suite()).wasSuccessful()
BaseTestCase.tearDownDriver()
sys.exit(ret)